Skip to main content
Glama
hello532

shop-mcp

by hello532

shop-mcp

A Model Context Protocol server that lets an LLM agent answer questions about a Shopify store's catalogue and stock — over stdio, from a single file, using only the Python standard library.

No MCP SDK. No requests. No GraphQL client. python3 shop_mcp.py is the whole install.

$ python3 shop_mcp.py --self-test
all green: 189 assertions

That command needs no credentials and no network. It is the point of the repo: the protocol layer and the tool layer are both exercised for real, because the Shopify transport is replaced at a seam rather than mocked at the boundary.

Installed from PyPI, the same command reports 183, and the six-assertion difference is a packaging fact rather than a weaker check:

$ uvx --from shop-mcp shop-mcp --self-test
all green: 183 assertions

manifest.json (5 assertions) and README.md (1) are deliberately not shipped into site-packages — the manifest's entry_point names a bundle path that does not exist in an installed copy, so packaging it would make a correct install fail. Both assertions skip rather than fail when their file is absent, which is why the count moves and the verdict does not. Clone the repo to run all 189.

Why write the protocol by hand

Because the failure modes of a stdio MCP server are all invisible locally and all fatal in a host. Each one below is a real defect this file is built to not have, and each has an assertion naming it:

  • A diagnostic on stdout. One stray print() corrupts the client's next parse. Nothing looks wrong when you run the server yourself. Every diagnostic here goes to stderr, and a test asserts stdout stays byte-empty across a full session.

  • Answering a notification. notifications/initialized has no id, so a reply to it is a message with no pending request. Strict clients treat that as a protocol violation and drop the connection.

  • id: 0 read as a notification. if msg.get("id") is falsy for zero, so a client that numbers requests from zero has its first call silently dropped. Presence, not truthiness.

  • Tool failures sent as JSON-RPC errors. A JSON-RPC error is for a malformed request. A tool that ran and failed must return a normal result with isError: true and the reason as text — otherwise the model never sees the message and cannot correct its own arguments.

  • Echoing an unknown protocolVersion. If a client asks for a revision the server does not know, agreeing to it leaves both sides believing a spec is in use that neither implements. This falls back to 2025-03-26, the spec's own default, and says so.

  • Pretty-printing the reply. Indented JSON contains newlines, and newline is the frame delimiter. One message becomes several broken ones.

Related MCP server: cob-shopify-mcp

Tools

tool

answers

search_products

"what do we sell that matches X" — identity and total stock

get_product

one product in full, every variant with SKU, price, stock

check_inventory

stock for a SKU per location: available, committed, on-hand

low_stock_report

variants at or below a threshold, lowest first

Four tools, chosen because each answers a question a shop owner actually asks. A wider surface would be easy and would make the model worse at picking.

The correctness that is not protocol

Three of the assertions cover mistakes that produce confidently wrong answers, which are worse than errors:

  • An unquoted SKU. sku:SH 1 is a different query from sku:"SH 1". The first silently matches the wrong variants and reports their stock as if it were yours. SKUs are quoted and internal quotes escaped.

  • A null quantity read as zero. Shopify returns null for a variant that does not track inventory. Coerced to 0, it appears in every restock report forever. Untracked and out-of-stock are different facts and stay different.

  • scan_exhausted. low_stock_report scans a bounded number of variants. If the scan hit its limit, "nothing is low" is indistinguishable from "I did not look far enough" — so the result says which it was, and the model can say so too.

Plus the transport rules any Shopify client needs and most skip: a THROTTLED GraphQL response is a 200 and must be retried, not read as success; a 401 must not be retried, because waiting will not fix a bad token; backoff must actually grow.

Verified, and not verified

Verified, by the self-test, on every run: 189 assertions covering the handshake, framing, notification handling, id presence, error mapping, schema strictness, retry and backoff policy, SKU quoting, null-quantity handling, threshold boundaries, and scan exhaustion. Wire shapes were taken from the official mcp Python SDK's types.py (LATEST_PROTOCOL_VERSION, CallToolResult, ServerCapabilities), not from memory.

Not verified: this has never been run against a live Shopify store. There is no credential in this repo and no recorded API session. The Shopify Admin GraphQL queries are written to the documented schema, and every code path around them is tested against a transport double — but the round trip against a real shop is unproven, and the test doubles are my model of Shopify's behaviour, not Shopify.

That distinction is the honest one, and it is the same line drawn in gpt-ads-feed. A README that blurs it is asking to be trusted on the wrong thing.

Assertions that can fail

mutation_test.sh injects known defects into copies of the source and asserts --self-test goes red for each, naming which assertion caught it. It also flags a NO-OP EDIT when a search pattern has gone stale — because a mutation that does not apply tests nothing while looking green, which is the failure mode that makes a suite worse than useless: trusted and empty.

It found real weaknesses in the suite on its first run, and all three were the same shape: the defect was detected, but by an exception rather than by a named assertion, so the message explained nothing and every assertion after it never ran.

Two were an unhandled KeyError: 'result', from indexing a reply that the defect had turned into a JSON-RPC error. Fixed by routing result access through a shape guard, so the same defect now reports a tool crash returns a result, so the loop survives: reply is a JSON-RPC error {'code': -32603, ...} and the three following assertions each still report their own verdict.

The third was a bare setup call — S.Tools(c).search_products(...), present only to make the assertion below it meaningful. When the throttle branch was disabled it raised, aborting the test before that assertion ran. Fixed with completes(), the exact inverse of raises(): the defect now reports a 200-with-THROTTLED is survivable, not a hard failure: raised ShopifyError: Throttled [THROTTLED], naming the rule and keeping the cause.

Three more defects surfaced only when the server was packaged as an .mcpb bundle and launched the way a host launches it, which no test had ever done:

  1. The code read SHOPIFY_SHOP; this README and the bundle manifest both told users to export SHOPIFY_SHOP_DOMAIN. Anyone following the docs got a permanently unconfigured server. Every one of the 180 assertions passed, because none of them compared the code against the docs.

  2. tools/list returned [] until credentials existed, so a host saw an empty server and reported it broken — and the readable no store is configured message on tools/call was unreachable, since nothing was listed to call. The docstring above that code stated the opposite requirement, and the test below it asserted the defect: eq(tools, [], ...). The list never depended on credentials; descriptors() touched no instance state at all, and is now a staticmethod.

  3. --self-test was advertised in the module docstring but crashed inside the bundle, which shipped only the server file. The bundle now ships the suite.

The first fix then broke the harness in a way worth recording. The new assertion failed when README.md was absent, and the harness copied only two files, so it fired inside every mutant. The run still printed 17 caught, but six of those were credited to README.md is present instead of their own labels: six real assertions could have been dead with the suite still green. A missing README is a packaging fact, not a code defect. The load-bearing comparison now runs against the module docstring, which travels with the source, and the harness copies the README so the cross-check is real.

All 23 mutations are caught by an assertion that names what broke, and each is credited to its own label.

Use it

Installed from PyPI — nothing to clone:

export SHOPIFY_SHOP_DOMAIN=your-shop.myshopify.com
export SHOPIFY_ADMIN_TOKEN=shpat_...          # read_products, read_inventory
uvx shop-mcp                                  # or: pip install shop-mcp && shop-mcp

Claude Desktop / any MCP host:

{
  "mcpServers": {
    "shop": {
      "command": "uvx",
      "args": ["shop-mcp"],
      "env": {
        "SHOPIFY_SHOP_DOMAIN": "your-shop.myshopify.com",
        "SHOPIFY_ADMIN_TOKEN": "shpat_..."
      }
    }
  }
}

From a clone instead, when you want to read the source before running it — which is the point of a single dependency-free file, and the only way to get the full 189-assertion suite:

python3 shop_mcp.py --self-test    # 189 here, 183 installed; see above
python3 shop_mcp.py
{ "command": "python3", "args": ["/absolute/path/to/shop_mcp.py"] }

With no credentials set it still completes a handshake and serves tools/list, then returns isError with the missing variable named. A host that cannot read tools/list reports "broken server" and sends you looking in the wrong place.

MIT.

Available Tools

4 tools
check_inventoryA

Stock for a SKU broken down by location, with available, committed and on-hand counts. Use when the question is 'can we ship it' rather than 'do we sell it'.

ParametersJSON Schema
NameRequiredDescriptionDefault
skuYesExact SKU to look up.
limitNoMaximum matching variants, 1-50.

TDQS

A4.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden for behavioral transparency. It does not explicitly state that the operation is read-only, nor does it mention authentication, rate limits, or other side effects. The read-only nature is implied but not disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences, front-loading the core purpose and then giving a practical usage guideline. There is no unnecessary detail or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description compensates by explaining the output shape: stock broken down by location with available, committed, and on-hand counts. It also provides the decision context, making it complete for this simple tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides descriptions for both parameters ('Exact SKU to look up' and 'Maximum matching variants, 1-50'), so schema coverage is high. The tool description adds context about the response structure but does not further clarify parameter semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns stock levels for a SKU, broken down by location with available, committed, and on-hand counts. It also distinguishes this from product-level queries by noting the 'can we ship it' use case.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly tells when to use this tool: when the question is about shippable availability ('can we ship it') rather than whether the item is sold ('do we sell it'). This provides clear guidance relative to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_productA

Read one product in full, including every variant with its SKU, price and stock level. Identify it by handle or by gid://shopify/Product/... id. Exactly one of the two.

ParametersJSON Schema
NameRequiredDescriptionDefault
idNogid://shopify/Product/1234567890
handleNoURL handle, e.g. 'blue-shirt'.

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description fully carries the burden of explaining behavior. It clearly indicates this is a read operation ('Read one product in full'), describes the extent of data returned (variants with SKU, price, stock level), and does not imply any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, using two sentences to convey the tool's purpose, the data returned, and the parameter constraint. No unnecessary words or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple fetch operation without an output schema, the description provides sufficient context: what it does, what data is included, and how to specify the target. It does not leave critical gaps that would prevent correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful constraints beyond the schema by stating that exactly one of the two parameters (id or handle) must be used. This clarifies the relationship and use of the parameters, which the schema alone does not fully convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reads a single product in full, including variants with SKU, price, and stock level. It distinguishes itself from siblings like search_products and check_inventory by focusing on retrieving a specific product's complete data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly instructs that the product must be identified by handle or by gid://shopify/Product/... id and that exactly one of the two must be provided. This gives clear guidance on when to use this tool versus alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

low_stock_reportA

Variants at or below a stock threshold, lowest first. Use for restock questions. Scans up to scan variants and filters locally, so raise scan for a large catalogue.

ParametersJSON Schema
NameRequiredDescriptionDefault
scanNoVariants to examine, 1-250. Default 100.
thresholdNoReport variants with stock <= this. Default 5.

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of explaining behavior. It discloses that the tool 'Scans up to `scan` variants and filters locally,' including a performance tip to 'raise `scan` for a large catalogue.' This gives agents important context about potential limitations and how to adjust parameters accordingly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is just two sentences, yet conveys purpose, usage, parameter behavior, and a practical tip. It is tightly worded without redundancy, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema and simple parameters, the description is essentially complete. It explains what is returned (variants at or below threshold), the sort order, and the parameter effects. A minor gap is not explicitly stating the output format, but that is not critical for this kind of report.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already fully covers both parameters with descriptions. The tool description adds further meaning by explaining the interaction: the threshold determines what qualifies as low stock, and the scan parameter controls how many variants are examined. This enriches the schema's static explanations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Variants at or below a stock threshold, lowest first.' This is a specific action (reporting) on a specific resource (variants). It distinguishes itself from sibling tools like search_products and check_inventory by focusing on low-stock items.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says 'Use for restock questions,' providing direct guidance on when to invoke this tool over alternatives. Though it doesn't name sibling tools, the use case is clearly differentiated from search/get/inventory operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_productsA

Find products in the store by free text, vendor, or status. Returns identity and total inventory only, not per-variant detail; call get_product for that. Use this first when you do not already know a handle.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum products to return, 1-50.
queryYesShopify search syntax, e.g. 'title:shirt', 'vendor:Acme', 'status:ACTIVE', or plain words.

TDQS

A4.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden for behavioral transparency. It states that only identity and total inventory are returned, but it does not explicitly mention whether the operation is read-only or if there are other side effects, auth requirements, or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, using three focused sentences. It front-loads the primary purpose, then clarifies output limitations and usage context without unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple and the description is sufficient for invocation, including query syntax and response scope. However, no output schema is provided and the description only names 'identity and total inventory' without specifying exact fields, leaving some minor ambiguity about the return shape.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful detail to both parameters: query is explained with Shopify search syntax examples, and limit's range is reiterated in the description. Schema coverage is 100%, and the description enhances understanding of how to construct effective queries.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: searching/finding products by free text, vendor, or status. It distinguishes this from get_product by noting that this is the entry point when the handle is unknown.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says to use this tool first when you do not already know a handle, and directs users to get_product for per-variant detail. This provides clear when-to-use and alternative guidance relative to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv1.0.1
    • First observedcheck_inventory
    • First observedget_product
    • First observedlow_stock_report
    • First observedsearch_products

TDQS

A4.4/5.0
Disambiguation5/5

Each tool has a distinct purpose: search_products finds products by criteria, get_product retrieves full details for one product, check_inventory queries stock per SKU by location, and low_stock_report lists variants under a threshold. No meaningful overlap or ambiguity exists.

Naming Consistency4/5

Most tools follow a clear verb_noun pattern (search_products, get_product, check_inventory), but low_stock_report is an adjective_noun phrase rather than verb_noun. The naming is still readable and predictable, with only this minor deviation.

Tool Count5/5

Four tools is a focused, appropriate set for a shop/inventory domain. Each tool covers a necessary operation without redundancy or bloat.

Completeness4/5

The set covers core read operations for products and inventory, including search, detail retrieval, per-SKU stock checks, and low-stock reporting. It lacks write operations (create/update/delete) or order-management functions, but the stated purpose appears read-only, so the gap is minor.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A Shopify-focused MCP server that enables AI agents to manage store operations like order tracking, product discovery, and checkout link generation. It facilitates customer-facing interactions including shipping estimates and real-time inventory searches.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    A production-grade MCP server and CLI tool that enables AI agents to manage Shopify stores through 49 built-in tools across products, orders, inventory, and analytics. It supports natural language workflows for tasks like inventory tracking, customer support, and sales reporting.
    433
    18
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Exposes Shopify order and inventory management tools via MCP, allowing agents to fetch, update, and print orders without exposing raw Shopify credentials.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hello532/shop-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server