Korral StoreLink MCP Server
Enables AI agents to interact with Korral's StoreLink system to check store inventory and sales data, and create replenishment orders to manage stock-outs.
README
Korral StoreLink MCP Server
A standalone Model Context Protocol server, written in
TypeScript with the official @modelcontextprotocol/sdk,
that exposes the StoreLink backend of the Korral grocery chain to an AI agent.
It ships two collapsed, semantic tools designed for a stock-out / replenishment workflow:
| Tool | Purpose |
|---|---|
get_store_inventory_and_sales(store_id, sku) |
One call returns on-hand inventory and trailing-24h POS sales, plus a pre-computed demand_gap and stockout_risk. |
create_replenishment_order(store_id, sku, quantity) |
Fires a mock POST to raise a replenishment (restock) order and returns the confirmation. |
The transport is Stdio — the server reads JSON-RPC from stdin and writes to stdout, which is how MCP hosts (Claude Desktop, IDEs, agent runtimes) launch local servers.
Quick start
npm install
npm test # vitest — unit tests for the tool logic
npm run build # esbuild — bundles a single production file to dist/index.js
npm start # runs dist/index.js over stdio
During development you can run the TypeScript source directly without building:
npm run dev # tsx src/index.ts
Wiring it into an MCP host
{
"mcpServers": {
"korral-storelink": {
"command": "node",
"args": ["E:/temp/duvo-mcp-assignment/dist/index.js"]
}
}
}
Mock data
The mock backend (src/mockData.ts) tracks one SKU — 8847291, Madeta butter 250g — across two
stores, deliberately seeded to show contrasting demand gaps:
| Store | On-hand | POS (last 24h) | Demand gap | Risk |
|---|---|---|---|---|
| 47 | 2 | 10 | 8 | high |
| 102 | 12 | 14 | 2 | moderate |
demand_gap = units_sold_last_24h - on_hand. Store 47 sold far more than it has on the shelf — a
clear restock candidate; Store 102 is keeping pace.
Architectural choices & tradeoffs
1. Collapsed, semantic tools over a 1:1 API mirror
In the real StoreLink API, inventory and POS sales live behind two separate endpoints. A naïve MCP server would expose them as two tools, forcing the agent to make two round-trips, hold both payloads in context, and do the subtraction itself.
Instead, get_store_inventory_and_sales collapses both endpoints into one payload and
pre-computes demand_gap and stockout_risk. The benefits for an agent:
- Fewer tokens / less context churn — one tool result instead of two, with only the fields that matter for the decision.
- Fewer round-trips — one tool call to assess a store/SKU instead of two-then-reason.
- Less room for error — the server, not the model, does the arithmetic and risk bucketing.
Tradeoff: the tool is opinionated and less general-purpose than raw endpoints. A different
consumer that wanted only inventory now over-fetches POS data, and the stockout_risk thresholds
(gap >= 5 → high, >= 1 → moderate) are baked into the server rather than chosen by the caller.
For an agent-first tool surface this is the right trade — we optimize for the agent's context window
and decision quality, not for maximal API flexibility.
2. Action tool returns a confirmation, not a raw HTTP echo
create_replenishment_order models a side-effecting POST. It returns a small, structured
confirmation (order_id, status: "submitted", echoed inputs) rather than a verbose HTTP response,
so the agent gets just enough to confirm success and report back.
3. Schema validation with Zod
Tool inputs are validated with Zod schemas registered through the SDK. Each field carries a
.describe() string that the SDK surfaces in the JSON Schema sent to the model — so the agent learns
what store_id, sku, and quantity mean. quantity is constrained to a positive integer both
in the schema and defensively in the handler.
4. Pure functions + thin server wiring (testability)
The tool logic (getStoreInventoryAndSales, createReplenishmentOrder) is implemented as pure,
exported functions; buildServer() only wires them to the MCP transport. This keeps the
Vitest suite fast and transport-free — it tests behavior directly, with no stdio mocking.
5. esbuild → single bundled file
npm run build (see build.mjs) bundles everything — including the SDK and Zod — into one
self-contained, minified dist/index.js with a #!/usr/bin/env node shebang. An MCP host can run it
with a single node dist/index.js command, no node_modules required at the deploy target. Node
built-ins are left external since the runtime provides them.
Tradeoff: bundling dependencies makes the output larger (~330 KB) and pins them at build time, but removes any runtime install step — the right call for a server meant to be dropped into a host config.
Project layout
.
├── build.mjs # esbuild bundle script -> dist/index.js
├── package.json
├── tsconfig.json
├── vitest.config.ts
├── src
│ ├── index.ts # MCP server: schemas, tools, stdio wiring
│ ├── index.test.ts # Vitest unit tests
│ └── mockData.ts # Mock StoreLink inventory + POS data
└── dist
└── index.js # Bundled production server (generated)
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。