MCP server (streamable HTTP)
A Model Context Protocol server over streamable HTTP (JSON responses, no event stream).
https://api.transitlab.nyc/mcp API keyTools: list_tables, describe_table, run_sql and send_feedback (the last stores a report, as POST /v1/feedback does), the same as the local transitlab mcp, which adds example_queries. Send the same key as for /v1/sql. Queries count against the same limits.
To connect a client, see CLI and MCP.
Request
Section titled “Request”curl https://api.transitlab.nyc/mcp \ -H "Authorization: Bearer $TRANSITLAB_API_KEY" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'import osimport requests
r = requests.post( "https://api.transitlab.nyc/mcp", headers={"Authorization": f"Bearer {os.environ['TRANSITLAB_API_KEY']}"}, json={ "jsonrpc": "2.0", "id": 1, "method": "tools/list", }, timeout=60,)r.raise_for_status()print(r.json())const res = await fetch("https://api.transitlab.nyc/mcp", { method: "POST", headers: { Authorization: `Bearer ${process.env.TRANSITLAB_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }),})if (!res.ok) throw new Error(`HTTP ${res.status}`)console.log(await res.json())Authorization
Section titled “Authorization”Needs an API key, sent as Authorization: Bearer <key>. Get a free key.
Request body
Section titled “Request body”application/json, required.
A JSON-RPC 2.0 message (or a batch).
Responses
Section titled “Responses”200 OK
Section titled “200 OK”The JSON-RPC answer.
A JSON-RPC 2.0 response.
{}202 Accepted
Section titled “202 Accepted”A notification was accepted.
Errors
Section titled “Errors”| Status | When |
|---|---|
401 | Unauthorized. No key, or a bad one. |
Error responses carry this body:
-
errorstring requiredA short code: unauthorized, rate_limited, daily_queries, daily_compute, concurrency, busy, budget_exhausted, engine_unavailable, bad_sql, not_read_only, sql_error, not_allowed, timeout, out_of_memory, bad_format, bad_limit, bad_date, no_such_table, not_found.
-
messagestring requiredWhat went wrong and what to do, in plain words.
-
get_a_keystring (uri)On 401: where to get a key.
-
docsstring (uri)On 401: the API guide.
{ "error": "unauthorized", "message": "Send an API key: `Authorization: Bearer tl_live_…`. Get a free key at https://transitlab.nyc/api-keys.", "get_a_key": "https://transitlab.nyc/api-keys", "docs": "https://docs.transitlab.nyc/start/sql-api/"}