MCPTool class
Generic MCP tool wrapper.
This is the base tool that gets cloned and configured per-server in the MCP client. The name, description, prompt, inputSchema, and call method are all overridden when an MCP server registers its tools.
Features:
- Passthrough input schema (accepts any JSON object)
- Passthrough permission check (requires user approval by default)
- Result truncation detection
- Search/read classification for UI collapse
- Progress reporting support
Constructors
Properties
- alwaysLoad → bool
-
Whether this tool should always be loaded (never deferred).
no setterinherited
- classification → McpToolClassification
-
Get the search/read classification for this tool.
no setter
- definition → ToolDefinition
-
Convert to API tool definition.
no setterinherited
- description → String
-
Human-readable description.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputSchema
→ Map<
String, dynamic> -
JSON Schema for the tool's input parameters.
no setteroverride
- interruptBehavior → InterruptBehavior
-
How this tool behaves when interrupted by user input.
no setterinherited
- isAvailable → bool
-
Whether this tool is available on the current platform.
no setterinherited
- isConcurrencySafe → bool
-
Whether this tool is safe to run concurrently with other tools.
no setterinherited
- isDestructive → bool
-
Whether this tool can cause destructive changes.
no setterinherited
- isEnabled → bool
-
Whether this tool is enabled (can be toggled by config).
no setterinherited
- isMcp → bool
-
Whether this tool comes from an MCP server.
no setteroverride
- isReadOnly → bool
-
Whether this tool only reads data (no side effects).
no setterinherited
- isReadTool → bool
-
Whether this tool is classified as a read operation.
no setter
- isSearchTool → bool
-
Whether this tool is classified as a search operation.
no setter
- maxResultSizeChars → int?
-
Maximum size in characters for tool results before disk persistence.
no setteroverride
-
mcpInfo
→ Map<
String, dynamic> ? -
MCP server info if this is an MCP tool.
no setteroverride
- name → String
-
Tool name as registered with the API.
no setteroverride
- prompt → String
-
Detailed prompt text sent in the system prompt for this tool.
no setteroverride
- requiresUserInteraction → bool
-
Whether this tool requires user interaction (prompts, confirmations).
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldDefer → bool
-
Whether this tool should be deferred (loaded on demand via ToolSearch).
no setterinherited
- strict → bool
-
Whether this tool enforces strict JSON output.
no setterinherited
- userFacingName → String
-
Human-facing name for display in permission prompts.
no setteroverride
Methods
-
call(
Map< String, dynamic> input, ToolUseContext context) → Future<ToolResult> -
Execute with full context (default delegates to simple execute).
inherited
-
checkPermissions(
Map< String, dynamic> input, ToolPermissionContext permContext) → Future<PermissionDecision> -
Check if this tool use is permitted. Returns a PermissionDecision.
Override in subclasses for tool-specific permission logic.
override
-
cloneForServer(
{required String name, required String description, required Map< String, dynamic> inputSchema, required MCPServerInfo serverInfo, required Future<ToolResult> callFn(Map<String, dynamic> ), String? prompt, String? userFacingName}) → MCPTool - Create a configured clone of this tool for a specific MCP server tool.
-
execute(
Map< String, dynamic> input) → Future<ToolResult> -
Execute the tool with the given input.
override
-
getActivityDescription(
Map< String, dynamic> input) → String -
Activity description for status display.
inherited
-
getPermissionExplanation(
Map< String, dynamic> input) → PermissionExplanation? -
Permission explanation for this tool.
inherited
-
getToolUseSummary(
Map< String, dynamic> input) → String -
Short summary of tool use for compact/grouped display.
inherited
-
isResultTruncated(
String output) → bool - Check if the result appears truncated.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toAutoClassifierInput(
Map< String, dynamic> input) → String -
Generate classifier input for auto-permission decisions.
Returns empty string to skip classification.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateInput(
Map< String, dynamic> input) → ValidationResult -
Validate input before execution and permission checks.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited