Skip to content

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.

Terminal window
npm install @modelcontextprotocol/sdk
import { 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();
  • list_brands first. It returns each brand’s slug; pass it as the brand argument on every other tool. In multi-brand API-key mode brand is 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.