McpToolset class

Toolset that exposes tools and resources from one MCP connection.

Constructors

McpToolset({required McpConnectionParams connectionParams, Object? toolFilter, String? toolNamePrefix, AuthConfig? authConfig, McpHeaderProvider? headerProvider, McpSamplingCallback? samplingCallback, McpElicitationCallback? elicitationCallback, Map<String, Object?>? samplingCapabilities})
Creates an MCP toolset bound to connectionParams.

Properties

authConfig → AuthConfig?
Optional auth configuration used for MCP tool discovery and calls.
final
connectionParams McpConnectionParams
MCP transport parameters for this toolset.
final
elicitationCallback McpElicitationCallback?
Optional callback used to answer MCP elicitation/create requests.
final
hashCode int
The hash code for this object.
no setterinherited
headerProvider McpHeaderProvider?
Optional callback for injecting request headers dynamically.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
samplingCallback McpSamplingCallback?
Optional callback used to answer MCP sampling/createMessage requests.
final
samplingCapabilities Map<String, Object?>
Optional MCP client capabilities advertised for sampling support.
final
toolFilter Object?
Tool filter expressed as a ToolPredicate or a list of tool names.
getter/setter pairinherited
toolNamePrefix String?
Optional prefix added by getToolsWithPrefix.
getter/setter pairinherited

Methods

close() Future<void>
Releases resources held by this toolset.
getAuthConfig() → AuthConfig?
Returns auth config for this toolset, if tool listing/calls require auth.
getTools({ReadonlyContext? readonlyContext}) Future<List<BaseTool>>
Returns filtered MCP tools discovered from cache or remote server.
getToolsWithPrefix({ReadonlyContext? readonlyContext}) Future<List<BaseTool>>
Returns getTools with an optional toolNamePrefix applied.
inherited
isToolSelected(BaseTool tool, ReadonlyContext? readonlyContext) bool
Returns whether tool should be visible in readonlyContext.
inherited
listResources() Future<List<String>>
Lists available MCP resource names.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
processLlmRequest({required ToolContext toolContext, required LlmRequest llmRequest}) Future<void>
Mutates outgoing llmRequest before model execution.
inherited
readResource(String resourceName) Future<List<McpResourceContent>>
Reads one named MCP resource into content parts.
toString() String
A string representation of this object.
inherited

Operators

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