Build a Shopify Admin REST API MCP Server
Connect Claude Desktop or Cursor to your Shopify store orders, draft orders, and fulfillment tracking with proper X-Shopify-Access-Token header wiring.
MCP Tool Selection
6 / 10 Free6 endpoints parsed • 2 safety-guarded
List Shopify store orders
Retrieve a specific order by ID
Cancel a Shopify order and optionally restock
Create a draft order for manual invoicing
List fulfillment tracking records for an order
Delete a registered Shopify store webhook
1#!/usr/bin/env node2/**3* Generated by Spec2MCP (https://spec2mcp.com)4* Server: shopify-admin-orders-api v2025-015* Tools exposed: 66*/7import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";8import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";9import { z } from "zod";1011const BASE_URL = (process.env.SHOPIFY_ADMIN_ORDERS_API_BASE_URL ?? "https://your-store.myshopify.com/admin/api/2025-01").replace(/\/+$/, "");12const API_KEY = process.env.SHOPIFY_ADMIN_ORDERS_API_API_KEY ?? "";13function buildAuthHeaders(): Record<string, string> {14return API_KEY ? { "X-Shopify-Access-Token": API_KEY } : {};15}1617interface UpstreamRequest {18method: string;19path: string;20query?: URLSearchParams;21body?: Record<string, unknown>;22}2324async function callUpstream(req: UpstreamRequest) {25const qs = req.query && req.query.toString() ? `?${req.query.toString()}` : "";26const url = `${BASE_URL}${req.path}${qs}`;2728const headers: Record<string, string> = {29Accept: "application/json",30"User-Agent": "spec2mcp/shopify-admin-orders-api",31...buildAuthHeaders(),32};3334if (req.body !== undefined) {35headers["Content-Type"] = "application/json";36}3738try {39const controller = new AbortController();40const timer = setTimeout(() => controller.abort(), 20_000);41const response = await fetch(url, {42method: req.method,43headers,44body: req.body !== undefined ? JSON.stringify(req.body) : undefined,45signal: controller.signal,46});47clearTimeout(timer);4849const rawText = await response.text();50let formatted = rawText;51try {52formatted = JSON.stringify(JSON.parse(rawText), null, 2);53} catch {54// keep raw text if upstream returned non-JSON55}5657if (!response.ok) {58return {59isError: true,60content: [61{62type: "text" as const,63text: `HTTP ${response.status} ${response.statusText} from ${req.method} ${req.path}\n${formatted}`,64},65],66};67}6869return {70content: [71{72type: "text" as const,73text: formatted || `HTTP ${response.status} (empty body)`,74},75],76};77} catch (err) {78const message = err instanceof Error ? err.message : String(err);79return {80isError: true,81content: [82{83type: "text" as const,84text: `Network error calling ${req.method} ${url}: ${message}`,85},86],87};88}89}9091const server = new McpServer({92name: "shopify-admin-orders-api",93version: "2025-01",94});9596server.tool(97"list_orders",98"List Shopify store orders [GET /orders.json]",99{100"status": z.enum(["open", "closed", "cancelled", "any"]).describe("Order status filter").optional(),101"financial_status": z.enum(["authorized", "pending", "paid", "refunded", "any"]).describe("Payment state filter").optional(),102"limit": z.number().int().describe("Max orders to return (1-250)").optional(),103},104{105title: "List Shopify store orders",106readOnlyHint: true,107destructiveHint: false,108idempotentHint: true,109openWorldHint: true,110},111async (args) => {112const query = new URLSearchParams();113if (args["status"] !== undefined) query.set("status", String(args["status"]));114if (args["financial_status"] !== undefined) query.set("financial_status", String(args["financial_status"]));115if (args["limit"] !== undefined) query.set("limit", String(args["limit"]));116return callUpstream({117method: "GET",118path: "/orders.json",119query,120});121}122);123124server.tool(125"get_order",126"Retrieve a specific order by ID [GET /orders/{order_id}.json]",127{128"order_id": z.string().describe("Numeric Shopify Order ID"),129},130{131title: "Retrieve a specific order by ID",132readOnlyHint: true,133destructiveHint: false,134idempotentHint: true,135openWorldHint: true,136},137async (args) => {138return callUpstream({139method: "GET",140path: `/orders/${encodeURIComponent(String(args["order_id"]))}.json`,141});142}143);144145server.tool(146"cancel_order",147"Cancel a Shopify order and optionally restock [POST /orders/{order_id}/cancel.json]",148{149"order_id": z.string().describe("Numeric Shopify Order ID"),150"reason": z.enum(["customer", "fraud", "inventory", "declined", "other"]).describe("Cancellation reason").optional(),151"email": z.boolean().describe("Send cancellation email to customer").optional(),152confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this POST operation."),153},154{155title: "Cancel a Shopify order and optionally restock",156readOnlyHint: false,157destructiveHint: true,158idempotentHint: false,159openWorldHint: true,160},161async (args) => {162if (!args.confirm_destructive_action) {163return {164isError: true,165content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],166};167}168const bodyPayload: Record<string, unknown> = {};169if (args["reason"] !== undefined) bodyPayload["reason"] = args["reason"];170if (args["email"] !== undefined) bodyPayload["email"] = args["email"];171return callUpstream({172method: "POST",173path: `/orders/${encodeURIComponent(String(args["order_id"]))}/cancel.json`,174body: bodyPayload,175});176}177);178179server.tool(180"create_draft_order",181"Create a draft order for manual invoicing [POST /draft_orders.json]",182{183"draft_order": z.record(z.unknown()).describe("Draft order line_items and customer payload"),184},185{186title: "Create a draft order for manual invoicing",187readOnlyHint: false,188destructiveHint: false,189idempotentHint: false,190openWorldHint: true,191},192async (args) => {193const bodyPayload: Record<string, unknown> = {};194if (args["draft_order"] !== undefined) bodyPayload["draft_order"] = args["draft_order"];195return callUpstream({196method: "POST",197path: "/draft_orders.json",198body: bodyPayload,199});200}201);202203server.tool(204"list_order_fulfillments",205"List fulfillment tracking records for an order [GET /orders/{order_id}/fulfillments.json]",206{207"order_id": z.string().describe("Numeric Shopify Order ID"),208},209{210title: "List fulfillment tracking records for an order",211readOnlyHint: true,212destructiveHint: false,213idempotentHint: true,214openWorldHint: true,215},216async (args) => {217return callUpstream({218method: "GET",219path: `/orders/${encodeURIComponent(String(args["order_id"]))}/fulfillments.json`,220});221}222);223224server.tool(225"delete_webhook",226"Delete a registered Shopify store webhook [DELETE /webhooks/{webhook_id}.json]",227{228"webhook_id": z.string().describe("Webhook ID to delete"),229confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this DELETE operation."),230},231{232title: "Delete a registered Shopify store webhook",233readOnlyHint: false,234destructiveHint: true,235idempotentHint: false,236openWorldHint: true,237},238async (args) => {239if (!args.confirm_destructive_action) {240return {241isError: true,242content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],243};244}245return callUpstream({246method: "DELETE",247path: `/webhooks/${encodeURIComponent(String(args["webhook_id"]))}.json`,248});249}250);251252async function main() {253const transport = new StdioServerTransport();254await server.connect(transport);255console.error("shopify-admin-orders-api MCP server listening on stdio (6 tools)");256}257258main().catch((err) => {259console.error("Fatal MCP server error:", err);260process.exit(1);261});262
How to export & compile your Shopify Admin OpenAPI spec
Click the 'Shopify Orders' preset above and replace your-store.myshopify.com in the Base URL field.
High-Signal Shopify Admin MCP Tools to Expose First
| Method | Endpoint Path | MCP Tool Name | Purpose |
|---|---|---|---|
| GET | /orders.json | list_orders | Filter open, paid, or pending store orders |
| GET | /orders/{order_id}.json | get_order | Inspect line items and customer details |
| POST | /orders/{order_id}/cancel.json | cancel_order | Guarded order cancellation workflow |
| POST | /draft_orders.json | create_draft_order | Create custom B2B invoice drafts |
Best Practices for Shopify Admin
- Pin a specific Shopify API version in your Base URL (e.g., /admin/api/2025-01) so field shapes stay predictable across quarters.
- Keep cancel_order and delete_webhook behind confirmation guards to protect live storefront revenue and integrations.
- Use status and financial_status enum filters on list_orders so LLMs never pull thousands of historical orders into context.
Common Shopify Admin MCP Gotchas
- Shopify uses the custom header X-Shopify-Access-Token rather than Authorization: Bearer—Spec2MCP auto-configures this header from your securityScheme.
- Shopify Admin REST endpoints return large nested JSON payloads; consider setting limit=10 by default in your agent system prompt.
- Each Shopify Custom App token must explicitly declare read_orders / write_draft_orders scopes in Shopify Admin.
Shopify Admin API to MCP Server — Frequently Asked Questions
How does Spec2MCP authenticate with Shopify Admin API?
Spec2MCP reads the apiKey header scheme and injects your shpat_... token into the X-Shopify-Access-Token header on every request.
Can I restrict the MCP server to read-only store analytics?
Yes. Click 'Select Safe (GET)' in the studio toolbar to disable POST and DELETE endpoints and generate a strictly read-only Shopify MCP server.
Does this work for multiple Shopify stores?
Yes—you can register multiple entries in mcp.json pointing to the same compiled server binary with different BASE_URL and API_KEY env vars.
Related OpenAPI-to-MCP Converters
View all 20Bearer sk_test_... / rk_live_... restricted API key
HTTP Basic Auth (agent@company.com/token:ZENDESK_API_TOKEN) or OAuth Bearer
HubSpot Private App Bearer Token (pat-na1-...)
Bearer, API Key Header/Query, or Basic via process.env
Free locally forever. Upgrade when your team goes remote.
Compile focused local TypeScript & Python MCP servers in your browser for $0. Move to Pro Cloud or Team when you need unlimited endpoints, hosted Remote MCP URLs, OAuth2 proxying, and CI sync.
Everything solo engineers need to turn REST APIs into local stdio MCP servers with zero login.
- Local TypeScript SDK + Zod codegen
- Local Python FastMCP + httpx codegen
- Up to 10 endpoints per MCP server
- Live context-window token estimator
- Destructive action confirmation guards
- Claude Desktop, Cursor, Windsurf & Antigravity mcp.json
- 100% client-side — specs stay in browser
Compile unlimited endpoints and publish a hosted Remote MCP URL with encrypted credential vaulting.
- Unlimited OpenAPI endpoints & tool grouping
- 1-click hosted Remote MCP endpoint (Streamable HTTP)
- Encrypted OAuth2 & API-Key secret vault
- Custom tool presets & OpenAPI overlay persistence
- Response payload truncation to stop context blowups
- Priority email & Discord support
Built for engineering orgs keeping internal MCP servers automatically synced with OpenAPI repos.
- Everything in Pro Cloud
- GitHub / GitLab CI auto-sync on OpenAPI PR merges
- Per-tool invocation audit logs & latency metrics
- Per-user rate limits & destructive-tool approval policies
- Role-based access across engineering & ops teams
- Dedicated onboarding & custom auth helpers