cafe-shop-mcp-agent
Cafe Shop MCP Agent - 详尽文档
系统概述
Cafe Shop MCP Agent("Bean & Brew")是 Model Context Protocol (MCP) 生态系统的先进实现。它由两个独立服务组成,通过 MCP streamable-http 传输协议安全通信。
该系统使用基于 LangChain 的 ReAct 代理,运行在 AWS Bedrock 上,用于处理自然语言的咖啡店请求,查询实时库存,并通过 MCP 服务器对 PostgreSQL 数据库执行订单。
Related MCP server: @striderlabs/mcp-starbucks
1. 架构深入解析
1.1 客户端接口(client/)
客户端充当面向用户的 API 和 LangChain 代理执行环境。
框架:FastAPI
代理编排器:LangGraph + LangChain(
create_agent)LLM 引擎:AWS Bedrock(
ChatBedrock)持久化:LangGraph AsyncPostgresSaver(检查点器),用于线程级记忆。
中间件集成:
SummarizationMiddleware:压缩超过 2000 个 token 或 10 条消息的历史记录。PIIMiddleware:在发送到 Bedrock 之前对电子邮件进行脱敏、对信用卡进行掩码处理、对电话号码进行脱敏。HumanInTheLoopMiddleware:拦截add_order工具调用,在执行前需要明确的人工审批。
1.2 MCP 服务器(mcp_server/)
服务器安全地暴露领域逻辑和数据边界。
框架:FastMCP(
mcp.server.fastmcp)数据库:PostgreSQL(通过 SQLAlchemy ORM 管理)。
传输:HTTP SSE(
streamable-http)。
2. API 契约与数据流
2.1 聊天端点(客户端)
POST /api/v1/chat
请求负载(ChatRequest):
{
"message": "I'd like to order 2 Cappuccinos please.",
"mode": "normal",
"stream": false,
"thread_id": "user-session-id"
}注意:mode 可以为 normal、structured 或留空。stream 决定响应是 SSE 还是同步 JSON。
响应负载(ChatResponse - 普通模式):
{
"message": "I have set up your order for 2 Cappuccinos. Before I finalize it, do you approve?",
"structured_output": null,
"stream_chunks": null,
"pending_approval": {
"tool": "add_order",
"args": {"customer_name": "Guest", "items": [{"item_name": "Cappuccino", "quantity": 2}]},
"description": "Tool add_order requires approval."
}
}(如果存在 pending_approval,则下一个请求的 message 必须恰好为 "approve" 或 "reject",并使用相同的 thread_id)。
2.2 数据库模式(MCP 服务器)
PostgreSQL 数据库由 4 个主要表组成:
menu_items:menu_item_id(主键)、name(唯一)、price(Numeric)、stock_quantity(int)、is_active(bool)。orders:order_id(UUID 主键)、order_sequence_id(BigInt 序列)、customer_name(str)、status(str)。order_items:连接orders和menu_items的联结表,包含quantity列。error_logs:log_id、error_code、message、source。
3. Model Context Protocol (MCP) 绑定
FastMCP 服务器显式注册以下组件。客户端在会话初始化期间(load_session_context)无条件加载这些组件。
3.1 工具(@mcp.tool())
工具名称 | 参数 | 返回 | 描述 |
| 无 |
| 获取活动菜单项( |
|
|
| 通过查找整数序列 ID 返回订单状态( |
|
|
| 下订单、生成序列 ID 并减少库存 |
3.2 提示词(@mcp.prompt())
brew_buddy_system:主要的 ReAct 代理指令,格式化角色、目标、约束和输出格式(使用 XML 标签<role>、<instructions>)。order_confirmation(customer_name, items):生成一份温馨、格式化的确认收据。
3.3 资源(@mcp.resource())
menu://items:实时菜单和价格的只读文本转储。store://info:包含营业时间、位置和联系政策的静态字符串。
4. 设置与执行步骤
4.1 前提条件
本地或通过 Docker 运行 PostgreSQL。
AWS Bedrock 访问权限(已配置 AWS 凭据)。
Python 3.11+ 和
uv包管理器。
4.2 启动 MCP 服务器
导航到 mcp_server/,使用 DB_HOST、DB_USER、DB_PASS 等更新您的 .env,然后运行:
uv sync
python main.py这将自动触发数据库迁移(create_tables.py)并填充默认咖啡菜单,在端口 8000 上启动 FastMCP。
4.3 启动客户端 API
导航到 client/,使用 AWS 和 MCP 服务器凭据(MCP_SERVER_URL=http://localhost:8000)更新您的 .env,然后运行:
uv sync
python main.py这将在端口 8080 上启动面向用户的 FastAPI 应用程序。
4.4 示例工作流
用户请求菜单:
POST /api/v1/chat-> 代理读取menu://items资源。用户下订单:
POST /api/v1/chat-> 代理调用add_order。HITL 中间件中断并返回pending_approval。用户批准:
POST /api/v1/chat(消息:"approve",相同的 thread_id)-> 客户端恢复 LangGraph 检查点状态 -> 工具在 MCP 服务器上执行 -> 数据库库存减少。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Let AI agents query data and act across all your business apps via MCP.
Hosted MCP for e-commerce: live product catalog, stock, and pricing for AI agents.
Connect e-commerce and marketing data to AI assistants via MCP.
Related MCP Servers
- FlicenseBqualityCmaintenanceAn MCP adapter that maps Coffee Company B2B HTTP APIs to MCP tools, allowing AI agents to query member information, benefits, coupons, and payment statuses. It enables seamless integration for AI assistants to manage coffee-related customer assets and loyalty details through natural language.101
- AlicenseAqualityDmaintenanceMCP server for Starbucks — let AI agents search the menu, customize drinks, find stores, place mobile pickup orders, and manage Starbucks Rewards.16141MIT
- AlicenseNot gradedqualityCmaintenanceEnables cataloging and managing personal inventory (items, attachments) through natural language, allowing users to add, search, update, and retrieve item details and attachments via MCP tools.1MIT
- FlicenseNot gradedqualityBmaintenanceEnables coffee shop order management via MCP, including menu lookup, order creation, and status tracking.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/rizhwan05/cafe-shop-mcp-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server