Call Tool
Execute a tool by name with provided arguments. Returns execution results with structured content and error handling.
Overview
The tools/call
method executes a specific tool with provided arguments. Tools perform operations like querying databases, calling APIs, or processing data. All tools require proper OAuth authentication and parameter validation.
Prerequisites
- Session Initialization: Complete
initialize
→notifications/initialized
flow - Authentication: Valid OAuth token or PAT with
mcp.tools.execute
scope - Session ID: Include
Mcp-Session-Id
header from initialization - Tool Discovery: Use tools/list to get available tools and their parameters
Request Format
Request Parameters
Must be "2.0"
(JSON-RPC version)
Unique request identifier (cannot be null)
Must be "tools/call"
Tool execution parameters
Response Format
Always "2.0"
Matches the request ID exactly
Tool execution result (present on success)
Error details (present on failure)
Example Responses
Tool Execution Results
Response Structure
Our implementation follows JSON-RPC 2.0 protocol with these patterns:
- Success Response: Contains
result
field with tool output - Error Response: Contains
error
field with error details
Content Format
Tool results contain a content
array with items of different types:
Type | Description | Fields |
---|---|---|
text | Plain text content | text |
image | Base64-encoded image | data , mimeType |
audio | Base64-encoded audio | data , mimeType |
resource | Embedded resource reference | resource.uri , resource.mimeType , resource.text |
Error Handling Strategy
Implementation Notes
Response Validation
- JSON-RPC compliance: All responses follow JSON-RPC 2.0 format
- Content array: Success responses contain
content
array - Flexible structure: Tests validate basic structure, not strict field requirements
- Error handling: Protocol errors vs tool execution handled through different response patterns
Tool Execution Environment
- Tools execute in controlled environment
- Results formatted as structured content
- Error conditions handled through JSON-RPC error responses
- OAuth validation applied before tool execution
OAuth and Permissions
Required OAuth Scope
mcp.tools.execute
: Required for all tool execution- Tool-specific permissions: Additional filtering based on database permissions
Tool Access Control
- User-specific: Each user sees only their permitted tools
- Database-driven: Tool permissions stored and validated in database
- Session-bound: Permissions validated per session and tool call
Progress Tracking
For long-running tools, include a progress token:
Error Codes
Code | Meaning | Recovery |
---|---|---|
-32000 | Authentication failure | Refresh token, reinitialize session |
-32001 | Resource not found | Verify resource exists |
-32002 | Tool not found | Check tools/list for available tools |
-32602 | Invalid parameters | Validate arguments against tool schema |
-32603 | Internal server error | Retry or contact support |
Parameter Validation
Tools validate parameters against their inputSchema
:
Required Parameters
- All parameters in
required
array must be provided - Missing required parameters return
-32602
error
Type Validation
- Parameters must match schema types (string, integer, number, boolean)
- Invalid types return
-32602
error with details
Value Constraints
- Minimum/maximum values enforced for numbers
- String length limits applied where specified
- Enum values validated against allowed options
Implementation Notes
Request ID Requirements
- Must be unique within session
- Cannot be null (enforced by implementation)
- Used for progress notifications and error correlation
Session Validation
Mcp-Session-Id
header required after initialization- Session must be active and authenticated
- Invalid session returns
-32000
authentication error
Tool Execution Environment
- Tools execute in controlled environment
- Database connections managed per execution
- API rate limits applied per user/tool combination
Performance Considerations
- Tool execution may be rate-limited
- Long-running tools support cancellation via
notifications/cancelled
- Results cached where appropriate
This method provides the core functionality for AI systems to interact with external services through controlled, authenticated tool execution.
Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Headers
MCP session ID (required after initialization)
"session_abc123"
Path Parameters
Tenant identifier (e.g., 'pipedrive', 'salesforce', 'hubspot')
"pipedrive"
Body
Response
JSON-RPC 2.0 response
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.
The response is of type object
.