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.
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.