# Model Context Protocol

URL: https://docs.analytics.remcostoeten.nl/docs/reference/mcp/post-v2-mcp

`POST /v2/mcp`

One JSON-RPC message per request over Streamable HTTP, stateless. Tools call the routes above with the same token; which tools are listed follows the token's scope. Point an MCP client at this URL with the token as a bearer.

Auth: none, or apiToken, or session.

## Request body

Content types: `application/json`, `application/x-www-form-urlencoded`, `multipart/form-data`.

```json
{
  "description": "One JSON-RPC 2.0 message; batches are not accepted."
}
```

## Responses

### 200

The JSON-RPC answer, with `error` for a malformed message, an unknown method or bad arguments. A notification gets an empty 202.

```json
{
  "description": "The JSON-RPC answer, with `error` for a malformed message, an unknown method or bad arguments. A notification gets an empty 202.",
  "type": "object",
  "required": [
    "jsonrpc",
    "id"
  ],
  "properties": {
    "jsonrpc": {
      "const": "2.0",
      "type": "string"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ]
    },
    "result": {
      "type": "object",
      "patternProperties": {
        "^(.*)$": {}
      }
    },
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "anyOf": [
            {
              "format": "integer",
              "default": 0,
              "type": "string"
            },
            {
              "type": "integer"
            }
          ]
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
```

### 202

Response for status 202

### 400

The JSON-RPC answer, with `error` for a malformed message, an unknown method or bad arguments. A notification gets an empty 202.

### 401, 403, 404, 409, 500, 503

The error envelope every failed request answers with.

Body: `#/components/schemas/ApiError`.

## Schemas

### ApiError

`#/components/schemas/ApiError`

```json
{
  "description": "The error envelope every failed request answers with.",
  "examples": [
    {
      "error": {
        "code": "NOT_FOUND",
        "message": "Project not found",
        "requestId": "req_01J8ZB4K2P",
        "docs": "https://api.analytics.remcostoeten.nl/v2/openapi#errors/NOT_FOUND"
      }
    }
  ],
  "type": "object",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "code",
        "message",
        "requestId",
        "docs"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "VALIDATION_FAILED",
            "UNAUTHORIZED",
            "AUTH_REQUIRED",
            "FORBIDDEN_ORIGIN",
            "ORIGIN_NOT_ALLOWED",
            "FORBIDDEN",
            "WIDGET_REPORTS_DISABLED",
            "NOT_FOUND",
            "CONFLICT",
            "PAYLOAD_TOO_LARGE",
            "RATE_LIMITED",
            "INTERNAL",
            "UNAVAILABLE"
          ],
          "description": "- `VALIDATION_FAILED` (400): Body, query or path fails the schema; details lists each field.\n- `UNAUTHORIZED` (401): No or invalid session, token or key.\n- `AUTH_REQUIRED` (401): The widget bootstrap was called without a signed-in session cookie.\n- `FORBIDDEN_ORIGIN` (403): The public key was used from an origin that is not in the project's allowed origins.\n- `ORIGIN_NOT_ALLOWED` (403): The widget bootstrap's Origin is not in any project's allowed origins.\n- `FORBIDDEN` (403): The token scope or the signed-in member's role does not allow the action, or the debug console was opened while the project's debugConsole switch is off.\n- `WIDGET_REPORTS_DISABLED` (403): SDK client reports were sent to a project whose widgetReports switch is off.\n- `NOT_FOUND` (404): Unknown route, project, visitor or session, or a private project without access.\n- `CONFLICT` (409): A project with this id already exists.\n- `PAYLOAD_TOO_LARGE` (413): The ingest body is over 60 KB or has more than 50 events, or a client report body is over 16 KB.\n- `RATE_LIMITED` (429): The per-IP-hash limit was hit; wait for the Retry-After header.\n- `INTERNAL` (500): Unexpected failure; the message never includes internals.\n- `UNAVAILABLE` (503): The database is unreachable, or a feature the route needs is not configured: a job's store, alerts, CRUX_API_KEY, SMTP or Resend; ingest clients retry."
        },
        "message": {
          "minLength": 1,
          "description": "What went wrong, for people. Never includes internals.",
          "type": "string"
        },
        "details": {
          "description": "Extra context for some codes: `fields` with each failed `path` and `message` for `VALIDATION_FAILED`, `retryAfterSeconds` for `RATE_LIMITED`.",
          "type": "object",
          "patternProperties": {
            "^(.*)$": {}
          }
        },
        "requestId": {
          "minLength": 1,
          "description": "The `X-Request-Id` the request sent, or a new `req_<uuid>`; also returned as the `X-Request-Id` header.",
          "type": "string"
        },
        "docs": {
          "format": "uri",
          "description": "Link to this error code in the API reference.",
          "type": "string"
        }
      }
    }
  },
  "$id": "#/components/schemas/ApiError"
}
```
