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

# initialize

> Negotiate the MCP protocol version and receive server capabilities.

The `initialize` method is the first request an AI client must send after connecting. It negotiates the protocol version and returns the server's capabilities, name, and version.

## 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 `"initialize"`.
</ParamField>

<ParamField body="params.protocolVersion" type="string" required>
  The MCP protocol version the client supports (e.g. `"2024-11-05"`).
</ParamField>

<ParamField body="params.capabilities" type="object">
  Client-declared capabilities object (e.g. `roots`, `sampling`). Can be empty `{}`.
</ParamField>

<ParamField body="params.clientInfo.name" type="string">
  Human-readable name of the connecting client (e.g. `"claude-desktop"`).
</ParamField>

<ParamField body="params.clientInfo.version" type="string">
  Version string of the connecting client (e.g. `"1.0.0"`).
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url https://yoursite.com/mcp/my-weather-tools \
       --header 'content-type: application/json' \
       --data '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {
        "roots": {"listChanged": true},
        "sampling": {}
      },
      "clientInfo": {
        "name": "claude-desktop",
        "version": "1.0.0"
      }
  }
  }
  '
  ```

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

  func main() {
  	body := strings.NewReader(`{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {
        "roots": {"listChanged": true},
        "sampling": {}
      },
      "clientInfo": {
        "name": "claude-desktop",
        "version": "1.0.0"
      }
  }
  }`)

  	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\": 1,\n  \"method\": \"initialize\",\n  \"params\": {\n    \"protocolVersion\": \"2024-11-05\",\n    \"capabilities\": {\n      \"roots\": {\"listChanged\": true},\n      \"sampling\": {}\n    },\n    \"clientInfo\": {\n      \"name\": \"claude-desktop\",\n      \"version\": \"1.0.0\"\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": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2024-11-05",
      "capabilities": {
        "roots": {"listChanged": true},
        "sampling": {}
      },
      "clientInfo": {
        "name": "claude-desktop",
        "version": "1.0.0"
      }
  }
  }'

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

## Response

<ResponseField name="result.protocolVersion" type="string">
  The protocol version the server selected (matches or falls back from the client's requested version).
</ResponseField>

<ResponseField name="result.capabilities" type="object">
  Server-declared capabilities. GetMCP reports `tools.listChanged: true`.
</ResponseField>

<ResponseField name="result.serverInfo.name" type="string">
  The server's display name as configured in GetMCP admin.
</ResponseField>

<ResponseField name="result.serverInfo.version" type="string">
  The GetMCP plugin version string.
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
      "protocolVersion": "2024-11-05",
      "capabilities": {
        "tools": {
          "listChanged": true
        }
      },
      "serverInfo": {
        "name": "My Weather Tools",
        "version": "1.0.0"
      }
    }
  }
  ```
</ResponseExample>

## Response Headers

| Header           | Description                              |
| ---------------- | ---------------------------------------- |
| `Mcp-Session-Id` | Session ID to use in subsequent requests |
| `Content-Type`   | `application/json`                       |

## Follow-up Notification

After receiving the `initialize` response, the client should send the `notifications/initialized` notification to signal it's ready:

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "notifications/initialized",
  "params": {}
}
```

This is a notification (no `id` field), so no response is expected.

## Capabilities

GetMCP currently reports:

| Capability          | Value                                             |
| ------------------- | ------------------------------------------------- |
| `tools.listChanged` | `true` — server can notify when tool list changes |
