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.
- A request without a valid token gets
401withWWW-Authenticate: Bearer resource_metadata="<resourceUrl base>/.well-known/oauth-protected-resource". - That document (RFC 9728, served without a token) names
resourceUrlasresourceandqueryGateway.auth.issuerUrlas the only authorization server. - The client gets a token from that issuer, with
resource=<resourceUrl>(RFC 8707). - The token must pass every HTTP-interface check (signature, expiry, issuer,
requiredClaims), and itsaudmust beresourceUrl. A token for the HTTP interface is refused here. A token for this endpoint is refused there only whenqueryGateway.auth.audienceis set: without it, the HTTP interface does not checkaud.
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, or403for a foreignOrigin, or405for a method other thanPOST), header mismatch-32020(400), unsupported protocol version-32022(400, withdata.supported), unknown method-32601(404), unknown tool-32602(200). - Tool errors are a
200result withisError: true. The text is the HTTP interface's error object,{"code", "message", "target", "timestamp"}, with the same codes. For example,FORBIDDENfor a dataset the token may not read andWINDOW_CAP_EXCEEDEDfor 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.