Skip to content
Docs

MCP server (streamable HTTP)

A Model Context Protocol server over streamable HTTP (JSON responses, no event stream).

POST https://api.transitlab.nyc/mcp API key

Tools: 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.

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 os
import 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())

Needs an API key, sent as Authorization: Bearer <key>. Get a free key.

application/json, required.

A JSON-RPC 2.0 message (or a batch).

The JSON-RPC answer.

A JSON-RPC 2.0 response.

Example
{}

A notification was accepted.

StatusWhen
401Unauthorized. No key, or a bad one.

Error responses carry this body:

  • error string required

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

  • message string required

    What went wrong and what to do, in plain words.

  • get_a_key string (uri)

    On 401: where to get a key.

  • docs string (uri)

    On 401: the API guide.

Example (401)
{
"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/"
}