Skip to main content
Glama
Ichibu013

Agentic Swiggy MCP Server

by Ichibu013

Agentic Swiggy MCP Server

Python LangChain LangGraph FastMCP ChromaDB

一个高度模块化、非确定性的代理式模型上下文协议(MCP)服务器,模拟食品配送助手(如 Swiggy)。该服务器基于 LangGraphFastMCPChromaDB 构建,利用智能 ReAct 代理动态路由任务、回答问题、提供推荐,并通过 人在回路(HITL) 工作流安全地执行食品订单。


核心特性

  • 非确定性 ReAct 代理:代理根据对话上下文动态决定使用哪些工具,无需硬编码工作流。

  • 人在回路(HITL):订单下达会被安全拦截。代理会暂停执行,在完成任何真实交易前请求人工授权。

  • 多格式 RAG 摄取:一个解耦的摄取管道,可统一解析 .json.csv.md.txt.pdf 文件到本地 ChromaDB 向量存储中。

  • 上下文感知推荐:根据用户当前地理位置和时段,动态评估并推荐前 3 个食品。

  • 模型上下文协议(MCP):将代理能力以标准化 MCP 工具形式暴露,使其可被现代 LLM 客户端(如 Claude Desktop)发现和使用。

  • 100% 本地嵌入:内置对 HuggingFace sentence-transformers 的支持,实现免费、离线的向量嵌入。


Related MCP server: Food402

项目结构

swiggy_agent/
├── data/
│   ├── restaurants_menu.json        # Restaurant catalog & timings
│   ├── order_history.json           # Past & active order records
│   ├── food_reviews.csv             # Customer reviews & sentiment
│   └── platform_policies.md         # Packaging & late-night guidelines
├── src/
│   ├── ingestion.py                 # Multi-format universal data ingestor
│   ├── tools/
│   │   ├── __init__.py
│   │   ├── order_tool.py            # Tool 1: Order Food (HITL sensitive)
│   │   ├── recommendation_tool.py   # Tool 2: Geo/Time Recommendations
│   │   ├── history_tool.py          # Tool 3: Order tracking & history
│   │   └── rag_tool.py              # Tool 4: Review retrieval RAG
│   ├── agent.py                     # Non-deterministic LangGraph agent + HITL
│   └── mcp_server.py                # FastMCP Server exposing tools
├── requirements.txt
├── .env                             # Environment variables (API Keys)
└── main.py                          # Entry point for interactive CLI testing

设置与安装

1. 安装依赖

请确保已安装 Python 3.10+。安装所需包:

pip install -r requirements.txt
# Alternatively, install manually:
pip install mcp langchain langchain-openai langchain-huggingface langchain-chroma langgraph chromadb sentence-transformers python-dotenv

2. 配置环境变量

在根目录创建 .env 文件,并添加您的 LLM API 密钥(例如 Google Gemini、OpenAI 或 Groq):

# Example using Google Gemini (Recommended for free tier)
GEMINI_API_KEY=your_api_key_here

# Example using OpenAI (If applicable)
# OPENAI_API_KEY=your_api_key_here

3. 初始化向量数据库

在运行代理之前,先摄取合成数据以构建本地 ChromaDB 向量存储:

python src/ingestion.py

使用方法

选项 1:运行交互式代理演示

通过终端测试 LangGraph 代理和人在回路订单工作流:

python main.py

尝试类似这样的提示:"你好,我是位于 Koramangala 的 USR_500,现在是 21:00。附近有什么好吃的?查看评论了解大家的评价,如果评分不错,就点 1 份送到 5th Block。"

选项 2:启动 MCP 服务器

要将工具暴露给兼容 MCP 的客户端(如 Claude Desktop 或外部应用):

python src/mcp_server.py

工具参考

工具名称

描述

输出

order_food

下单购买食品。触发图中断,要求用户进行 "yes" 授权。

JSON 确认

get_top_3_food

根据 locationcurrent_time 评估本地餐厅,以建议最佳选项。

JSON 数组

get_order_status_and_history

检索特定用户 ID 的活动及历史订单数据。

JSON 字典

query_food_reviews_and_policies

对评论、菜单和平台政策执行 RAG 语义搜索。

Markdown 文本


许可证

MIT 许可证

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.

  • MCP server for AI dialogue using various LLM models via AceDataCloud

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ichibu013/Swiggy-Agentic-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server