Token导航 LogoToken导航TokenDH.com
Swiggy Zomato MCP logo
AI代理stdio官方级别未说明来源级核验

Swiggy Zomato MCP

MCP Server

一个基于AI的食品价格比较工具,可同时查询Swiggy和Zomato平台的价格和优惠券信息。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
AI代理Python工作流自动化

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

hemachandran2406

提供方

hemachandran2406

最后核验

2026/5/17 20:22

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

🍔 食品聚集剂

比较不同地区的食品价格 Swiggy佐马托 使用人工智能——由谷歌双子座、LangGraph和模型上下文协议(MCP)提供支持。

React FastAPI LangGraph Gemini MLflow

______________________________________________________________________

✨ 特性

  • 🔍 跨平台搜索 --同时查询Swiggy和Zomato
  • 🎟️ 优惠券比较 --获取并应用两个平台上的可用折扣
  • 💬 React聊天界面 --带有多回合记忆的深色主题对话界面
  • 📊 流量追踪 --代理推理、工具调用和LLM响应的完全可观察性
  • 令牌优化 -为减少API成本而调整的工具说明
  • 🐳 可部署的 --包含多级Dockerfile+渲染蓝图

______________________________________________________________________

🏗️ 建筑

┌──────────────────────────────────────────────────┐
│                 Render (Docker)                  │
│                                                  │
│  ┌────────────────────────────────────────────┐  │
│  │  FastAPI (port 8000)                       │  │
│  │  ├── GET  /           → React static app   │  │
│  │  ├── POST /api/connect → connect MCP       │  │
│  │  ├── POST /api/chat   → agent endpoint     │  │
│  │  └── GET  /api/status → health check       │  │
│  └──────────┬─────────────────────────────────┘  │
│             │                                    │
│  ┌──────────▼─────────────────────────────────┐  │
│  │  LangGraph ReAct Agent (Gemini)            │  │
│  │  ├── Swiggy MCP (via npx mcp-remote)       │  │
│  │  └── Zomato MCP (via npx mcp-remote)       │  │
│  └────────────────────────────────────────────┘  │
│                                                  │
│  ┌────────────────────────────────────────────┐  │
│  │  MLflow Tracking (localhost:5000)           │  │
│  └────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────┘

______________________________________________________________________

📁 项目结构

.
├── frontend/                # React chat frontend (Vite)
│   ├── src/
│   │   ├── App.jsx          # Chat UI component
│   │   ├── index.css        # Dark gradient theme
│   │   └── main.jsx         # React entry point
│   ├── index.html           # HTML template
│   ├── vite.config.js       # Vite config with API proxy
│   ├── package.json         # Frontend dependencies
│   └── dist/                # Built static files (after npm run build)
│
├── main.py                  # FastAPI backend (API + serves React)
├── agent.py                 # LangGraph ReAct agent with Gemini
├── mcp_client.py            # MCP server connection manager
├── streamlit_app.py         # Streamlit frontend (alternative)
│
├── requirements.txt         # Python dependencies
├── .env.example             # Environment variable template
├── .gitignore               # Git ignore rules
│
├── Dockerfile               # Multi-stage: Node builds React → Python serves all
├── render.yaml              # Render Blueprint for one-click deploy
└── README.md                # This file

______________________________________________________________________

🚀 快速入门(逐步)

先决条件

要求版本检查命令
Python3.11+python --version
Node.js18+node --version
npm9+npm --version
Gemini API密钥-在这里买一个

______________________________________________________________________

步骤1:克隆存储库

git clone 
cd "Swiggy MCP POC"

______________________________________________________________________

步骤2:设置Python后端

# Create virtual environment
python -m venv venv

# Activate it
source venv/bin/activate        # macOS / Linux
# venv\Scripts\activate          # Windows

# Install Python dependencies
pip install -r requirements.txt

验证: 您应该看到安装的软件包没有错误。运行此程序以确认:

python -c "from agent import create_food_aggregator_agent; print('✅ Backend imports OK')"

______________________________________________________________________

步骤3:设置React前端

# Navigate to frontend
cd frontend

# Install Node dependencies
npm install

# Build the React app
npm run build

# Go back to project root
cd ..

验证: 检查生成输出是否存在:

ls frontend/dist/
# Should show: index.html  assets/

______________________________________________________________________

步骤4:配置环境变量

# Copy the template
cp .env.example .env

现在编辑 .env 使用编辑器并添加Gemini API密钥:

# ─── REQUIRED ───
GEMINI_API_KEY="your_gemini_api_key_here"

# ─── OPTIONAL (defaults shown) ───
GEMINI_MODEL="gemini-3-flash-preview"
SWIGGY_MCP_URL="https://mcp.swiggy.com/food"
ZOMATO_MCP_URL="https://mcp-server.zomato.com/mcp"
MLFLOW_TRACKING_URI="http://127.0.0.1:5000"
MAX_TOOL_DESC_LENGTH="200"

______________________________________________________________________

步骤5:运行应用程序

你有 3种方式 运行应用程序。选择一个:

选项A:React+FastAPI(推荐)

这是生产设置。FastAPI在单个端口上同时为API和React UI提供服务。

端子1 --启动服务器:

source venv/bin/activate
RUN_SERVER=1 uvicorn main:app --host 0.0.0.0 --port 8000

打开: http://localhost:8000

用途:

  1. 点击 “连接到MCP服务器” 在侧边栏中
  2. 将为Swiggy OAuth打开一个浏览器窗口——授权它
  3. 另一个浏览器窗口将为Zomato OAuth打开——授权它
  4. 连接后,键入您的食物查询并聊天!

______________________________________________________________________

选项B:React开发模式(用于前端开发)

使用热重载运行React开发服务器,代理到FastAPI后端。

端子1 --启动FastAPI后端:

source venv/bin/activate
RUN_SERVER=1 uvicorn main:app --host 0.0.0.0 --port 8000

2号航站楼 --启动React开发服务器:

cd frontend
npm run dev

打开: http://localhost:5173(Vite-dev服务器,热重载)

______________________________________________________________________

选项C:CLI模式(不需要UI)

用于直接在终端进行快速测试。

source venv/bin/activate

# Interactive chat mode
python main.py

# Or single query mode
python main.py -q "I want to order Narmada Chicken Biriyani"

______________________________________________________________________

选项D:流光显示(替代UI)

source venv/bin/activate
streamlit run streamlit_app.py --server.port 8501

打开: http://localhost:8501

______________________________________________________________________

步骤6:(可选)启动用于跟踪的MLW

打开A 独立终端:

source venv/bin/activate
mlflow ui --port 5000

打开: http://localhost:5000

所有代理痕迹都将显示在 食品_聚合剂_试剂 实验。您可以看到:

  • 每个LLM调用及其令牌
  • 每次MCP工具调用及其参数/结果
  • 完整的ReAct推理链

______________________________________________________________________

🔌 API 参考

FastAPI后端公开了这些端点:

POST /api/connect

连接到Swiggy和Zomato MCP服务器。聊天前先打一次电话。

curl -X POST http://localhost:8000/api/connect

答复:

{
  "connected": true,
  "servers": [
    {"name": "Swiggy", "status": "ok", "tools": 13},
    {"name": "Zomato", "status": "ok", "tools": 11}
  ],
  "total_tools": 24
}

POST /api/chat

向代理发送消息。

curl -X POST http://localhost:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"query": "I want to order Narmada Chicken Biriyani", "session_id": "my-session-1"}'

答复:

{
  "response": "I found several options for Narmada Chicken Biriyani..."
}
注: 使用相同 session_id 跨请求维护对话历史记录(多回合)。

GET /api/status

检查MCP服务器是否已连接。

curl http://localhost:8000/api/status

______________________________________________________________________

🚢 部署

选项1:渲染(免费--推荐)

Render提供了一个免费的基于Docker的web服务层。

  1. 将代码推送到GitHub
  2. 首选 render.comWeb服务
  3. 连接您的GitHub仓库
  4. 选择 码头工人 作为环境
  5. 添加环境变量: GEMINI_API_KEY =您的钥匙
  6. 点击 部署

包括 render.yaml 文件还支持 蓝图部署 --只需在Render上单击“新建蓝图实例”并指向您的仓库。

选项2:Docker(任何地方)

# Build the image (this builds React + installs Python)
docker build -t food-aggregator .

# Run it
docker run -p 8000:8000 \
  -e GEMINI_API_KEY="your_key_here" \
  -e GEMINI_MODEL="gemini-3-flash-preview" \
  food-aggregator

打开: http://localhost:8000

选项3:谷歌云运行

gcloud builds submit --tag gcr.io/YOUR_PROJECT/food-aggregator

gcloud run deploy food-aggregator \
  --image gcr.io/YOUR_PROJECT/food-aggregator \
  --platform managed \
  --allow-unauthenticated \
  --set-env-vars "GEMINI_API_KEY=your_key"

______________________________________________________________________

⚙️ 环境变量

变量必填默认描述
GEMINI_API_KEYGoogle Gemini API密钥
GEMINI_MODELgemini-3-flash-preview使用Gemini模型
SWIGGY_MCP_URLhttps://mcp.swiggy.com/foodSwiggy MCP服务器端点
ZOMATO_MCP_URLhttps://mcp-server.zomato.com/mcpZomato MCP服务器端点
MLFLOW_TRACKING_URIhttp://127.0.0.1:5000工作流跟踪服务器URL
MAX_TOOL_DESC_LENGTH200MCP工具描述的最大字符数(令牌优化)
RUN_SERVER--设置为 1 启动FastAPI服务器(否则启动CLI)

______________________________________________________________________

📋 运作原理

  1. 连接 --点击按钮→ FastAPI生成 npx mcp-remote 通过OAuth连接到Swiggy/Zomato远程HTTP MCP服务器的进程
  2. 加载工具 --加载MCP工具(搜索、菜单、购物车、优惠券、订单、跟踪);截断描述以保存令牌
  3. 聊天 --您的消息进入由Gemini驱动的LangGraph ReAct循环 MemorySaver 用于多回合对话
  4. 搜索 --代理调用两个平台上的MCP工具,比较结果,应用可用优惠券
  5. 推荐 --代理会格式化一个比较价格的响应,并推荐最便宜的选项

______________________________________________________________________

🛠️ 技术栈

技术
LLM谷歌双子座(langchain-google-genai)
代理LangGraph重新激活+ MemorySaver 校验指针
主控程序langchain-mcp-adapters + npx mcp-remote
后端FastAPI+Uvicorn
前端React+Vite
追踪MLW
部署Docker/渲染/云运行

______________________________________________________________________

🐛 故障排除

问题解决方案
ModuleNotFoundError确保venv已激活: source venv/bin/activate
npx: command not found安装Node.js 18+: brew install node (macOS)
OAuth窗口未打开检查浏览器的弹出窗口阻止程序
GEMINI_API_KEY not set将您的密钥添加到 .env --参见步骤4
frontend/dist not found快跑 cd frontend && npm run build --参见步骤3
MLflow连接错误先启动MLflow: mlflow ui --port 5000
令牌限制错误减少 MAX_TOOL_DESC_LENGTH.env (默认值:200)

______________________________________________________________________

📄 许可证

麻省理工学院

目录标签

目录标签

AI代理Python工作流自动化本地部署食品价格比较多平台查询优惠券比较React聊天界面

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

oauth

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiooauth部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP