shopnex-mcp
# shopnex-mcp
Model Context Protocol (MCP) server for [ShopNex](https://github.com/shopnex-ai/shopnex) stores. Connect Claude Desktop, Cursor, Cline / VS Code, Windsurf, or n8n to your ShopNex Admin REST API (`/api/v1/admin/*`) using a scoped `sk_…` API token.
Built on the official `@modelcontextprotocol/sdk` stdio transport with JSON Schema 2020-12 validated tool definitions, pagination from day one, dashboard analytics, preview-first inventory writes, and an optional read-only lock (`SHOPNEX_READ_ONLY=1`).
---
## Features
- **Official MCP SDK transport**: Uses `@modelcontextprotocol/sdk` (`Server` + `StdioServerTransport`) with zero hand-rolled framing and zero `stdout` log pollution.
- **JSON Schema 2020-12 & Anthropic API verified**: Every tool's `inputSchema` is validated in CI with `Ajv2020` (`strict: true`) and checked against Anthropic's strict tool-use schema rules.
- **ShopNex `/api/v1/admin/*` native contract**: Authenticates via `Authorization: Bearer sk_…`, maps pagination to `?limit=&offset=`, preserves exact integer-cent money amounts (`priceCents`, `totalCents`, `salesCents`), and surfaces missing `read_*` / `write_*` token scopes clearly on HTTP `403`.
- **Safe-by-default writes**: `update_product_inventory` defaults to `confirm: false` (dry-run diff preview) before mutating live variant stock, and `SHOPNEX_READ_ONLY=1` removes write tools completely.
---
## Tools
| Tool | Method & ShopNex Endpoint | Required Scope | Description |
| :--- | :--- | :--- | :--- |
| `list_products` | `GET /api/v1/admin/products` | `read_products` | Paginated catalog listing (`limit`, `page` / `offset`, `search`, `customField`). |
| `get_product` | `GET /api/v1/admin/products/{id}` | `read_products` | Full product details including options, variant UUIDs, SKUs, `priceCents`, and stock. |
| `update_product_inventory` | `PATCH /api/v1/admin/variants/{variantId}` | `write_products` | Updates variant `inventoryQuantity` (and optional `priceCents` / `sku`) with `confirm` preview gate. Hidden when `SHOPNEX_READ_ONLY=1`. |
| `list_orders` | `GET /api/v1/admin/orders` | `read_orders` | Paginated orders with `financialStatus`, `fulfillmentStatus`, `cancelled`, `customerId`, and `search` (`#1001`, email, name). |
| `list_customers` | `GET /api/v1/admin/customers` | `read_customers` | Paginated customer directory with `search` across email, name, and phone. |
| `shop_analytics` | `GET /api/v1/admin/analytics/overview` + `/admin/shop` | `read_orders` | Store sales, order count, AOV, returning customer rate vs. prior period, daily series, top 5 products, and unfulfilled/unpaid queues (`days`, IANA `timezone`). |
---
## 1-Step Token Setup
In your ShopNex Admin (**Settings → API tokens**), create a token (`sk_…`) with the scopes you want the assistant to have:
| Mode | Recommended Scopes (`Settings → API tokens`) |
| :--- | :--- |
| **Read + Inventory updates** | `write_products`, `read_orders`, `read_customers` (`write_*` automatically includes `read_*`) |
| **Read-only (`SHOPNEX_READ_ONLY=1`)** | `read_products`, `read_orders`, `read_customers` |
### Environment Variables
| Variable | Required | Default | Description |
| :--- | :--- | :--- | :--- |
| `SHOPNEX_URL` | Yes | — | Base URL of your ShopNex store (e.g. `https://shop.example.com` or `http://localhost:3000`). |
| `SHOPNEX_API_KEY` | Yes | — | Secret API token (`sk_…`) from **Settings → API tokens**. |
| `SHOPNEX_READ_ONLY` | No | `0` | Set to `1` or `true` to hide and block all write tools. |
| `SHOPNEX_TIMEOUT_MS` | No | `15000` | Per-request HTTP timeout in milliseconds (`1000`–`120000`). |
---
## Client Configuration
### Claude Desktop (`claude_desktop_config.json`)
```json
{
"mcpServers": {
"shopnex": {
"command": "npx",
"args": ["-y", "github:khoap1220-hue/shopnex-mcp"],
"env": {
"SHOPNEX_URL": "https://shop.example.com",
"SHOPNEX_API_KEY": "sk_your_token_here"
}
}
}
}
```
### Cursor (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"shopnex": {
"command": "npx",
"args": ["-y", "github:khoap1220-hue/shopnex-mcp"],
"env": {
"SHOPNEX_URL": "https://shop.example.com",
"SHOPNEX_API_KEY": "sk_your_token_here"
}
}
}
}
```
### Cline / VS Code (`.vscode/mcp.json`)
```json
{
"servers": {
"shopnex": {
"type": "stdio",
"command": "npx",
"args": ["-y", "github:khoap1220-hue/shopnex-mcp"],
"env": {
"SHOPNEX_URL": "https://shop.example.com",
"SHOPNEX_API_KEY": "sk_your_token_here"
}
}
}
}
```
### Windsurf (`~/.codeium/windsurf/mcp_config.json`)
```json
{
"mcpServers": {
"shopnex": {
"command": "npx",
"args": ["-y", "github:khoap1220-hue/shopnex-mcp"],
"env": {
"SHOPNEX_URL": "https://shop.example.com",
"SHOPNEX_API_KEY": "sk_your_token_here"
}
}
}
}
```
### n8n (MCP Client Tool Node — Command-line / Stdio)
| Field | Value |
| :--- | :--- |
| **Connection Type** | `Command Line (STDIO)` |
| **Command** | `npx` |
| **Arguments** | `-y github:khoap1220-hue/shopnex-mcp` |
| **Environment** | `SHOPNEX_URL=https://shop.example.com,SHOPNEX_API_KEY=sk_your_token_here` |
---
## Development & Verification
Requires **Node.js >= 20**.
```bash
npm install
npm run lint
npm run typecheck
npm run build
npm test
```
## License
MIT © 2026 [Khoa Phan](https://khoaphan.dev/services/?ref=gh-shopnex-mcp)
TDQS
Scored across 6 tools
Each tool targets a clearly distinct resource and action: three list_* tools for separate entity types, one get_* for single-product detail, one write for variant inventory, and one analytics aggregate. The list vs. get split for products is explicitly clarified by descriptions (catalog listing vs. full detail by UUID).
Five of six tools follow a snake_case verb_noun pattern (list_products, list_orders, get_product, update_product_inventory). shop_analytics breaks the verb-first convention as a bare noun phrase, a minor but noticeable deviation.
Six tools is a tight, focused set that avoids redundancy and fits a read-oriented store admin surface. It sits at the lower end of the comfortable range, leaving room for obvious companions like get_order or get_customer.
Coverage is read-heavy: products, orders, and customers can be listed and product detail/inventory can be read and updated, but there is no get_order, get_customer, create operation, or order fulfillment/refund path. Agents can partially work around gaps via search filters on list tools, but common admin write workflows are dead ends.