McpClient class

Modern MCP Client factory with enhanced error handling and configuration

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

createAndConnect({required McpClientConfig config, required TransportConfig transportConfig}) Future<Result<Client, Exception>>
Create and connect a client using the provided configuration
createClient(McpClientConfig config) Client
Create a new MCP client with the specified configuration
createSseTransport({required String serverUrl, Map<String, String>? headers}) Future<Result<SseClientTransport, Exception>>
Create an SSE transport with the given configuration
createStdioTransport({required String command, List<String> arguments = const [], String? workingDirectory, Map<String, String>? environment}) Future<Result<StdioClientTransport, Exception>>
Create a stdio transport with the given configuration
createStreamableHttpTransport({required String baseUrl, Map<String, String>? headers, Duration? timeout, int? maxConcurrentRequests, bool? useHttp2}) Future<Result<StreamableHttpClientTransport, Exception>>
Create a Streamable HTTP transport with the given configuration
productionConfig({required String name, required String version, ClientCapabilities? capabilities}) McpClientConfig
Helper method to create a production-ready client configuration
simpleConfig({required String name, required String version, bool enableDebugLogging = false}) McpClientConfig
Helper method to create a simple client configuration