Imported from Herve-M/net-ssms-mcp (
src/Server.Mcp.Shared/AGENTS.md). Install upstream withnpx skills add Herve-M/net-ssms-mcp --skill Server.Mcp.Shared. Copyright stays with the author.
Server.Mcp.Shared — AGENTS.md
The wire-facing MCP tool layer. Every tool the product exposes lives here, and both hosts
run these same classes: Server.Mcp (stdio) and Server.Api (HTTP). Depends on
Application (Mediator) only — no SMO, no SQL.
How to author a tool (annotations, snake_case parameters, CallToolResult, never throw,
namespace rules, pagination) is not repeated here — see
mcp.md.
Tools
Nine tools across six [McpServerToolType] classes in tools/:
| Class | Tool names |
|---|---|
ServerTools |
get_server_info |
DatabaseTools |
list_databases, list_objects |
TableTools |
describe_table |
ViewTools |
describe_view |
ProcedureTools |
describe_procedure |
SecurityTools |
list_principals, list_role_memberships, list_permissions |
Adding a tool means adding it to AddTools() in DependencyInjection.cs — registration is
explicit (WithTools<T>()), never assembly scanning.
Boundaries
tools/— the tool classes. Each isinternal sealedwith primary-constructor DI (IMediator,IDefaultServerName) and delegates straight to Application handlers.tools/Abstractions/— result shaping shared by ≥2 tools.ToolPayload— theCallToolResultbuilder:Structured<T>(payload)for success,MissingServerName()for the one current error path.ServerInfoResult— composite payload forget_server_info, fanning nineGetServer*Mediator requests into one record.
Abstractions/(layer root) — layer-wide contracts, not tied to one tool.IDefaultServerName— the per-host default data-source, supplied by DI.ServerNameResolver.TryResolve(requested, fallback, out serverName)— prefers an explicitserver_name, falls back to the host default, returnsfalsewhen neither is available.
DependencyInjection.cs—AddTools()(tool registration) andAddDefaultServerName(string?)(per-host default).
Pattern (tool method)
ServerNameResolver.TryResolve(server_name, _defaultServerName, out string resolved); returnToolPayload.MissingServerName()when it fails.await _mediator.Send(new SomeRequest(resolved, …), cancellationToken).- Return
ToolPayload.Structured(result).
Per-host behaviour comes only from DI: stdio registers
AddDefaultServerName(MainConfigurationFactory.MainDataSourceName) so server_name may be
omitted; HTTP registers AddDefaultServerName(null) so it is required. Never fork a tool
class per host.
See tools/ServerTools.cs as the reference implementation.