๐ Magento 2 GraphQL Documentation MCP Server
A local STDIO MCP server that provides tools to search and retrieve Magento 2 GraphQL API documentation from local markdown files.
๐ New to setup? See SETUP.md for a step-by-step quick start guide.
โจ Features
- Search Documentation: Conduct full-text search across over 350 GraphQL documentation pages.
- Get Complete Documents: Retrieve full documentation along with metadata.
- Search GraphQL Elements: Find queries, mutations, types, and interfaces.
- Get Element Details: View complete schema element definitions accompanied by examples.
- Browse Categories: Navigate through the documentation hierarchy (schema, develop, usage, tutorials).
- Access Tutorials: Obtain step-by-step learning paths (e.g., checkout workflow).
- Search Code Examples: Find working code examples in GraphQL, JSON, JavaScript.
- Discover Related Docs: Automatically find related documentation.
- Offline Operation: Operate entirely offline using local markdown files.
- Fast Startup: Only re-index if documentation files have changed (less than 5 seconds).
๐ Quick Start
Step 1: Clone the Documentation Repository
The MCP server needs access to the Adobe Commerce GraphQL documentation markdown files. Clone the official repository:
git clone https://github.com/AdobeDocs/commerce-webapi.git
Step 2: Set Up the Documentation Path
You have two options for configuring the documentation path:
Option A: Using a Symlink (Recommended)
Create a symlink in the project directory:
cd magento-graphql-docs-mcp
ln -s /path/to/commerce-webapi/src/pages/graphql data
Option B: Using Environment Variable
Set the MAGENTO_GRAPHQL_DOCS_PATH environment variable:
export MAGENTO_GRAPHQL_DOCS_PATH="/path/to/commerce-webapi/src/pages/graphql"
To make this permanent, add it to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export MAGENTO_GRAPHQL_DOCS_PATH="/path/to/commerce-webapi/src/pages/graphql"' >> ~/.zshrc
source ~/.zshrc
Step 3: Verify Documentation Access
Check that the documentation path is accessible:
ls -la data/
ls -la $MAGENTO_GRAPHQL_DOCS_PATH/
Step 4: Install the MCP Server
cd magento-graphql-docs-mcp
pip install -e .
(Optional) Build and Run with Docker
If you prefer Docker, build the image and mount your docs path to /data (or set MAGENTO_GRAPHQL_DOCS_PATH to another location):
docker build -t magento-graphql-docs-mcp -f docker/Dockerfile .
docker run --rm -it \
-v /absolute/path/to/commerce-webapi/src/pages/graphql:/data \
magento-graphql-docs-mcp
Auto-fetch fallback: if you do not mount docs, the container can clone them on start. Control this with MAGENTO_GRAPHQL_DOCS_AUTO_FETCH (default: true):
docker run --rm -it magento-graphql-docs-mcp
docker run --rm -it \
-e MAGENTO_GRAPHQL_DOCS_AUTO_FETCH=false \
-v /absolute/path/to/commerce-webapi/src/pages/graphql:/data \
magento-graphql-docs-mcp
Host-Side Docker Wrapper (STDIO)
Use the provided wrapper to run the container and forward STDIN/STDOUT for MCP clients (no TTY added):
./run-docker-mcp.sh
What it does:
- Automatically builds the
magento-graphql-docs-mcp image if it is missing.
- Mounts
MAGENTO_GRAPHQL_DOCS_PATH (or ./data) to /data if it exists; otherwise relies on auto-fetch.
- Keeps STDIO clean for MCP clients; prints connection instructions on start.
- Respects
MAGENTO_GRAPHQL_DOCS_AUTO_FETCH (set to false to require a mounted path).
Point your MCP client command to the wrapper path. Example Claude Desktop config:
{
"mcpServers": {
"magento-graphql-docs": {
"command": "/absolute/path/to/run-docker-mcp.sh"
}
}
}
VS Code MCP Configuration
Example VS Code MCP config using the Docker wrapper:
{
"servers": {
"magento-webapi-docs": {
"type": "stdio",
"command": "/absolute/path/to/run-docker-mcp.sh"
}
}
}
After adding the server entry, open the VS Code MCP/Tools panel and press โStartโ for magento-webapi-docs to launch the container-backed STDIO server.
Docker Compose (HTTP/SSE)
Use the provided docker-compose.yml to run the server on HTTP/SSE:
docker compose up --build
This builds from docker/Dockerfile, maps 8765:8765, and sets MAGENTO_GRAPHQL_DOCS_TRANSPORT=http with MAGENTO_GRAPHQL_DOCS_HOST=0.0.0.0. Uncomment the volumes block in docker-compose.yml to bind a local docs checkout; otherwise the image can auto-fetch the docs. Port 8765 is chosen to avoid common 8080 conflicts; adjust as needed.
Step 5: Run and Verify
magento-graphql-docs-mcp
python3 tests/verify_parser.py
python3 tests/verify_db.py
python3 tests/verify_server.py
๐ฆ Installation
Requirements
- Python 3.10 or higher
- Git (to clone the documentation repository)
- Over 350 Magento 2 GraphQL documentation markdown files from AdobeDocs/commerce-webapi
Detailed Setup
1. Clone Both Repositories
git clone https://github.com/AdobeDocs/commerce-webapi.git
cd magento-graphql-docs-mcp
2. Configure Documentation Path
The server looks for documentation in this order (with path validation on startup):
- Environment variable
MAGENTO_GRAPHQL_DOCS_PATH (if set, validates path exists)
./data/ directory (symlink or directory with .md files in project root)
../commerce-webapi/src/pages/graphql/ (sibling directory auto-detection)
If no valid path is found, the server will fail with a helpful error message explaining all three setup options.
Choose the method that works best for your setup:
ln -s ~/projects/commerce-webapi/src/pages/graphql data
export MAGENTO_GRAPHQL_DOCS_PATH="$HOME/projects/commerce-webapi/src/pages/graphql"
3. Install Dependencies
pip install -e .
This installs:
fastmcp - MCP server framework
sqlite-utils - Database management
pydantic - Data validation
python-frontmatter - YAML frontmatter parsing
markdown-it-py - Markdown processing
๐ป Usage
Running the Server
Once configured, start the server:
magento-graphql-docs-mcp
On subsequent runs, if the documentation hasn't changed, startup is nearly instant (around 0.87s).
Running Over HTTP/SSE
STDIO remains the default. To expose the server via HTTP with SSE (for clients that expect MCP over SSE), set the transport variables:
MAGENTO_GRAPHQL_DOCS_TRANSPORT=http \
MAGENTO_GRAPHQL_DOCS_HOST=0.0.0.0 \
MAGENTO_GRAPHQL_DOCS_PORT=8765 \
magento-graphql-docs-mcp
MAGENTO_GRAPHQL_DOCS_HOST defaults to 127.0.0.1 and MAGENTO_GRAPHQL_DOCS_PORT defaults to 8765 when unset. Port 8765 is frequently used by other services; pick any free port (the example above uses the default port 8765).
Configuration
The server uses environment variables for configuration:
Documentation Path
Set where the GraphQL documentation is located:
export MAGENTO_GRAPHQL_DOCS_PATH="/Users/you/projects/commerce-webapi/src/pages/graphql"
export MAGENTO_GRAPHQL_DOCS_PATH="./data"
export MAGENTO_GRAPHQL_DOCS_PATH="~/repos/commerce-webapi/src/pages/graphql"
Default: The server looks for documentation in these locations (in order, with validation):
MAGENTO_GRAPHQL_DOCS_PATH environment variable (validated on startup)
./data/ directory in project root (must contain .md files)
../commerce-webapi/src/pages/graphql/ (sibling directory auto-detection)
Database Location
Customize where the SQLite database is stored:
export MAGENTO_GRAPHQL_DOCS_DB_PATH="/custom/path/magento-graphql.db"
The database directory will be created automatically if it doesn't exist.
Performance Tuning (Optional)
Customize search behavior and limits:
export MAGENTO_GRAPHQL_DOCS_TOP_K=10
export MAGENTO_GRAPHQL_DOCS_MAX_FIELDS=30
export MAGENTO_GRAPHQL_DOCS_CODE_PREVIEW=600
Transport & Port
Control how the MCP server is exposed:
MAGENTO_GRAPHQL_DOCS_TRANSPORT: stdio (default) or http/sse to enable HTTP + SSE
MAGENTO_GRAPHQL_DOCS_HOST: bind address for HTTP/SSE mode (default: 127.0.0.1)
MAGENTO_GRAPHQL_DOCS_PORT: HTTP/SSE port (default: 8765)
FastMCP serves SSE when transport="http".
Using with an MCP Client
Configure your MCP client (e.g., Claude Desktop, Cline, etc.) to use this server.
Example: Claude Desktop Configuration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"magento-graphql-docs": {
"command": "magento-graphql-docs-mcp",
"env": {
"MAGENTO_GRAPHQL_DOCS_PATH": "/Users/you/projects/commerce-webapi/src/pages/graphql"
}
}
}
}
Example: Using Python Module Directly
{
"mcpServers": {
"magento-graphql-docs": {
"command": "python3",
"args": ["-m", "magento_graphql_docs_mcp.server"],
"env": {
"MAGENTO_GRAPHQL_DOCS_PATH": "/path/to/commerce-webapi/src/pages/graphql"
}
}
}
}
Example: With Custom Database Path
{
"mcpServers": {
"magento-graphql-docs": {
"command": "magento-graphql-docs-mcp",
"env": {
"MAGENTO_GRAPHQL_DOCS_PATH": "/path/to/commerce-webapi/src/pages/graphql",
"MAGENTO_GRAPHQL_DOCS_DB_PATH": "/custom/databases/magento-graphql.db"
}
}
}
}
After configuration, restart your MCP client to activate the server.
๐ป Usage Examples
The examples/ directory contains practical usage examples demonstrating all MCP tools:
Available Examples
- Product Queries (
examples/example_products.py)
- Search product documentation.
- Find product GraphQL queries and types.
- Explore ProductInterface details.
- Search product code examples.
- Customer Queries (
examples/example_customer.py)
- Search customer documentation.
- Find customer mutations (create, update).
- Explore authentication and tokens.
- Find customer address operations.
- Cart & Checkout (
examples/example_cart_checkout.py)
- Search cart documentation.
- Complete checkout workflow tutorial.
- Find cart mutations and queries.
- Explore checkout step-by-step.
Running Examples
python3 examples/example_products.py
python3 examples/example_customer.py
python3 examples/example_cart_checkout.py
bash examples/run_all_examples.sh
See examples/README.md for detailed documentation.
๐ MCP Tools
1. search_documentation
Search for documentation pages using keywords.
Parameters:
queries: List of 1 - 3 short keyword queries (e.g., ["product", "cart"])
category: Optional filter (schema, develop, usage, tutorials)
subcategory: Optional filter (products, cart, customer, etc.)
content_type: Optional filter (guide, reference, tutorial, schema)
Example:
search_documentation(queries=["checkout"], category="tutorials")
2. get_document
Get complete documentation page by file path.
Parameters:
file_path: Relative path to document (e.g., "schema/products/queries/products.md")
Returns: Full document content with metadata, frontmatter, and markdown.
3. search_graphql_elements
Search for GraphQL queries, mutations, types, or interfaces.
Parameters:
query: Search term
element_type: Optional filter (query, mutation, type, interface, union)
Example:
search_graphql_elements(query="products", element_type="query")
4. get_element_details
Get complete details about a specific GraphQL element.
Parameters:
element_name: Element name (e.g., "products", "createCustomer")
element_type: Optional type filter
Returns: Full element definition with fields, parameters, source document, and code examples.
5. list_categories
List all documentation categories with document counts.
Returns: Hierarchical category tree showing all available documentation areas.
6. get_tutorial
Get complete tutorial with all steps in order.
Parameters:
tutorial_name: Tutorial name (e.g., "checkout")
Returns: Sequential tutorial steps with code examples and explanations.
7. search_examples
Search for code examples by topic and language.
Parameters:
query: Search term
language: Optional language filter (graphql, json, javascript, php, bash)
Example:
search_examples(query="add to cart", language="graphql")
8. get_related_documents
Find documents related to a specified document.
Parameters:
file_path: File path of source document
Returns: Related documents based on category and keywords.
๐งช Verification Scripts
Test each component independently.
Important: Run all tests from the project root directory:
cd magento-graphql-docs-mcp
python3 tests/verify_parser.py
python3 tests/verify_db.py
python3 tests/verify_server.py
python3 tests/benchmark_performance.py
Running tests from other directories will cause import errors.
๐ง Technical Details
Database Schema
The server uses SQLite with the following tables:
- documents: All documentation pages with FTS5 index
- code_blocks: Code examples from documentation
- graphql_elements: Extracted GraphQL schema elements with FTS5 index
- metadata: Ingestion tracking
Performance
Based on benchmarks (run python3 tests/benchmark_performance.py):
- Startup Time: 0.87s (when data unchanged) | 3 - 5s (first run or files changed)
- Search Speed: 5.5ms average (FTS5 direct: 0.7ms)
- Document Retrieval: 8.2ms
- GraphQL Element Search: 3.4ms
- Database Size: Approximately 30 MB for 350 documents
- Indexed Content: 350 documents, 963 code blocks, 51 GraphQL elements
All performance targets exceeded: <5s startup โ, <100ms searches โ
Example Queries
| Query |
Tool |
Result |
| "How do I query products?" |
search_documentation |
Product query documentation |
| "Show me product query details" |
search_graphql_elements |
products query definition |
| "Complete checkout flow" |
get_tutorial |
Step-by-step checkout guide |
| "Cart mutation examples" |
search_examples |
Working GraphQL cart examples |
| "All B2B documentation" |
list_categories + search |
B2B schema documentation |
Development
Project Structure
magento-graphql-docs-mcp/
โโโ magento_graphql_docs_mcp/
โ โโโ __init__.py
โ โโโ config.py # Configuration
โ โโโ parser.py # Markdown + GraphQL parser
โ โโโ ingest.py # Database ingestion
โ โโโ server.py # MCP server with 8 tools
โโโ tests/
โ โโโ verify_parser.py # Parser verification
โ โโโ verify_db.py # Database verification
โ โโโ verify_server.py # Server verification
โโโ data/
โ โโโ (symlink to docs)
โโโ pyproject.toml
โโโ README.md
โโโ CLAUDE.md
Architecture
Markdown Files (350)
โ
Parser (frontmatter + content + GraphQL extraction)
โ
SQLite (documents + code_blocks + graphql_elements + FTS5)
โ
FastMCP Server (8 tools via STDIO)
โ
MCP Client (Claude, IDE, etc.)
Advantages
vs Web Scraping
- โ
Offline operation (no network required)
- โ
Fast startup (3 - 5s vs 30 - 60s)
- โ
Local control (works with custom docs)
- โ
No HTML parsing complexity
vs REST API MCP
- โ
Includes tutorials and guides (not just API specs)
- โ
Code examples searchable
- โ
Narrative content for learning
- โ
Tutorial workflows
Unique Features
- ๐ 350 documents indexed
- ๐ 8 specialized search tools
- ๐ก Tutorial support
- ๐ Code example search
- ๐ Related document discovery
- โก Fast FTS5 search
- ๐ฏ GraphQL-aware parsing
๐ ๏ธ Troubleshooting
Documentation Not Found Error
Error: FileNotFoundError: Documentation directory not found!
The server now provides a helpful error message showing all three setup methods.
Solutions:
- Verify the documentation repository is cloned:
git clone https://github.com/AdobeDocs/commerce-webapi.git
- Check the path is correct:
echo $MAGENTO_GRAPHQL_DOCS_PATH
ls -la $MAGENTO_GRAPHQL_DOCS_PATH
ls -la data/
- Set the correct path (choose one method):
export MAGENTO_GRAPHQL_DOCS_PATH="/path/to/commerce-webapi/src/pages/graphql"
cd magento-graphql-docs-mcp
ln -s /path/to/commerce-webapi/src/pages/graphql data
cd parent-directory
git clone https://github.com/AdobeDocs/commerce-webapi.git
- Verify the setup:
magento-graphql-docs-mcp
Server Won't Start
Error: ModuleNotFoundError: No module named 'magento_graphql_docs_mcp'
Solution: Install the package in development mode:
cd magento-graphql-docs-mcp
pip install -e .
Error: Server starts but immediately exits
Solution: Check Python version (requires 3.10+):
python3 --version
No Search Results
Issue: Search returns no results even though documentation exists
Solutions:
- Use shorter, simpler keywords:
- Check if database was created:
ls -la ~/.mcp/magento-graphql-docs/
- Verify data was indexed:
python3 tests/verify_db.py
- Re-index the database:
rm ~/.mcp/magento-graphql-docs/database.db
magento-graphql-docs-mcp
Database Errors
Error: sqlite3.OperationalError: database is locked
Solution: Another process is using the database:
lsof ~/.mcp/magento-graphql-docs/database.db
kill <PID>
rm ~/.mcp/magento-graphql-docs/database.db
magento-graphql-docs-mcp
Error: sqlite3.DatabaseError: database disk image is malformed
Solution: Database is corrupted, recreate it:
rm -rf ~/.mcp/magento-graphql-docs/
magento-graphql-docs-mcp
Slow Performance
Issue: First startup takes >10 seconds
Solution: This is normal! First run parses 350 files. Subsequent runs are <1s.
Issue: Every startup is slow
Solution: Documentation mtime is changing. Check:
cd /path/to/commerce-webapi
git status
git pull
Verification Failed
Issue: verify_server.py fails with connection errors
Solution:
pip install -e ".[dev]"
pip list | grep mcp
python3 tests/verify_parser.py
python3 tests/verify_db.py
python3 tests/verify_server.py
MCP Client Integration Issues
Issue: MCP client shows "Server not found" or "Connection failed"
Solutions:
- Verify command is correct:
which magento-graphql-docs-mcp
python3 -m magento_graphql_docs_mcp.server
- Check environment variables in MCP config:
{
"mcpServers": {
"magento-graphql-docs": {
"command": "magento-graphql-docs-mcp",
"env": {
"MAGENTO_GRAPHQL_DOCS_PATH": "/FULL/PATH/to/commerce-webapi/src/pages/graphql"
}
}
}
}
Important: Use absolute paths, not ~ or relative paths in MCP config.
- Check logs:
- Claude Desktop:
~/Library/Logs/Claude/ (macOS)
- Look for error messages related to the server
Getting Help
If you're still having issues:
- Run all verification scripts:
python3 tests/verify_parser.py
python3 tests/verify_db.py
python3 tests/verify_server.py
python3 tests/benchmark_performance.py
- Check your setup:
python3 --version
echo $MAGENTO_GRAPHQL_DOCS_PATH
ls -la $MAGENTO_GRAPHQL_DOCS_PATH | head -20
ls -la ~/.mcp/magento-graphql-docs/
pip show magento-graphql-docs-mcp
- Create a GitHub issue with the output of the above commands.
๐ License
MIT
๐ฅ Contributing
Contributions welcome! Please test all changes with verification scripts before submitting.
๐ค Support
For issues or questions:
- Run verification scripts to diagnose issues
- Check database location and permissions
- Verify documentation path is correct