Ninja MCP
MCP server for AI agents to interact with the Ninja/AnaNinja mobile API, enabling mobile-compatible auth, address management, retail/grocery product search, draft order validation, and checkout/payment flows.
README
Unofficial Ninja MCP
MCP server for AI agents working with the Ninja/AnaNinja API.
This project exposes the Ninja/AnaNinja API as a small operational MCP:
- auth with reusable local
deviceId/authKey - saved addresses
- vertical/store discovery for retail, pharmacy, beauty, and restaurants
- retail/pharmacy/beauty product search, detail lookup, and product image URLs
- restaurant branch search, menu lookup, variant IDs, and topping metadata
- draft order validation for product verticals and restaurants
- guarded checkout creation
- payment-method inspection plus saved-card, wallet, and STC Pay helpers
Live checkout/payment tools use explicit execution flags and keep state in local 0600 files.
Install
npm install
npm run build
Run locally:
npm start
MCP client config example:
{
"mcpServers": {
"ninja": {
"command": "node",
"args": ["/absolute/path/to/ninja-mcp/dist/index.js"],
"env": {
"NINJA_MCP_STATE_FILE": "/Users/you/.ninja-mcp/state.json"
}
}
}
}
First Login
- Call
ninja_auth_start_loginwith the account phone number. This registers a device session and sends an OTP. - Call
ninja_auth_verify_otpwith the OTP. - Future calls reuse the saved auth key. This MCP does not use an OAuth refresh-token flow.
The default state path is:
~/.ninja-mcp/state.json
Override with:
NINJA_MCP_STATE_FILE=/secure/path/state.json
State files contain auth material.
Current Coverage
Implemented:
- auth/device session reuse
- saved address listing
- vertical discovery for
RETAIL,PHARMACY,BEAUTY, andRESTAURANT - product search and detail lookup for retail/pharmacy/beauty through the Fahras products endpoint
- product image URL extraction from product and restaurant menu media
- restaurant branch search and restaurant menu lookup through GraphQL
- draft order validation for retail, pharmacy OTC, beauty, and restaurant carts
- checkout creation for pending unpaid orders/payment requests
- payment-method inspection for a pending checkout
- account-level saved payment option inspection
- payment helpers for saved card and wallet
- STC Pay initiate + OTP helper flow
MCP request-shape support:
- saved-card payment request shape:
savedCard.cardIdwith optionalsavedCard.cvv - wallet payment request shape:
includeWallet: true - restaurant checkout request shape:
OrderRequest.restaurantwithbranchIdandmenuId, plus restaurant variant IDs inlineItems[].itemId
Not implemented by this MCP:
- Tabby/Tamara and other redirect/token-based methods
- Apple Pay, Samsung Pay, Google Pay, QPay, KNET, Benefit, Daftar
- prescription/consultation pharmacy handling beyond
request.pharmacypassthrough
Agent Workflow
Read ninja://agent-guide or call ninja_agent_guide first.
Typical product-vertical call sequence:
ninja_saved_addressesninja_search_productswithvertical: "RETAIL","PHARMACY", or"BEAUTY"ninja_create_draft_order- Review the exact cart, total, delivery location, and payment method.
ninja_create_checkoutwithconfirmCreateOrder: trueninja_pending_payment_methods- Choose from the available payment methods.
- Use a method-specific helper if this MCP implements that method.
Typical restaurant call sequence:
ninja_saved_addressesninja_search_restaurantsninja_restaurant_menuninja_create_draft_orderwithvertical: "RESTAURANT",restaurant.branchId,restaurant.menuId, and restaurant variant IDs inlineItems[].itemId- Review the draft, then continue through checkout/payment if the cart is correct.
Implemented method-specific helpers:
- saved card: call
ninja_pending_payment_methods, choose acardIndex, then callninja_pay_saved_card - wallet: call
ninja_pay_walletif wallet is available for the pending checkout - STC Pay: use
ninja_initiate_stc_pay, collect the fresh OTP, then callninja_submit_stc_otp
Card setup: card registration is outside this MCP. Add a saved card to the account, then refresh ninja_saved_payment_options or ninja_pending_payment_methods. Once the card appears as saved, use ninja_pay_saved_card.
API Notes
- The bearer token is a short-lived HS256 JWT signed locally with
authKey. - Saved addresses are backend GraphQL data, not only local client memory.
- Product search uses vertical discovery to find the store/search context, then the Fahras products endpoint.
- Product image URLs come from
medias; search/menu tools return them asimageUrls. - Retail/pharmacy/beauty product search returns both
idandproductId. UseproductId, exposed asorderItemId, forlineItems[].itemId. Theidfield is store-scoped and should not be used as the cart item id. - Restaurant carts use menu variant IDs. Use
variant.orderItemId/variantIdfromninja_restaurant_menuforlineItems[].itemId. - Restaurant toppings use
toppingIdandtoppingOptionIdfrom the menu response. createDraftOrder.paymentMethodsis a direct list, not a{ data: [...] }wrapper.- Always draft before checkout/payment.
createOrdercan recover the same pending payment request for the same cart.- Payment methods are returned per payment request; availability can vary by account, cart, location, and time.
ninja_pending_payment_methodslabels each method withapiCapabilityandmcpCapability.- Saved cards expose
requiresCvv; saved-card payment acceptscardIndexorcardId, plus optionalcvv. ninja_saved_payment_optionslists account-level saved cards and wallets; for an actual checkout, preferninja_pending_payment_methods.- STC Pay initiate expects
mobileNumberin9665XXXXXXXXform; the MCP normalizes common Saudi formats. - Payment calls can return
PENDING; pollpaymentStatusand then inspectshowOrder. - Totals are read from known payment-summary keys. If the upstream shape changes, the MCP reports candidate keys instead of guessing from an arbitrary amount.
State And Side Effects
- Tool outputs redact full auth/payment IDs.
- Auth state and pending payment context are written with mode
0600. - Live mutation tools use execution flags, such as
confirmCreateOrder,confirmSendOtp,confirmSubmitOtp, andconfirmSubmitPayment. - Failed payment attempts keep pending context so callers can try another available method.
- Successful payment clears pending checkout context.
Environment
NINJA_MCP_STATE_FILE=/secure/path/state.json
NINJA_FIREBASE_CHECK_TOKEN=optional_firebase_check_token
NINJA_CLIENT_VERSION=optional_api_client_version_override
NINJA_CLIENT_USER_AGENT=optional_api_user_agent_override
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。