magento-api-mcp

magento-api-mcp

Enables searching and retrieving Magento 2 REST API documentation offline via local OpenAPI parsing, supporting endpoint search, schema lookup, and category browsing.

Category
访问服务器

README

Magento 2 REST API MCP Server

A local STDIO MCP server that provides tools to search and retrieve Magento 2 REST API documentation from OpenAPI (swagger) specifications.

Features

  • Search Endpoints: Full-text search across all Magento 2 REST API endpoints
  • Get Endpoint Details: Retrieve complete documentation for specific API endpoints
  • List Categories: Browse endpoints by category tags (carts, customers, products, etc.)
  • Search Schemas: Find data models and schema definitions
  • Get Schema Details: View complete schema/model definitions with all properties
  • Offline Operation: Works entirely offline using local swagger.json file
  • Fast Startup: Only re-parses if swagger.json has been modified

How it Works

  1. Parsing: On startup, the server parses the OpenAPI 3.0 swagger.json file
  2. Indexing: Extracts endpoints, parameters, responses, and schemas
  3. Storage: Stores data in a local SQLite database with FTS5 indexes
  4. Searching: Provides full-text search across paths, descriptions, parameters, and schemas

Installation

Requirements

  • Python 3.10 or higher
  • uv (recommended) or pip

Install from Source

cd magento-api-mcp
pip install -e .

Usage

Running the Server

magento-api-mcp

The server starts immediately and parses the swagger.json file on first run or when the file has been modified.

Configuration

  • Database Location: Default is ~/.mcp/magento-api/database.db
    • Override with MAGENTO_API_DB_PATH environment variable
  • Swagger File: Default is data/swagger.json in the package directory
    • Override with MAGENTO_API_SWAGGER_PATH environment variable

Using with an MCP Client

Configure your MCP client to run the magento-api-mcp command:

{
  "mcpServers": {
    "magento-api": {
      "command": "magento-api-mcp"
    }
  }
}

Or with custom swagger file:

{
  "mcpServers": {
    "magento-api": {
      "command": "magento-api-mcp",
      "env": {
        "MAGENTO_API_SWAGGER_PATH": "/path/to/your/swagger.json"
      }
    }
  }
}

MCP Tools

1. search_endpoints

Search for API endpoints using keywords.

Parameters:

  • queries: List of 1-3 short keyword queries (e.g., ["cart", "customer"])
  • filter_by_method: Optional HTTP method filter (GET, POST, PUT, DELETE)
  • filter_by_tag: Optional category filter (e.g., "carts/mine")

Example:

search_endpoints(queries=["cart operations"], filter_by_method="GET")

2. get_endpoint_details

Get complete documentation for a specific endpoint.

Parameters:

  • path: Exact API path (e.g., "/V1/carts/mine")
  • method: Optional HTTP method (if omitted, returns all methods for this path)

Example:

get_endpoint_details(path="/V1/carts/mine", method="GET")

Returns:

  • HTTP method and path
  • Category and operation ID
  • Summary and description
  • Parameters table with types and descriptions
  • Request body schema (if applicable)
  • Response codes and schemas

3. list_tags

List all available API category tags.

Returns: Hierarchical list of all endpoint categories with counts.

4. search_schemas

Search for data schemas/models by keyword.

Parameters:

  • query: Keyword to search for

Example:

search_schemas(query="customer")

5. get_schema

Get complete definition of a schema/model.

Parameters:

  • schema_name: Exact schema name (e.g., "quote-data-cart-interface")

Returns: Full schema with type, description, and all properties in JSON format.

Verification Scripts

Test each component independently:

# Test the OpenAPI parser
python3 tests/verify_parser.py

# Test database ingestion
python3 tests/verify_db.py

# Test MCP server and all tools
python3 tests/verify_server.py

Database Schema

The server uses SQLite with the following tables:

  • endpoints: All API endpoints with FTS5 index
  • parameters: Endpoint parameters
  • responses: Response definitions
  • schemas: Data model definitions with FTS5 index
  • metadata: Ingestion tracking

Advantages Over Web Scraping

  1. No Network Dependency: Works completely offline
  2. Instant Startup: ~2-5 seconds vs minutes of web scraping
  3. Structured Data: Access to complete OpenAPI metadata
  4. Precise Search: Filter by method, category, response code
  5. Schema Resolution: Navigate complex nested data structures
  6. Deterministic: No HTML parsing or website structure changes

Example Queries

Query Tool Purpose
["cart"] search_endpoints Find all cart-related endpoints
["customer", "authentication"] search_endpoints Find customer auth endpoints
/V1/carts/mine get_endpoint_details Get complete cart endpoint docs
customer search_schemas Find customer-related schemas
quote-data-cart-interface get_schema View cart data structure

Development

Project Structure

magento-api-mcp/
├── magento_api_mcp/
│   ├── __init__.py
│   ├── config.py          # Configuration
│   ├── parser.py          # OpenAPI parser
│   ├── ingest.py          # Database ingestion
│   └── server.py          # MCP server with tools
├── tests/
│   ├── verify_parser.py   # Parser verification
│   ├── verify_db.py       # Database verification
│   └── verify_server.py   # Server verification
├── data/
│   └── swagger.json       # OpenAPI specification
├── pyproject.toml
└── README.md

Adding New Tools

To add new MCP tools, edit magento_api_mcp/server.py and use the @mcp.tool() decorator.

Using Different Swagger Files

The server can work with any OpenAPI 3.0 swagger file. Simply set the MAGENTO_API_SWAGGER_PATH environment variable:

export MAGENTO_API_SWAGGER_PATH=/path/to/different-api-swagger.json
magento-api-mcp

License

MIT

Contributing

Contributions welcome! Please test all changes with the verification scripts before submitting.

Support

For issues or questions, please check:

  1. Run verification scripts to diagnose issues
  2. Check database location and permissions
  3. Verify swagger.json is valid OpenAPI 3.0 format

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选