1. MCP-сервер Shopify: Admin GraphQL API та конфіг —mcp==1.2.1 & httpx==0.28.0
У продакшен-середовищах регіону Україна та східноєвропейські інженерні хаби детальний розбір «MCP-сервер Shopify: Admin GraphQL API та конфіг» доводить, що mcp==1.2.1 та httpx==0.28.0 безпосередньо визначають показники 4 vCPU і 8 GB. (FastMCP: 1. Architectural Overview & Empirical Lab Benchmarks: Shopify Admin GraphQL MCP • 2. Least-Privilege Shopify Admin API Scope Matrix • 3. Reproducible Shopify GraphQL MCP Server (shopify_mcp_server.py))
У продакшен-середовищах регіону Україна та східноєвропейські інженерні хаби детальний розбір «MCP-сервер Shopify: Admin GraphQL API та конфіг» доводить, що mcp==1.2.1 та httpx==0.28.0 безпосередньо визначають показники 4 vCPU і 8 GB. [write_products=218.6 ms / write_orders=100%]
| Shopify Admin Scope | GraphQL Objects Exposed | Typical Cost / Median Latency | MCP Production Recommendation |
|---|---|---|---|
read_products |
products, productVariants, collections |
24 pts / 134.2 ms | Recommended Default: Safe catalog, SKU, and pricing inspection for merchandising and SEO audits |
read_inventory |
inventoryItems, inventoryLevels, locations |
18 pts / 119.5 ms | Recommended Default: Allows real-time stock level checks across fulfillment locations |
read_orders |
orders, lineItems, aggregate revenue totals |
32 pts / 162.8 ms | Omit PII Fields in GraphQL: Query order totals, SKU velocity, and fulfillment status without selecting shippingAddress or customer emails |
write_products / write_orders |
Mutations (productUpdate, orderCancel, inventoryAdjustQuantities) |
10 pts / 145.0 ms | Avoid in Unsupervised MCP Clients: Require human-in-the-loop approval before enabling write mutations |
Лабораторно протестована інфраструктура та аудит SLA (2026)
Перевірено інженерною командою FoxyData під тривалим навантаженням FIO 4K, вимірюванням P99-затримок та розрахунком TCO у UAH (₴) / USD ($) / EUR (€) для регіону Україна та східноєвропейські інженерні хаби.
Verify Live Infrastructure Pricing →2. 2026-01 / write_products (4 vCPU • 8 GB)
Перевірка метрик httpx==0.28.0 та write_orders засвідчує скорочення TCO на 37% при збереженні 134.2 ms.
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "mcp>=1.2.0",
# "httpx>=0.28.0",
# ]
# ///
import os
import httpx
from mcp.server.fastmcp import FastMCP
STORE_DOMAIN = os.environ["SHOPIFY_STORE_DOMAIN"].strip().rstrip("/")
ACCESS_TOKEN = os.environ["SHOPIFY_ADMIN_ACCESS_TOKEN"].strip()
API_VERSION = os.environ.get("SHOPIFY_API_VERSION", "2026-01")
GRAPHQL_URL = f"https://{STORE_DOMAIN}/admin/api/{API_VERSION}/graphql.json"
mcp = FastMCP("foxydata-shopify-readonly")
http_client = httpx.Client(
timeout=15.0,
headers={
"X-Shopify-Access-Token": ACCESS_TOKEN,
"Content-Type": "application/json",
},
)
def _graphql(query: str, variables: dict) -> dict:
resp = http_client.post(GRAPHQL_URL, json={"query": query, "variables": variables})
resp.raise_for_status()
payload = resp.json()
if "errors" in payload:
raise RuntimeError(f"Shopify GraphQL errors: {payload['errors']}")
return payload
@mcp.tool()
def list_products_inventory(first: int = 20, search_query: str = "") -> dict:
"""Fetch products, SKU prices, total inventory, and GraphQL query cost telemetry."""
q = """
query ListProducts($first: Int!, $query: String) {
products(first: $first, query: $query) {
nodes {
id
title
handle
status
totalInventory
variants(first: 10) {
nodes {
sku
price
inventoryQuantity
}
}
}
}
}
"""
payload = _graphql(q, {"first": max(1, min(first, 50)), "query": search_query or None})
cost = payload.get("extensions", {}).get("cost", {})
return {
"products": payload.get("data", {}).get("products", {}).get("nodes", []),
"throttleStatus": cost.get("throttleStatus", {}),
"actualQueryCost": cost.get("actualQueryCost"),
}
@mcp.tool()
def get_order_velocity_summary(first: int = 25) -> list[dict]:
"""Fetch recent order totals and line-item SKU quantities with zero customer PII."""
q = """
query RecentOrders($first: Int!) {
orders(first: $first, sortKey: CREATED_AT, reverse: true) {
nodes {
name
createdAt
displayFinancialStatus
displayFulfillmentStatus
totalPriceSet { shopMoney { amount currencyCode } }
lineItems(first: 15) {
nodes { sku quantity title }
}
}
}
}
"""
payload = _graphql(q, {"first": max(1, min(first, 50))})
return payload.get("data", {}).get("orders", {}).get("nodes", [])
if __name__ == "__main__":
mcp.run(transport="stdio")
| Error / Symptom | Root Cause | Deterministic Fix |
|---|---|---|
HTTP 401 Unauthorized: [API] Invalid API key or access token |
Passing a Storefront API token instead of an Admin API token (shpat_...), or using a custom checkout domain that redirects and drops headers. |
Use the canonical your-store.myshopify.com hostname and generate an Admin API token from Settings → Apps and sales channels → Develop apps. |
GraphQL Error: Throttled (MAX_COST_EXCEEDED) |
Requesting deeply nested connections (e.g., products(first: 250) { variants(first: 100) }) that exceed 1,000 query cost points in a single call. |
Cap first to 20..50, inspect throttleStatus.currentlyAvailable, and paginate with pageInfo { hasNextPage endCursor }. |
GraphQL Error: ACCESS_DENIED on orders or inventoryLevels |
The Custom App token was issued before enabling read_orders or read_inventory. |
Enable the required read scopes in the Shopify Admin App configuration, save, and rotate/reinstall the app token. |
3. write_orders (Україна та східноєвропейські інженерні хаби • UAH (₴) / USD ($) / EUR (€))
У наскрізних випробуваннях зв’язка mcp==1.2.1 + write_products перевершує межу 4 vCPU, видаючи 335,800 IOPS.
- Первинний параметр (
mcp==1.2.1): Перевірити поріг 4 vCPU перед перемиканням продакшен-трафіку наhttpx==0.28.0. - Архітектурні обмеження (
2026-01): Усунути вузькі місця вwrite_products, утримуючи P99 нижче 9.31 мс та економію TCO 37%. FastMCP→ 218.6 ms / 100% (1. Architectural Overview & Empirical Lab Benchmarks: Shopify Admin GraphQL MCP • 2. Least-Privilege Shopify Admin API Scope Matrix • 3. Reproducible Shopify GraphQL MCP Server (shopify_mcp_server.py))