McpReplExtensions
Extension methods for integrating MCP server support into a Repl app.
- Kind:
Class - Namespace: Repl.Mcp
- Assembly:
Repl.Mcp - Source: src/Repl.Mcp/McpReplExtensions.cs
Signature
Section titled “Signature”public static class McpReplExtensionsInheritance
Section titled “Inheritance”Methods
Section titled “Methods”AddReplMcpServer(IServiceCollection, Action<ReplMcpServerOptions>?)
Section titled “AddReplMcpServer(IServiceCollection, Action<ReplMcpServerOptions>?)”Registers MCP server services in the DI container.
public static IServiceCollection AddReplMcpServer(this IServiceCollection services, Action<ReplMcpServerOptions>? configure = null)Parameters
Section titled “Parameters”services(IServiceCollection): Service collection.configure(Action<ReplMcpServerOptions>): Optional configuration callback.
Returns
Section titled “Returns”IServiceCollection - The same service collection.
BuildMcpServerOptions(ICoreReplApp, Action<ReplMcpServerOptions>?, IServiceProvider?)
Section titled “BuildMcpServerOptions(ICoreReplApp, Action<ReplMcpServerOptions>?, IServiceProvider?)”Builds McpServerOptions from the Repl app’s command graph.
Use this to integrate with custom transports (WebSocket, HTTP) or ASP.NET Core
without going through the mcp serve CLI command.
The returned options capture the current command graph as pre-populated
collections.
public static McpServerOptions BuildMcpServerOptions(this ICoreReplApp app, Action<ReplMcpServerOptions>? configure = null, IServiceProvider? services = null)Parameters
Section titled “Parameters”app(ICoreReplApp): The core Repl app.configure(Action<ReplMcpServerOptions>): Optional MCP configuration callback.services(IServiceProvider): Optional service provider for DI during tool dispatch.
Returns
Section titled “Returns”McpServerOptions - Ready-to-use McpServerOptions for McpServer.Create or ASP.NET integration.
BuildMcpServerOptions(ReplApp, Action<ReplMcpServerOptions>?)
Section titled “BuildMcpServerOptions(ReplApp, Action<ReplMcpServerOptions>?)”Builds McpServerOptions from a ReplApp’s command graph,
automatically using the app’s shared service provider for DI during tool dispatch.
Use this to integrate with custom transports (WebSocket, HTTP) or ASP.NET Core
without going through the mcp serve CLI command.
public static McpServerOptions BuildMcpServerOptions(this ReplApp app, Action<ReplMcpServerOptions>? configure = null)Parameters
Section titled “Parameters”app(ReplApp): The Repl app.configure(Action<ReplMcpServerOptions>): Optional MCP configuration callback.
Returns
Section titled “Returns”McpServerOptions - Ready-to-use McpServerOptions for McpServer.Create or ASP.NET integration.
ConfigureMcpServerOptions(ICoreReplApp, McpServerOptions, Action<ReplMcpServerOptions>?, IServiceProvider?)
Section titled “ConfigureMcpServerOptions(ICoreReplApp, McpServerOptions, Action<ReplMcpServerOptions>?, IServiceProvider?)”Applies the current Core Repl projection to SDK-owned server options.
public static void ConfigureMcpServerOptions(this ICoreReplApp app, McpServerOptions target, Action<ReplMcpServerOptions>? configure = null, IServiceProvider? services = null)Parameters
Section titled “Parameters”app(ICoreReplApp): The core Repl app.target(McpServerOptions): SDK-owned options to configure.configure(Action<ReplMcpServerOptions>): Optional Repl MCP configuration.services(IServiceProvider): Services whose lifetime covers use of the resulting projection.
ConfigureMcpServerOptions(ReplApp, McpServerOptions, Action<ReplMcpServerOptions>?, IServiceProvider?)
Section titled “ConfigureMcpServerOptions(ReplApp, McpServerOptions, Action<ReplMcpServerOptions>?, IServiceProvider?)”Applies the current Repl projection to SDK-owned server options.
public static void ConfigureMcpServerOptions(this ReplApp app, McpServerOptions target, Action<ReplMcpServerOptions>? configure = null, IServiceProvider? services = null)Parameters
Section titled “Parameters”app(ReplApp): The Repl app.target(McpServerOptions): SDK-owned options to configure.configure(Action<ReplMcpServerOptions>): Optional Repl MCP configuration.services(IServiceProvider): Services whose lifetime covers use of the resulting projection; defaults to the app’s shared services.
UseMcpServer(ReplApp, Action<ReplMcpServerOptions>?)
Section titled “UseMcpServer(ReplApp, Action<ReplMcpServerOptions>?)”Enables MCP server mode via {commandName} serve.
public static ReplApp UseMcpServer(this ReplApp app, Action<ReplMcpServerOptions>? configure = null)Parameters
Section titled “Parameters”app(ReplApp): Target Repl app.configure(Action<ReplMcpServerOptions>): Optional configuration callback.
Returns
Section titled “Returns”ReplApp - The same app instance.