Carrefour Drive MCP
Carrefour Drive MCP — 为你的 AI 代理提供生鲜杂货购物能力
适用于 Carrefour Drive(carrefour.fr)的 MCP 服务器。 让 Claude、Cursor 或任何 Model Context Protocol 客户端在你的 Carrefour 账户上搜索法国生鲜杂货目录、构建购物车、 选择 Drive 自提或配送时段、查看积分和过往收据。
48 个工具。 其中 43 个是真实的 carrefour.fr API 端点,以 JSON 描述并由通用执行器运行,
另有 5 个会话管理工具。新增一个端点只需放入一个 JSON 文件——无需编写代码。
"What did I buy last month?" → get_loyalty_order_receipts
"Refill my usual weekly groceries." → get_frequent_purchases + add_item_to_cart
"Cheapest organic pasta under 2 €?" → search_products
"Book the Saturday morning Drive slot." → get_delivery_timeslots + select_cart_delivery_slot独立运行 — 无需
spectral二进制文件、无需外部网关、无需 API 密钥。克隆、构建、运行。可穿透 Cloudflare — 每次调用都从真实的 Chromium 页面发出,因为除此之外 没有任何方式能拿到
200。保持登录状态 — 你只需在浏览器窗口中登录一次;服务器会通过 OAuth2 SSO 循环 自动续期会话。
目录
Related MCP server: mcp-leclerc-drive
安装
无需克隆任何内容。Node.js 20+ 是唯一的前置条件(原生 fetch、
FormData、node:test)。
npx -y github:maximeallanic/CarrefourDriveMCP这一条命令即可获取、构建并在 stdio 上启动服务器——首次 运行还会下载它用作 HTTP 传输层的 Chromium。大多数情况下你无需 亲自输入这条命令:你把它放进 MCP 客户端配置中 (下一节),客户端会替你运行它。
更希望全局安装一次?
npm install -g github:maximeallanic/CarrefourDriveMCP
carrefour-drive-mcp你的会话、浏览器配置文件和日志存放在 ~/.carrefour-drive-mcp
(设置了 $XDG_DATA_HOME 时为 $XDG_DATA_HOME/carrefour-drive-mcp),
因此升级永远不会让你掉线。可通过 CARREFOUR_DATA_DIR 覆盖。
git clone https://github.com/maximeallanic/CarrefourDriveMCP.git
cd CarrefourDriveMCP
npm install # builds, and downloads the Chromium transport
node dist/index.js源码检出会将数据保存在仓库自身的 data/ 目录中。
连接到你的代理
Claude Code
claude mcp add carrefour-drive -- npx -y github:maximeallanic/CarrefourDriveMCP然后在任何会话中:
> Log me in to Carrefour (runs carrefour_browser_login)
> Add 2 L of semi-skimmed milk to my Drive cartClaude Desktop
编辑 claude_desktop_config.json:
macOS —
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows —
%APPDATA%\Claude\claude_desktop_config.jsonLinux —
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"carrefour-drive": {
"command": "npx",
"args": ["-y", "github:maximeallanic/CarrefourDriveMCP"]
}
}
}重启 Claude Desktop;Carrefour 工具会出现在工具菜单中。
在 Windows 上,使用
"command": "cmd"并搭配"args": ["/c", "npx", "-y", "github:maximeallanic/CarrefourDriveMCP"]。
Cursor、Windsurf、Zed、VS Code 及其他 MCP 客户端
任何通过 stdio 使用 MCP 的客户端都接受同样的两个字段:
{
"command": "npx",
"args": ["-y", "github:maximeallanic/CarrefourDriveMCP"]
}Cursor —
~/.cursor/mcp.json(或项目中的.cursor/mcp.json)Windsurf —
~/.codeium/windsurf/mcp_config.jsonVS Code / Copilot —
.vscode/mcp.json,位于"servers"下Zed —
settings.json,位于"context_servers"下
已全局安装或已克隆?换成
{"command": "carrefour-drive-mcp"} 或
{"command": "node", "args": ["/absolute/path/to/dist/index.js"]}。
已有 Cookie?在 "env" 块中传入即可,无需登录:
{"CARREFOUR_COOKIES": "…cookie header…"}。
登录
carrefour.fr 通过 Cookie 登录,背后还有 Cloudflare Turnstile 验证码和 OTP。因此登录是交互式的,只需一次:
让代理运行
carrefour_browser_login。浏览器窗口会在 Carrefour 登录页面上打开。请自行输入邮箱、密码 和 OTP 验证码。
不要关闭窗口 — 服务器会检测 OAuth 循环的结束, 从内存中抓取会话 Cookie 并替你关闭窗口。
此后会话会自动静默续期:服务器会在经过身份验证的调用之前重放 SSO
authorize → callback 重定向,在 401/403 之后也会如此,
并且每 30 分钟执行一次保活。只有当 SSO Cookie 本身过期时
(最长 24 小时,或空闲 60 分钟)你才需要重新登录——工具会明确提示。
随时用 carrefour_session_status 检查状态(verify: true 会发起
真实调用)。
会话工具 | 功能 |
| 打开窗口登录(验证码 + OTP) |
| 已存储的 Cookie、浏览器配置文件、SSO 剩余时间 |
| 强制续期(很少需要——它是自动的) |
| 手动导入 Cookie(header、JSON 映射或 JSON 数组格式) |
| 清除本地会话 |
对于
carrefour_set_cookies,只有 JSON 数组 格式携带 Cookie 域名——它是唯一能提供c4iamsecuretk的格式,没有它就无法 自动续期。
Cookie 存储位于 <data dir>/sessions/cookies.json(权限 0600),
每次启动时都会重新注入浏览器配置文件。
工具参考
搜索与目录 (无需账户)
工具 | 端点 | 必填参数 |
| GET /s |
|
| GET /autocomplete |
|
| POST /products |
|
| GET /products/query/{query_id} |
|
| GET /product/{ean}/reviews |
|
| GET /navigation | — |
| POST /api/marketing/{placement} |
|
| GET /donation | — |
| POST ocb.carrefour.fr/preprompts |
|
| GET /api/eligibility/drive |
|
购物车与结算
工具 | 端点 | 必填参数 |
| GET /api/cart | — |
| PATCH /api/cart |
|
| PATCH /api/cart/items |
|
| POST /api/cart/promo_code |
|
| GET /api/cart/simulate |
|
| GET /api/timeslots |
|
| PUT /api/cart/slot |
|
| POST /api/checkout/{basket_service_type}/validate/slot |
|
| POST /api/checkout/{basket_service_type}/validate/summary |
|
| GET /api/checkout/recommendations/{facility_id}/{basket_service} |
|
| POST /api/checkout/payment |
|
⚠️
submit_checkout_payment会发起真实扣款。它的四个参数 被捕获为查询字符串,而描述却暗示它们是 HTTP 头——在生产环境中使用前 请对照真实调用记录进行核实。
账户、订单与积分
工具 | 端点 | 必需参数 |
| GET /api/user/orders | — |
| GET /api/user/orders/last | — |
| GET /mon-compte/achats-frequents | — |
| GET /api/user/secured/loyalty/balance | — |
| GET /api/user/secured/loyalty/my-cards | — |
| GET /api/user/loyalty/coupons-dashboard | — |
| GET /api/user/loyalty/coupon-collection | — |
| GET /api/user/secured/loyalty/orders/receipts |
|
| GET /api/user/secured/loyalty/orders/receipt/{gln}/{date_key}/{receipt_number} |
|
| GET /api/advantage-code | — |
| GET /api/user/products/vignettes-products | — |
| GET /api/user/loyalty/olympic-games/prime | — |
| GET /api/user/my-account/kpis |
|
| GET /api/user/my-account/consents | — |
| GET /api/favoritestore | — |
| POST /api/information-insert/stores/{store_id} |
|
| GET /api/homepage/returningBanner | — |
| GET /api/user/recommendation/cdp | — |
| GET /api/recommendations |
|
购物清单
工具 | 端点 | 必需参数 |
| GET /api/shopping-lists | — |
| GET /api/shopping-lists-id/{list_id} |
|
| POST /api/shopping-lists/memo-list |
|
为什么需要真实浏览器
carrefour.fr 位于 Cloudflare managed challenge(托管质询)之后,会对客户端进行指纹识别。从同一 IP 在同一天测得的结果如下:
客户端 |
|
|
|
| 前几次调用返回 |
Chrome |
|
无论怎样调整请求头都无法改变这一点:唯一可行的传输方式是浏览器。而且请求必须从页面内发出——Playwright 的 APIRequestContext 使用的是 Node HTTP 栈,会像 fetch 一样被拦截。
因此,服务器保持一个常驻的 Chromium,并让每个 API 调用都以 fetch 的形式在停留于目标源(origin)的页面内执行(每个源一个页面,这是出于 CORS 的限制)。它以**无窗口(windowless)**模式运行,但不是标准的无头模式:
启动模式 | 结果 |
|
|
|
|
|
|
最后一行就是实际发布所用的方式。
身份验证的工作原理
两套不同的 Cookie 系统:
域 | 作用 | 有效期 |
| ForgeRock SSO,Cookie | 最长 24 小时,空闲 60 分钟后失效 |
| 门店会话( | 短期有效,可续期 |
登录是交互式的,原因有两个限制:登录表单位于 Cloudflare Turnstile 验证码之后,而该验证码拒绝在 CDP 驱动的浏览器中通过验证;此外,c4iamsecuretk 是会话 Cookie,Chromium 永远不会将其写入磁盘。因此,窗口是一个普通的 Chromium,调试端口已打开,但在登录完成前不附加任何调试连接;服务器通过普通 HTTP 在 /json/list 上轮询标签页(未启用任何 CDP 域,因此不会留下自动化痕迹),当 OAuth 循环跳回门店页面的那一刻才附加连接,并从内存中读取 Cookie。
此后的续期只是一次普通的导航——Chromium 会跟随重定向并自行设置 Cookie:
GET moncompte.carrefour.fr/iam/oauth2/CarrefourConnect/authorize?client_id=…&redirect_uri=https://www.carrefour.fr/login/check
└─302─► www.carrefour.fr/login/check?code=… (the BFF exchanges the code)
└─302─► www.carrefour.fr/ (fresh session cookies)执行器的工作原理
tools/*.json ──► loader (validation) ──► params (JSON Schema ➜ zod) ──► MCP tools/list
└─► resolve ($param ➜ URL/query/headers/body)
└─► http.service (cookies + rate limit + fetch)tools/ 中的每个文件都是自描述的:
{
"name": "add_item_to_cart",
"parameters": { "type": "object", "properties": { … }, "required": [ … ] },
"request": {
"method": "PATCH",
"url": "https://www.carrefour.fr/api/cart",
"headers": { … },
"query": {},
"body": { "items": [ { "ean": { "$param": "ean" }, … } ] },
"content_type": "application/json"
},
"requires_auth": true
}引擎(src/spec/):
递归替换
headers、query和body中的{"$param": "name"}节点,并保留原始类型(数字、布尔值、数组);丢弃没有实参的占位符,这样可选参数会从请求中消失,而不会被发送为
null;填充 URL 段
{basket_service_type}、{store_id}、……,并进行编码;当必需的段缺失时,会报出清晰的错误信息;将数组序列化为重复的查询键(
codes[]=14&codes[]=15);根据
content_type对请求体进行编码:JSON、x-www-form-urlencoded或multipart/form-data(boundary 交给fetch处理);应用带抖动的滑动速率限制,并附带浏览器请求头。
添加一个端点只需向 tools/ 中放入一个新的 JSON 文件,无需编写任何代码。
配置
参见 .env.example。主要变量:
变量 | 默认值 | 作用 |
| — | 会话 Cookie(header、JSON 映射或 JSON 数组) |
| — | JSON Cookie 导出文件的路径 |
|
| 下方所有内容的写入根目录 |
|
| 持久化的 Cookie 存储(cookie jar) |
|
| 持久化的 Chromium 配置文件 |
|
| SSO 保活周期; |
|
| 用于刷新的 OAuth2 客户端 |
|
| BFF 回调地址 |
|
| 请求的作用域 |
|
| JSON 工具定义目录 |
|
| 对大响应的截断 |
|
| HTTP 超时时间 |
|
| 速率限制窗口 |
|
| 请求之间的抖动延迟 |
|
| winston 日志(文件 + stderr,绝不输出到 stdout) |
验证安装
从源码检出开始:
npm run build # tsc
npm test # build + unit tests (node:test)
npm run smoke # build + real MCP stdio handshake + tools/list
npm run verify # all three测试覆盖 $param 替换、URL 段、查询字符串中的数组、三种请求体编码以及 cookie-jar 处理。冒烟测试会实际启动服务器,完成 JSON-RPC 握手并列出所有工具。
对 carrefour.fr 的网络调用不会自动测试——它们需要真实账号和有效的 Cookie。
常见问题
需要 API 密钥吗? 不需要。Carrefour 没有公开 API;本服务器驱动的是网站所使用的同一批私有端点,用的是你自己的会话。
在法国之外能用吗? 商品目录和门店都在法国(carrefour.fr)。对于某些 IP,Cloudflare 可能会采取更严格的策略。
密码会被存储吗? 不会。你在浏览器窗口中输入密码;只有 Cookie 会被持久化,存储在 ~/.carrefour-drive-mcp/sessions/cookies.json,权限为 0600。本仓库不保存任何凭据,data/ 和 .env 已在 gitignore 中。
它能下真实订单吗? 能——submit_checkout_payment 会发起真实扣款。请谨慎使用。
我可以添加端点吗? 在 tools/ 中放入一个 JSON 文件即可。参见执行器的工作原理。
支持哪些客户端? 任何通过 stdio 使用 MCP 的客户端都可以:Claude Code、Claude Desktop、Cursor、Windsurf、VS Code / Copilot、Zed、Continue,以及使用 MCP SDK 的自定义代理。
免责声明
非官方项目,与 Carrefour 无关联,未获得 Carrefour 的认可或支持。仅供在个人账号上用于个人和教育用途。请遵守 Carrefour 的服务条款,并相应地限制自己的请求频率。
许可证
MIT © Maxime Allanic
关键词:Carrefour MCP server · Carrefour Drive API · Model Context Protocol 杂货 · Claude Desktop MCP · Claude Code MCP server · Cursor MCP · 法国食品杂货购物AI代理 · courses en ligne · drive · liste de courses · fidélité Carrefour · MCP 购物车自动化。
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 Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that connects Carrefour Drive to Claude and other MCP clients, enabling product search with real prices, nutriscore, availability, and natural language cart management.MIT
- AlicenseAqualityBmaintenanceMCP server for E.Leclerc Drive that enables searching products, managing a cart, and preparing grocery orders natively through natural language.8697MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for grocery-related web automation using Playwright, enabling AI assistants to interact with grocery websites.
- FlicenseNot gradedqualityDmaintenanceMCP server for Carrefour Drive that enables AI assistants to search products, manage carts, check delivery slots, and order groceries via automated browser interactions.2
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Shopping MCP for AI agents: search, compare, Amazon buy links. Auto-register.
Agent-native product catalog for AI shopping agents. 296M+ products, 28 countries.
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/maximeallanic/CarrefourDriveMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server