Table of Contents

Class McpServerFactory

Namespace
ModelContextProtocol.Server
Assembly
ModelContextProtocol.dll

Provides a factory for creating IMcpServer instances.

public static class McpServerFactory
Inheritance
McpServerFactory
Inherited Members

Remarks

This is the recommended way to create IMcpServer instances. The factory handles proper initialization of server instances with the required dependencies.

Methods

Create(ITransport, McpServerOptions, ILoggerFactory?, IServiceProvider?)

Creates a new instance of an IMcpServer.

public static IMcpServer Create(ITransport transport, McpServerOptions serverOptions, ILoggerFactory? loggerFactory = null, IServiceProvider? serviceProvider = null)

Parameters

transport ITransport

Transport to use for the server representing an already-established MCP session.

serverOptions McpServerOptions

Configuration options for this server, including capabilities.

loggerFactory ILoggerFactory

Logger factory to use for logging. If null, logging will be disabled.

serviceProvider IServiceProvider

Optional service provider to create new instances of tools and other dependencies.

Returns

IMcpServer

An IMcpServer instance that should be disposed when no longer needed.

Exceptions

ArgumentNullException

transport is null.

ArgumentNullException

serverOptions is null.