Magento 2 MCP Server

Magento 2 MCP Server

site icon
2025.03.30 1
JavaScriptMagento 2 集成REST APIAI 助手交互开发效率数据库
Magento 2 MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器实现,专为 Magento 2 设计。它允许 AI 助手通过标准化接口与 Magento 商店进行交互。该服务器提供了 REST API 集成、安全认证处理、资源与工具处理等功能,适用于需要自动化操作 Magento 商店的场景。
View on GitHub

Overview

基本能力

产品定位

Magento 2 MCP Server 是一个为 Magento 2 设计的 MCP 服务器实现,旨在通过标准化接口实现 AI 助手与 Magento 商店的交互。

核心功能

  • REST API 与 Magento 2 的集成
  • 安全认证处理
  • 常见 Magento 操作的资源与工具处理
  • 基于 TypeScript 实现,确保类型安全
  • 基于官方 MCP SDK 构建

适用场景

  • 自动化操作 Magento 商店
  • AI 助手与 Magento 商店的交互
  • 开发与测试 Magento 相关功能

工具列表

  • magento_rest_api: 用于向 Magento 实例发起 REST API 调用。支持参数包括 path(API 端点路径)、method(HTTP 方法)、body(请求体,JSON 字符串)和 query(查询参数)。

常见问题解答

  • 安全注意事项: 不要提交 Magento 管理员令牌,使用环境变量存储敏感信息,保持 Node.js 和 npm 版本更新,定期更新依赖项。

使用教程

使用依赖

  • Node.js (v18 或更高版本)
  • npm (v8 或更高版本)
  • 具有 REST API 访问权限的 Magento 2 实例
  • Magento 的管理员 API 访问令牌

安装教程

npm install vasileuski/magento2-mcp-server

启动服务器

magento <magento_url> <admin_api_token>

示例:

magento https://your-magento-store.com eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...

与 MCP 客户端集成

在 MCP 客户端(如 Cursor)的配置中添加以下内容:

{
  "tools": [
    {
      "name": "mcp_magento_magento_rest_api",
      "command": "magento https://your-magento-store.com your-admin-api-token"
    }
  ]
}

调试方式

  1. 克隆仓库
  2. 安装依赖: npm install
  3. 启动开发服务器: npm run dev
  4. 进行更改
  5. 运行测试: npm test
  6. 构建生产版本: npm run build

许可证

该项目遵循 MIT 开源许可条款。