magento-mcp-server

sprinixtech/magento-mcp-server

3.2

If you are the rightful owner of magento-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Sprinix_MageMCPServer is a Magento 2 module designed to expose REST and GraphQL APIs in an MCP-compatible format, facilitating integration with AI agents and autonomous tools.

Sprinix_MageMCPServer

A Magento 2 module to expose REST and GraphQL APIs in MCP-compatible format for use with AI agents like LangChain, OpenAI Assistants, and autonomous tools.


šŸ”§ What It Does

This module dynamically generates MCP-style tool metadata (as JSON schema) for all Magento REST endpoints. These metadata files can be consumed by:

  • LangChain agents
  • OpenAI Assistants API
  • RAG pipelines
  • Custom AI workflows

šŸš€ Features

  • āœ… REST API metadata via /mcp/metadata
  • āœ… Admin config for enable/disable and cache TTL
  • āœ… Cached metadata in var/ for speed
  • āœ… OpenAPI-style JSON at /mcp/metadata/openapi
  • āœ… LangChain & Assistant-API friendly output

šŸ› ļø Installation

composer require sprinixtech/magento-mcp-server
php bin/magento setup:upgrade
php bin/magento cache:flush

āš™ļø Admin Configuration

Navigate to:

Stores → Configuration → MCP Server

You can:

  • Enable/disable the MCP server
  • Set metadata cache lifetime (in seconds)

šŸ“± Available Endpoints

Endpoint URLDescription
/mcp/metadataMCP metadata for REST APIs
/mcp/metadata/graphqlMCP metadata for GraphQL queries/mutations
/mcp/metadata/openapiREST metadata in OpenAPI style

🧠 LangChain Usage Example (Node.js)

import { ChatOpenAI } from "langchain/chat_models/openai";
import { DynamicTool } from "langchain/tools";

const res = await fetch("https://your-magento.com/mcp/metadata/graphql");
const toolsJson = await res.json();

const tools = toolsJson.map(tool => new DynamicTool({
  name: tool.name,
  description: tool.description,
  func: async (input) => {
    const response = await fetch(tool.api.url, {
      method: tool.api.method,
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ query: `{ ${tool.name} { id name } }` })
    });
    return await response.text();
  }
}));

šŸ”® Future Enhancements

  • āœ… CLI command to flush cached metadata
  • 🧬 Argument and return type introspection
  • šŸ“Š Swagger UI for OpenAPI metadata
  • 🌐 Multi-store view support
  • šŸ” Auth/token integration

šŸ‘Øā€šŸ’» Author

Gulshan Maurya
šŸ“§ gulshan.4dream@gmail.com
šŸ”— LinkedIn


šŸ“„ License

MIT