This MCP (Model Context Protocol) server provides access to Shopify's GraphQL Admin API through a standardized interface that AI agents can interact with.
- Clone this repository
- Install the dependencies:
pip install -r requirements.txt
- Copy the
.env.example
file to.env
and fill in your credentials:
cp .env.example .env
- Edit the
.env
file with your Shopify Admin API credentials.
The Shopify GraphQL Admin API requires authentication via an access token. There are two main ways to obtain this token:
- Create a Shopify app in the Shopify Partner Dashboard
- Set up OAuth by registering a redirect URL
- Request the necessary API scopes during the OAuth process
- After a successful OAuth flow, you'll receive an access token
- Store this token in your
.env
file
- Go to your Shopify admin panel
- Navigate to Apps > Develop apps
- Create a custom app
- Add the required Admin API access scopes
- Generate an access token
- Store this token in your
.env
file
To use this MCP server with your AI agent, add the following configuration to your client config JSON file:
{
"mcp": {
"servers": {
"shopify": {
"command": ["python", "path/to/shopify_mcp_server.py"],
"tools": ["shopify_execute_graphql"]
}
}
}
}
Here are some example GraphQL queries you can run using the shopify_execute_graphql
tool:
query {
products(first: 5) {
edges {
node {
id
title
description
}
}
}
}
mutation {
productCreate(input: {
title: "New Product",
productType: "Accessories",
vendor: "My Store"
}) {
product {
id
title
}
userErrors {
field
message
}
}
}
Shopify's GraphQL API uses a calculated cost system for rate limiting. Each query has a cost based on the complexity and number of fields requested. Your API request will return the cost information, which you should monitor to avoid hitting rate limits.