Skip to content

Commit 35fb6e3

Browse files
committed
feat: v3.17.0 — wire NpgsqlRest.Mcp into the standalone client
NpgsqlRestClient now references the Mcp plugin and registers it from a McpOptions config section in CreateCodeGenHandlers (Enabled / UrlPath / ServerName / ServerVersion / Instructions). Disabled by default — when McpOptions:Enabled is not true the server is not registered (no behavior change). Full suite green (2160). Discoverability (appsettings/ConfigTemplate/ConfigDefaults/schema McpOptions section) and docs follow in a separate change.
1 parent d26fde6 commit 35fb6e3

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

NpgsqlRestClient/App.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using NpgsqlRest.UploadHandlers;
1111
using NpgsqlRest.Auth;
1212
using NpgsqlRest.OpenAPI;
13+
using NpgsqlRest.Mcp;
1314

1415
namespace NpgsqlRestClient;
1516

@@ -576,6 +577,21 @@ public List<IEndpointCreateHandler> CreateCodeGenHandlers(string connectionStrin
576577
_builder.ClientLogger?.LogDebug("TypeScript client code generation enabled. FilePath={FilePath}", ts.FilePath);
577578
}
578579

580+
var mcpCfg = _config.NpgsqlRestCfg.GetSection("McpOptions");
581+
if (mcpCfg is not null && _config.GetConfigBool("Enabled", mcpCfg) is true)
582+
{
583+
handlers.Add(new Mcp(new McpOptions
584+
{
585+
Enabled = true,
586+
UrlPath = _config.GetConfigStr("UrlPath", mcpCfg) ?? "/mcp",
587+
ServerName = _config.GetConfigStr("ServerName", mcpCfg),
588+
ServerVersion = _config.GetConfigStr("ServerVersion", mcpCfg),
589+
Instructions = _config.GetConfigStr("Instructions", mcpCfg),
590+
}));
591+
_builder.ClientLogger?.LogDebug("MCP server enabled. UrlPath={UrlPath}",
592+
_config.GetConfigStr("UrlPath", mcpCfg) ?? "/mcp");
593+
}
594+
579595
return handlers;
580596
}
581597

NpgsqlRestClient/NpgsqlRestClient.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<ProjectReference Include="..\plugins\NpgsqlRest.OpenApi\NpgsqlRest.OpenApi.csproj" />
3232
<ProjectReference Include="..\plugins\NpgsqlRest.TsClient\NpgsqlRest.TsClient.csproj" />
3333
<ProjectReference Include="..\plugins\NpgsqlRest.SqlFileSource\NpgsqlRest.SqlFileSource.csproj" />
34+
<ProjectReference Include="..\plugins\NpgsqlRest.Mcp\NpgsqlRest.Mcp.csproj" />
3435
</ItemGroup>
3536

3637
<ItemGroup>

0 commit comments

Comments
 (0)