McpServer class

Modern MCP Server factory with enhanced configuration and error handling

Annotations
  • @immutable

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

createAndStart({required McpServerConfig config, required TransportConfig transportConfig}) Future<Result<Server, Exception>>
Create and start a server using the provided configuration and transport
createServer(McpServerConfig config) Server
Create a new MCP server with the specified configuration
createSseTransport(SseTransportConfig config) Result<SseServerTransport, Exception>
Create an SSE transport with the given configuration
createStdioTransport() Result<StdioServerTransport, Exception>
Create a stdio transport
createStreamableHttpTransport(int port, {String endpoint = '/mcp', String host = 'localhost', List<int>? fallbackPorts, bool isJsonResponseEnabled = false, String? sessionId, String? authToken}) Result<StreamableHttpServerTransport, Exception>
Create a StreamableHTTP transport with the given configuration (sync version)
createStreamableHttpTransportAsync(int port, {String endpoint = '/mcp', String host = 'localhost', List<int>? fallbackPorts, bool isJsonResponseEnabled = false, String? sessionId, String? authToken}) Future<Result<StreamableHttpServerTransport, Exception>>
Create a StreamableHTTP transport with the given configuration
createTransport(TransportConfig config) Result<Future<ServerTransport>, Exception>
Create a transport using unified configuration (Result-based)
productionConfig({required String name, required String version, ServerCapabilities? capabilities}) McpServerConfig
Helper method to create a production-ready server configuration
simpleConfig({required String name, required String version, bool enableDebugLogging = false}) McpServerConfig
Helper method to create a simple server configuration