Skip to content

McpReplExtensions

Extension methods for integrating MCP server support into a Repl app.

public static class McpReplExtensions

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)
  • services (IServiceCollection): Service collection.
  • configure (Action<ReplMcpServerOptions>): Optional configuration callback.

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)
  • app (ICoreReplApp): The core Repl app.
  • configure (Action<ReplMcpServerOptions>): Optional MCP configuration callback.
  • services (IServiceProvider): Optional service provider for DI during tool dispatch.

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)
  • app (ReplApp): The Repl app.
  • configure (Action<ReplMcpServerOptions>): Optional MCP configuration callback.

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)
  • app (ReplApp): Target Repl app.
  • configure (Action<ReplMcpServerOptions>): Optional configuration callback.

ReplApp - The same app instance.