> ## 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.

# Create Tool

> Create a new tool within a server.

## Path Parameters

<ParamField path="server_id" type="string" required>
  The UUID of the server to add the tool to (e.g. `836995ae-1cff-41ec-823e-a4f07ccca3a0`). Numeric IDs are also accepted for backwards compatibility.
</ParamField>

## Body Parameters

<ParamField body="name" type="string" required>
  Machine-readable tool name used by AI clients (e.g., `get_weather`). Use `snake_case`.
</ParamField>

<ParamField body="description" type="string">
  Human-readable description. AI clients use this to decide when to call the tool.
</ParamField>

<ParamField body="endpoint_url" type="string">
  The HTTP URL to call when the tool is invoked. Supports `{param}` path placeholders.
</ParamField>

<ParamField body="http_method" default="GET" type="string">
  HTTP method. One of: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`.
</ParamField>

<ParamField body="input_schema" type="object">
  JSON Schema object defining accepted input parameters.
</ParamField>

<ParamField body="parameter_mapping" type="object">
  Maps input parameters to their location in the outbound HTTP request. Each key is a parameter name; the value is an object with:

  * `target` (string, required): where to place the value — `path`, `query`, `body`, or `header`.
  * `key` (string, optional): the key name to use in the request. Defaults to the parameter name.

  Example: `{"city": {"target": "query", "key": "q"}}` sends `city` as `?q=London`.
</ParamField>

<ParamField body="headers" type="object">
  Custom HTTP headers to include in every request to the external API.
</ParamField>

<ParamField body="cache_ttl" default="0" type="integer">
  Cache response for N seconds. Set to 0 to disable.
</ParamField>

<ParamField body="timeout" default="30" type="integer">
  Request timeout in seconds.
</ParamField>

<ParamField body="retry_count" type="integer" default="0">
  Number of automatic retries on failure (0–5). Retries on connection errors and HTTP status codes 408, 429, 500, 502, 503, 504.
</ParamField>

<ParamField body="retry_backoff" type="string" default="exponential">
  Delay strategy between retries. One of: `none` (retry immediately), `linear` (1s, 2s, 3s…), `exponential` (1s, 2s, 4s…).
</ParamField>

<ParamField body="status" default="active" type="string">
  Tool status. One of: `active`, `paused`.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools \
       --header 'Authorization: Bearer gmcp_your_api_key' \
       --header 'content-type: application/json' \
       --data '
  {
    "name": "create_customer",
    "description": "Create a new customer in Stripe",
    "endpoint_url": "https://api.stripe.com/v1/customers",
    "http_method": "POST",
    "input_schema": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "description": "Customer email address"
        },
        "name": {
          "type": "string",
          "description": "Customer full name"
        }
      },
      "required": ["email"]
    },
    "parameter_mapping": {
      "email": {"target": "body"},
      "name": {"target": "body"}
    },
    "timeout": 30,
    "status": "active"
  }
  '
  ```

  ```python Python theme={null}
  import requests
  payload = {
      "name": "create_customer",
      "description": "Create a new customer in Stripe",
      "endpoint_url": "https://api.stripe.com/v1/customers",
      "http_method": "POST",
      "input_schema": {
          "type": "object",
          "properties": {
              "email": {"type": "string", "format": "email", "description": "Customer email"},
              "name": {"type": "string", "description": "Customer full name"}
          },
          "required": ["email"]
      },
      "parameter_mapping": {
          "email": {"target": "body"},
          "name": {"target": "body"}
      },
      "timeout": 30,
      "status": "active"
  }

  response = requests.post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools",
      headers={
          "Authorization": "Bearer gmcp_your_api_key",
          "Content-Type": "application/json"
      },
      json=payload
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools",
    {
      method: "POST",
      headers: {
        "Authorization": "Bearer gmcp_your_api_key",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        name: "create_customer",
        description: "Create a new customer in Stripe",
        endpoint_url: "https://api.stripe.com/v1/customers",
        http_method: "POST",
        input_schema: {
          type: "object",
          properties: {
            email: { type: "string", format: "email" },
            name: { type: "string" }
          },
          required: ["email"]
        },
        parameter_mapping: {
          email: { target: "body" },
          name: { target: "body" }
        },
        timeout: 30,
        status: "active"
      })
    }
  );
  const data = await response.json();
  ```

  ```php PHP theme={null}
  $response = wp_remote_post(
      "https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools",
      [
          "headers" => [
              "Authorization" => "Bearer gmcp_your_api_key",
              "Content-Type"  => "application/json"
          ],
          "body" => json_encode([
              "name"          => "create_customer",
              "description"   => "Create a new customer in Stripe",
              "endpoint_url"  => "https://api.stripe.com/v1/customers",
              "http_method"   => "POST",
              "input_schema"  => [
                  "type"       => "object",
                  "properties" => [
                      "email" => ["type" => "string", "format" => "email"],
                      "name"  => ["type" => "string"]
                  ],
                  "required" => ["email"]
              ],
              "parameter_mapping" => [
                  "email" => ["target" => "body"],
                  "name"  => ["target" => "body"]
              ],
              "timeout" => 30,
              "status"  => "active"
          ])
      ]
  );
  $data = json_decode(wp_remote_retrieve_body($response), true);
  ```

  ```go Go theme={null}
  package main
  import (
  	"fmt"
  	"io"
  	"net/http"
  	"strings"
  )

  func main() {
  	body := strings.NewReader(`{
    "name": "create_customer",
    "description": "Create a new customer in Stripe",
    "endpoint_url": "https://api.stripe.com/v1/customers",
    "http_method": "POST",
    "input_schema": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "description": "Customer email address"
        },
        "name": {
          "type": "string",
          "description": "Customer full name"
        }
      },
      "required": ["email"]
    },
    "parameter_mapping": {
      "email": {"target": "body"},
      "name": {"target": "body"}
    },
    "timeout": 30,
    "status": "active"
  }`)

  	req, _ := http.NewRequest("POST", "https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools", body)
  	req.Header.Set("Authorization", "Bearer gmcp_your_api_key")
  	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  \"name\": \"create_customer\",\n  \"description\": \"Create a new customer in Stripe\",\n  \"endpoint_url\": \"https://api.stripe.com/v1/customers\",\n  \"http_method\": \"POST\",\n  \"input_schema\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"email\": {\n        \"type\": \"string\",\n        \"format\": \"email\",\n        \"description\": \"Customer email address\"\n      },\n      \"name\": {\n        \"type\": \"string\",\n        \"description\": \"Customer full name\"\n      }\n    },\n    \"required\": [\"email\"]\n  },\n  \"parameter_mapping\": {\n    \"email\": {\"target\": \"body\"},\n    \"name\": {\"target\": \"body\"}\n  },\n  \"timeout\": 30,\n  \"status\": \"active\"\n}";

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://yoursite.com/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools"))
              .header("Authorization", "Bearer gmcp_your_api_key")
              .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/wp-json/getmcp/v1/servers/836995ae-1cff-41ec-823e-a4f07ccca3a0/tools')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer gmcp_your_api_key'
  request['Content-Type'] = 'application/json'
  request.body = '{
    "name": "create_customer",
    "description": "Create a new customer in Stripe",
    "endpoint_url": "https://api.stripe.com/v1/customers",
    "http_method": "POST",
    "input_schema": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "description": "Customer email address"
        },
        "name": {
          "type": "string",
          "description": "Customer full name"
        }
      },
      "required": ["email"]
    },
    "parameter_mapping": {
      "email": {"target": "body"},
      "name": {"target": "body"}
    },
    "timeout": 30,
    "status": "active"
  }'

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

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": 5,
    "uuid": "5376af81-6bb8-4b01-800c-508d7672e394",
    "server_id": 1,
    "name": "create_customer",
    "description": "Create a new customer in Stripe",
    "endpoint_url": "https://api.stripe.com/v1/customers",
    "http_method": "POST",
    "input_schema": {
      "type": "object",
      "properties": {
        "email": {"type": "string", "format": "email"},
        "name": {"type": "string"}
      },
      "required": ["email"]
    },
    "parameter_mapping": {
      "email": {"target": "body", "key": "email"},
      "name": {"target": "body", "key": "name"}
    },
    "response_mapping": {
      "selector": "",
      "format": "json",
      "template": ""
    },
    "headers": null,
    "cache_ttl": 0,
    "timeout": 30,
    "rate_limit_per_min": 60,
    "retry_count": 0,
    "retry_backoff": "exponential",
    "sort_order": 0,
    "status": "active",
    "tags": [],
    "last_tested_at": null,
    "last_test_response_ms": null,
    "server_uuid": "836995ae-1cff-41ec-823e-a4f07ccca3a0",
    "server_hex": "a1b2c3d4e5f6a1b2",
    "created_at": "2025-03-18T10:00:00Z",
    "updated_at": "2025-03-18T10:00:00Z"
  }
  ```

  ```json 500 Server Error theme={null}
  {
    "code": "getmcp_create_failed",
    "message": "Failed to create tool.",
    "data": { "status": 500 }
  }
  ```
</ResponseExample>
