Code samples
The Forktime MCP server speaks the standard Model Context Protocol over Streamable HTTP, so the official MCP SDKs work out of the box. Point the client at https://api.forktime.ai/mcp, attach your Bearer API key, and you’re calling tools.
Every example does the same thing: connect, list the tools, call list_brands, then read a brand’s menu.
npm install @modelcontextprotocol/sdkimport { Client } from '@modelcontextprotocol/sdk/client/index.js';import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
const transport = new StreamableHTTPClientTransport( new URL('https://api.forktime.ai/mcp'), { requestInit: { headers: { Authorization: `Bearer ${process.env.FORKTIME_API_KEY}` }, }, },);
const client = new Client({ name: 'my-app', version: '1.0.0' });await client.connect(transport);
// Discover the tools the key is allowed to use.const { tools } = await client.listTools();console.log(tools.map((t) => t.name));
// Always resolve the brand first — pass its slug on every other call.const brands = await client.callTool({ name: 'list_brands', arguments: {} });
// Read a brand's menu.const menu = await client.callTool({ name: 'list_menu', arguments: { brand: 'medusa' },});console.log(menu.structuredContent ?? menu.content);
await client.close();pip install mcpimport asyncio, osfrom mcp import ClientSessionfrom mcp.client.streamable_http import streamablehttp_client
API_KEY = os.environ["FORKTIME_API_KEY"]
async def main(): async with streamablehttp_client( "https://api.forktime.ai/mcp", headers={"Authorization": f"Bearer {API_KEY}"}, ) as (read, write, _): async with ClientSession(read, write) as session: await session.initialize()
tools = await session.list_tools() print([t.name for t in tools.tools])
brands = await session.call_tool("list_brands", {}) menu = await session.call_tool("list_menu", {"brand": "medusa"}) print(menu.structuredContent)
asyncio.run(main())MCP is JSON-RPC 2.0 over HTTP. A real client runs an initialize handshake and manages a session for you — with raw curl you do it by hand, so this is mainly for a quick debug poke. Send the session id returned by initialize on subsequent calls.
# 1. initialize — grab the mcp-session-id from the response headerscurl -isN https://api.forktime.ai/mcp \ -H "Authorization: Bearer $FORKTIME_API_KEY" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{ "protocolVersion":"2025-06-18", "capabilities":{}, "clientInfo":{"name":"curl","version":"1.0"}}}'
# 2. call a tool (reuse the session id from step 1)curl -sN https://api.forktime.ai/mcp \ -H "Authorization: Bearer $FORKTIME_API_KEY" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Mcp-Session-Id: <session-id-from-step-1>" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{ "name":"list_brands","arguments":{}}}'list_brandsfirst. It returns each brand’sslug; pass it as thebrandargument on every other tool. In multi-brand API-key modebrandis required.- Reads are safe; writes are live. A write tool changes real restaurant data — see each tool’s scope before you call it.
- Errors are structured. A missing scope or an ambiguous name comes back as a normal tool result you can branch on (e.g.
needsDisambiguation), not an exception to catch.
From here, the tool reference lists every tool, its parameters, and the scope it needs.