McpSessionManager class
Central registry and transport manager for MCP sessions.
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
-
callTool(
{required McpConnectionParams connectionParams, required String toolName, required Map< String, dynamic> args, Map<String, String> ? headers}) → Future<Object?> - Calls one MCP tool and returns its JSON-like result payload.
-
clear(
) → void - Clears all cached sessions, tools, resources, and descriptors.
-
configureConnection(
{required McpConnectionParams connectionParams, McpSamplingCallback? samplingCallback, Map< String, Object?> ? samplingCapabilities}) → void - Configures per-connection MCP client-side sampling support.
-
getTools(
McpConnectionParams connectionParams) → List< BaseTool> -
Returns locally registered tools for
connectionParams. -
listPromptArgumentNames(
{required McpConnectionParams connectionParams, required String promptName, Map< String, String> ? headers}) → Future<Set< String> > - Lists argument names declared by a remote MCP prompt definition.
-
listRemoteToolDescriptors(
{required McpConnectionParams connectionParams, bool forceRefresh = true, Map< String, String> ? headers}) → Future<List< Map< >String, Object?> > - Lists remote MCP tool descriptors and optionally refreshes cache.
-
listResources(
McpConnectionParams connectionParams) → List< String> -
Returns locally cached resource names for
connectionParams. -
listResourcesAsync(
McpConnectionParams connectionParams, {Map< String, String> ? headers}) → Future<List< String> > - Lists resources from local cache and remote MCP capabilities.
-
listServerUrls(
) → List< String> - Returns connection keys for all registered MCP servers.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readResource(
{required McpConnectionParams connectionParams, required String resourceName}) → List< McpResourceContent> -
Returns locally cached resource contents for
resourceName. -
readResourceAsync(
{required McpConnectionParams connectionParams, required String resourceName, Map< String, Object?> ? promptArguments, Map<String, String> ? headers}) → Future<List< McpResourceContent> > - Reads one MCP resource or prompt result from the remote server.
-
registerResources(
{required McpConnectionParams connectionParams, required Map< String, List< resources}) → voidMcpResourceContent> > -
Registers static
resourcesfor one MCPconnectionParamsscope. -
registerToolExecutor(
{required McpConnectionParams connectionParams, required String toolName, required McpToolExecutor executor}) → void -
Registers a custom
executorfortoolNamewithin one connection. -
registerTools(
{required McpConnectionParams connectionParams, required List< BaseTool> tools}) → void -
Registers local
toolsfor the given MCPconnectionParams. -
subscribeResource(
{required McpConnectionParams connectionParams, required String resourceUri, Map< String, String> ? headers}) → Future<void> - Subscribes to resource-change notifications when supported.
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribeResource(
{required McpConnectionParams connectionParams, required String resourceUri, Map< String, String> ? headers}) → Future<void> - Unsubscribes from resource-change notifications when supported.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → McpSessionManager
-
Shared process-wide session manager instance.
final