Build an agent

Working code to wire Swiggy MCP into the framework you already use.

Swiggy MCP speaks standard streamable HTTP. Every major agent framework in 2026 has first-class MCP support. Pick your framework, paste the connector, give your agent access to 35 Swiggy tools.

Set your access token in SWIGGY_TOKEN (obtain via Authenticate).

import { Agent, Runner, MCPServerStreamableHttp } from "@openai/agents";
 
const swiggyFood = new MCPServerStreamableHttp({
  url: "https://mcp.swiggy.com/food",
  requestInit: {
    headers: { Authorization: `Bearer ${process.env.SWIGGY_TOKEN}` },
  },
});
 
const agent = new Agent({
  name: "FoodOrderingAgent",
  instructions: "Help users order food on Swiggy. Always call get_addresses first.",
  mcpServers: [swiggyFood],
});
 
await swiggyFood.connect();
const result = await Runner.run(agent, "Order biryani to my home address.");
console.log(result.finalOutput);

Python:

from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
 
swiggy_food = MCPServerStreamableHttp(
    url="https://mcp.swiggy.com/food",
    headers={"Authorization": f"Bearer {os.environ['SWIGGY_TOKEN']}"},
)
 
agent = Agent(
    name="FoodOrderingAgent",
    instructions="Help users order food on Swiggy. Always call get_addresses first.",
    mcp_servers=[swiggy_food],
)
 
await swiggy_food.connect()
result = await Runner.run(agent, "Order biryani to my home address.")
print(result.final_output)

Handling expired tokens

Access tokens live 5 days. When a call returns 401 (or JSON-RPC -32001), re-run the OAuth flow and retry. Most frameworks expose a hook for this; for raw clients:

async function callWithReauth<T>(fn: () => Promise<T>): Promise<T> {
  try {
    return await fn();
  } catch (e: any) {
    if (e?.status === 401) {
      await reAuthenticate();
      return fn();
    }
    throw e;
  }
}

See Authenticate for the full OAuth walkthrough.

Wire more than one Swiggy server

Each server is independent - connect multiple if your agent needs to span domains:

mcpServers: [
  { url: "https://mcp.swiggy.com/food" },
  { url: "https://mcp.swiggy.com/im" },
  { url: "https://mcp.swiggy.com/dineout" },
]

Tool names are unique across servers, so your agent can dispatch across all 35 tools without conflict.

Where to go next

  • Recipes - end-to-end journeys for food, grocery, dineout, and combined flows.
  • Agent patterns - voice vs chat response shaping, multi-turn state.
  • Reference - every tool, every parameter.
  • Ship to production - retries, observability, go-live checklist.