> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# tools/call

> Execute a tool by name with the provided arguments.

The `tools/call` method executes a specific tool with the given arguments. The server validates the arguments against the tool's input schema, calls the configured API endpoint, and returns the result.

## MCP Endpoint

```
POST https://yoursite.com/mcp/{slug}
Content-Type: application/json
```

## Request

<ParamField body="jsonrpc" type="string" required>
  Must be `"2.0"`.
</ParamField>

<ParamField body="id" type="integer | string" required>
  Arbitrary request identifier echoed back unchanged in the response.
</ParamField>

<ParamField body="method" type="string" required>
  Must be `"tools/call"`.
</ParamField>

<ParamField body="params.name" type="string" required>
  The tool name to execute (e.g. `"get_weather"`). Must match a name from `tools/list`.
</ParamField>

<ParamField body="params.arguments" type="object" required>
  Key-value pairs matching the tool's `inputSchema`. Required fields must be present and correctly typed or the call is rejected with a validation error.
</ParamField>

<RequestExample>
  ```bash cURL (GET tool) theme={null}
  curl --request POST \
       --url https://yoursite.com/mcp/my-weather-tools \
       --header 'content-type: application/json' \
       --header 'Mcp-Session-Id: your_session_id' \
       --data '
  {
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "get_weather",
      "arguments": {
        "city": "London"
      }
  }
  }
  '
  ```

  ```bash cURL (POST tool) theme={null}
  curl --request POST \
       --url https://yoursite.com/mcp/stripe-payments \
       --header 'content-type: application/json' \
       --header 'Mcp-Session-Id: your_session_id' \
       --data '
  {
    "jsonrpc": "2.0",
    "id": 5,
    "method": "tools/call",
    "params": {
      "name": "create_customer",
      "arguments": {
        "email": "jane@example.com",
        "name": "Jane Smith"
      }
  }
  }
  '
  ```

  ```go Go theme={null}
  package main

  import (
  	"fmt"
  	"io"
  	"net/http"
  	"strings"
  )

  func main() {
  	body := strings.NewReader(`{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "get_weather",
      "arguments": {
        "city": "London"
      }
  }
  }`)

  	req, _ := http.NewRequest("POST", "https://yoursite.com/mcp/my-weather-tools", body)
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	resp, _ := client.Do(req)
  	defer resp.Body.Close()
  	data, _ := io.ReadAll(resp.Body)
  	fmt.Println(string(data))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  public class Main {
      public static void main(String[] args) throws Exception {
          String json = "{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 4,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"get_weather\",\n    \"arguments\": {\n      \"city\": \"London\"\n    }\n}\n}";

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://yoursite.com/mcp/my-weather-tools"))
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(json))
              .build();

          HttpClient client = HttpClient.newHttpClient();
          HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
          System.out.println(response.body());
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  uri = URI('https://yoursite.com/mcp/my-weather-tools')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'

  request = Net::HTTP::Post.new(uri)
  request['Content-Type'] = 'application/json'
  request.body = '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "get_weather",
      "arguments": {
        "city": "London"
      }
  }
  }'

  response = http.request(request)
  puts JSON.parse(response.body)
  ```
</RequestExample>

## Response

<ResponseField name="result.content" type="array">
  Array of content blocks. Each block has:

  * `type` — Always `"text"` in the current implementation
  * `text` — The upstream API response body as a JSON string
</ResponseField>

<ResponseField name="result.isError" type="boolean">
  Present and `true` when the tool call failed (e.g. upstream API returned an error). The `content` array still contains the error message text.
</ResponseField>

<ResponseExample>
  ```json 200 OK (success) theme={null}
  {
    "jsonrpc": "2.0",
    "id": 4,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "{\"current_condition\":[{\"temp_C\":\"12\",\"temp_F\":\"54\",\"weatherDesc\":[{\"value\":\"Partly cloudy\"}],\"humidity\":\"72\",\"windspeedKmph\":\"15\"}]}"
        }
      ]
    }
  }
  ```

  ```json 200 OK (POST tool creating a resource) theme={null}
  {
    "jsonrpc": "2.0",
    "id": 5,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "{\"id\":\"cus_abc123\",\"object\":\"customer\",\"email\":\"jane@example.com\",\"name\":\"Jane Smith\",\"created\":1710755200}"
        }
      ]
    }
  }
  ```

  ```json 200 OK (tool error) theme={null}
  {
    "jsonrpc": "2.0",
    "id": 4,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "Error: Upstream API returned 404 - City not found"
        }
      ],
      "isError": true
    }
  }
  ```

  ```json 200 OK (method not found) theme={null}
  {
    "jsonrpc": "2.0",
    "id": 4,
    "error": {
      "code": -32601,
      "message": "Method not found: tools/call"
    }
  }
  ```
</ResponseExample>

## Request Parameters

<ParamField body="params.name" type="string" required>
  The name of the tool to call. Must match a tool defined in the server.
</ParamField>

<ParamField body="params.arguments" type="object">
  Key-value pairs matching the tool's `inputSchema`. Required parameters must be provided.
</ParamField>

## Tool Execution Pipeline

When `tools/call` is received:

1. **Validate** — Check the tool exists and is active
2. **Resolve parameters** — Map arguments to the HTTP request (path, query, body, headers)
3. **Inject auth** — Add API credentials to the request
4. **Call API** — Execute the HTTP request to the upstream endpoint
5. **Transform** — Convert the API response into MCP content blocks
6. **Log** — Record the call in the analytics database
7. **Return** — Send the JSON-RPC response
