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.
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
- ✅ 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
composer require sprinixtech/magento-mcp-server
php bin/magento setup:upgrade
php bin/magento cache:flush
Navigate to:
Stores → Configuration → MCP Server
You can:
- Enable/disable the MCP server
- Set metadata cache lifetime (in seconds)
Endpoint URL | Description |
---|---|
/mcp/metadata |
MCP metadata for REST APIs |
/mcp/metadata/graphql |
MCP metadata for GraphQL queries/mutations |
/mcp/metadata/openapi |
REST metadata in OpenAPI style |
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();
}
}));
- ✅ CLI command to flush cached metadata
- 🧬 Argument and return type introspection
- 📊 Swagger UI for OpenAPI metadata
- 🌐 Multi-store view support
- 🔐 Auth/token integration
Gulshan Maurya
📧 [email protected]
🔗 LinkedIn
MIT