Class BowireMcpAdapterServiceCollectionExtensions
- Namespace
- Kuestenlogik.Bowire.Protocol.Mcp
- Assembly
- Kuestenlogik.Bowire.Protocol.Mcp.dll
DI registration for the Bowire MCP adapter — the server side that exposes Bowire's discovered API services as MCP tools, resources, and prompts so AI agents (Claude, Copilot, Cursor) can call them.
public static class BowireMcpAdapterServiceCollectionExtensions
- Inheritance
-
BowireMcpAdapterServiceCollectionExtensions
- Inherited Members
Remarks
Built on the official ModelContextProtocol.AspNetCore SDK:
the previous hand-rolled JSON-RPC pipeline
(McpAdapterServer.HandleMessageAsync) is replaced by the
SDK's AddMcpServer().WithHttpTransport() chain, and tools /
resources / prompts are injected as dynamic handlers because
Bowire's surface depends on what was discovered at runtime, not
what's known at compile time.
Dual-mount coexistence (#287): when paired with
Kuestenlogik.Bowire.Mcp.AddBowireMcp, the adapter installs
its handlers on the shared
BowireMcpDualHandlerDispatcher rather than calling
WithListToolsHandler directly. The dispatcher routes
per-request to either the full server's static tools or the
adapter's dynamic ones based on which prefix the inbound request
hit, so an embedded host can mount both endpoints on the same app
without conflict.
Usage:
// Independent options block — separate from BowireMcpOptions.
builder.Services.AddBowireMcpAdapter(opts =>
{
opts.UpstreamServerUrl = "http://localhost:5005";
opts.RequestTimeout = TimeSpan.FromSeconds(15);
});
var app = builder.Build();
app.MapBowire(opts => opts.Title = "My API");
app.MapBowireMcpAdapter(); // default: /bowire/mcp/adapter
Methods
AddBowireMcpAdapter(IServiceCollection, Action<BowireMcpAdapterOptions>?)
Register the Bowire MCP adapter with a configuration callback against the independent BowireMcpAdapterOptions block. Pair with MapBowireMcpAdapter(IEndpointRouteBuilder, string) at map-time to actually mount the endpoint.
public static IServiceCollection AddBowireMcpAdapter(this IServiceCollection services, Action<BowireMcpAdapterOptions>? configure)
Parameters
servicesIServiceCollectionconfigureAction<BowireMcpAdapterOptions>
Returns
Remarks
The options block is registered through the standard
IOptions<T> pipeline; multiple AddBowireMcpAdapter
calls compose (last writer wins per property). Independent of
BowireMcpOptions (the full-server config) so the two
endpoints can be tuned without cross-contamination.
AddBowireMcpAdapter(IServiceCollection, string?)
Register the Bowire MCP adapter with the legacy positional
argument shape. Equivalent to
AddBowireMcpAdapter(IServiceCollection, Action<BowireMcpAdapterOptions>?)
with a single
UpstreamServerUrl setter.
Kept so existing callers (and the standalone CLI in
BrowserUiHost) don't have to migrate.
public static IServiceCollection AddBowireMcpAdapter(this IServiceCollection services, string? serverUrl = null)
Parameters
servicesIServiceCollectionThe application's service collection.
serverUrlstringThe target server URL the adapter should run discovery and invoke against. Optional; defaults to
http://localhostwhen omitted, matching the previous behaviour ofWithMcpAdapter()without an argument.