Skip to content

MCP interface

The query gateway serves the Model Context Protocol so that an AI agent can read your datasets. It is off by default. It reads the same datasets, through the same engine and the same limits, as the HTTP interface (query gateway).

Connecting

Item Value
Protocol MCP revision 2026-07-28, Streamable HTTP. Stateless: no initialize, no session.
Endpoint POST /mcp on queryGateway.serverPort, behind your ingress. The URL is queryGateway.mcp.resourceUrl, e.g. https://gw.example.com/ns/traces/mcp behind the chart's HTTPRoute.
Responses One JSON object per request (Content-Type: application/json), never an SSE stream.
Enable Set queryGateway.mcp.resourceUrl. Set queryGateway.mcp.serveHttpQuery: false for a pod that serves MCP only (the HTTP query route then answers 404; /metrics stays).
TLS Terminated by the ingress, as for the HTTP interface. resourceUrl must be https.

Every request carries the 2026-07-28 headers: MCP-Protocol-Version: 2026-07-28, Mcp-Method, and Mcp-Name on tools/call. They must agree with the body. The body must also name the version in params._meta["io.modelcontextprotocol/protocolVersion"]; a request without it gets 400 -32020, as a header mismatch does.

Authorization

The gateway is an OAuth resource server only. It issues no tokens.

  1. A request without a valid token gets 401 with WWW-Authenticate: Bearer resource_metadata="<resourceUrl base>/.well-known/oauth-protected-resource".
  2. That document (RFC 9728, served without a token) names resourceUrl as resource and queryGateway.auth.issuerUrl as the only authorization server.
  3. The client gets a token from that issuer, with resource=<resourceUrl> (RFC 8707).
  4. The token must pass every HTTP-interface check (signature, expiry, issuer, requiredClaims), and its aud must be resourceUrl. A token for the HTTP interface is refused here. A token for this endpoint is refused there only when queryGateway.auth.audience is set: without it, the HTTP interface does not check aud.

Behind the chart's HTTPRoute, the metadata URL is under the namespace prefix (https://host/ns/<namespace>/.well-known/oauth-protected-resource). A client that ignores resource_metadata and guesses https://host/.well-known/oauth-protected-resource/... does not find it. The MCP specification requires clients to use the header.

A request with an Origin header other than resourceUrl's origin gets 403.

Tools

All tools are read-only. Dataset access follows queryGateway.auth.datasetRoles, as on the HTTP interface.

Tool Arguments Returns
help topic: guide (default) or openapi The usage guide (also in server/discover's instructions), or the HTTP interface's OpenAPI document.
list_datasets none The datasets this token may read, with each one's timeColumn and maxRawWindowDays.
describe_dataset dataset Columns and types, the partition spec, and the partition values the current snapshot covers.
query dataset plus the POST QueryDocument (attributes, filter, groupBy, orderBy, page, limit, tier) A markdown table and a footer.

A query result looks like this:

| service_name | errors |
|---|---|
| auth-api | 412 |
| billing | 87 |

2 rows

Cells are escaped (| → \|, newline → \n) and cut at 500 characters (…). NULL is a null. The footer says more rows may follow: page N when the page is full, and names the boundary when the hot tier was degraded (rows after it are missing). This is the same for the two types of hot source, a PostgreSQL table and the tail service.

Rows are data from your dataset. They appear only in tool results, never in tool descriptions.

Limits

Limit Value
Rows per page 100 by default, at most 1000 (a larger limit is clamped).
Table size 64 KiB. The table stops at the last whole row that fits, and the footer says so.
Concurrency describe_dataset and query each hold one of the pod's maxInFlightHttpQueries slots, shared with the HTTP interface. With none free, the call is a tool error QUERY_CONCURRENCY_EXCEEDED. The other tools and methods take no slot, so they answer on a busy pod.
Everything else As on the HTTP interface: the raw window cap, the manifest budget and the compute deadline.

Errors

Two kinds:

  • Protocol errors are JSON-RPC errors: parse error -32700 (400), invalid request -32600 (400, or 403 for a foreign Origin, or 405 for a method other than POST), header mismatch -32020 (400), unsupported protocol version -32022 (400, with data.supported), unknown method -32601 (404), unknown tool -32602 (200).
  • Tool errors are a 200 result with isError: true. The text is the HTTP interface's error object, {"code", "message", "target", "timestamp"}, with the same codes. For example, FORBIDDEN for a dataset the token may not read and WINDOW_CAP_EXCEEDED for a raw query over too wide a range.

Authentication failures are HTTP 401, and an unreachable identity provider is 503 UPSTREAM_AUTH_UNAVAILABLE, as on the HTTP interface.

Operations

Each request is one audit line with door: "mcp" and, for a tool call, the dataset it named. A refused tool call has status 200 and its error_code. In tracelake_gateway_query_requests_total these requests have method="MCP". Every request counts, not only queries: server/discover, tools/list, help and list_datasets are rows with an empty dataset. Neither the audit line nor the metric names the tool.