McpTool
class McpTool implements Approvable, Tool
Traits
Constants
| protected MCP_CLIENT_TOOL |
The MCP client tool primitive class name. |
| protected NAME_PREFIX |
The prefix applied to MCP client tool names. |
Properties
| protected Approval|bool|null | $approvalRequirement | from InteractsWithApprovals |
Methods
Indicate that the tool requires approval before execution.
Indicate that the tool may execute without approval.
Determine whether the tool should request approval for the given request.
Format an MCP error payload into tool output.
Create a new MCP client tool wrapper instance.
Determine whether the given value is an MCP client tool primitive.
Get the name of the tool.
Get the description of the tool's purpose.
Get the MCP annotations describing the tool's behavior.
Convert an MCP tool result into tool output.
Convert an MCP error result into tool output.
Extract the text content from an MCP tool result.
Details
in
InteractsWithApprovals at line 17
InteractsWithApprovals
requireApproval(string|null $reason = null)
Indicate that the tool requires approval before execution.
in
InteractsWithApprovals at line 27
InteractsWithApprovals
withoutApproval()
Indicate that the tool may execute without approval.
in
InteractsWithApprovals at line 37
Approval|null
shouldRequestApproval(Request $request)
Determine whether the tool should request approval for the given request.
at line 151
protected Approval|bool
needsApproval(Request $request)
Determine whether the tool needs approval for the given request.
in
NormalizesMcpResult at line 12
protected string
errorMessage(string $text)
Format an MCP error payload into tool output.
in
NormalizesMcpResult at line 24
protected string
json(array $content)
Encode structured MCP content as JSON.
at line 38
__construct(object $tool)
Create a new MCP client tool wrapper instance.
at line 45
static bool
supports(mixed $tool)
Determine whether the given value is an MCP client tool primitive.
at line 53
string
name()
Get the name of the tool.
at line 61
Stringable|string
description()
Get the description of the tool's purpose.
at line 71
array
annotations()
Get the MCP annotations describing the tool's behavior.
at line 79
Stringable|string
handle(Request $request)
Execute the tool.
at line 89
array
schema(JsonSchema $schema)
Get the tool's schema definition.
at line 111
protected string
convertResult(object $result)
Convert an MCP tool result into tool output.
at line 127
protected string
errorResult(object $result)
Convert an MCP error result into tool output.
at line 141
protected string
text(object $result)
Extract the text content from an MCP tool result.