[!IMPORTANT]
Important Note: Commerce MCP is provided free of charge as an early access service. Our Service Level Agreement do not apply to Commerce MCP, and it is provided on an "as-is" basis.
commercetools MCP Essentials
This repository contains both a MCP server (which you can integrate with many MCP clients) and agent essentials that can be used from within agent frameworks.
commercetools Model Context Protocol
Setup
To run the commercetools MCP server using npx, use the following command:
# To set up all available tools
npx -y @commercetools/mcp-essentials --tools=all --clientId=CLIENT_ID --clientSecret=CLIENT_SECRET --projectKey=PROJECT_KEY --authUrl=AUTH_URL --apiUrl=API_URL
# To set up all read-only tools
npx -y @commercetools/mcp-essentials --tools=all.read --clientId=CLIENT_ID --clientSecret=CLIENT_SECRET --projectKey=PROJECT_KEY --authUrl=AUTH_URL --apiUrl=API_URL
# To set up specific tools
npx -y @commercetools/mcp-essentials --tools=products.read,products.create --clientId=CLIENT_ID --clientSecret=CLIENT_SECRET --projectKey=PROJECT_KEY --authUrl=AUTH_URL --apiUrl=API_URL
Make sure to replace CLIENT_ID
, CLIENT_SECRET
, PROJECT_KEY
, AUTH_URL
, and API_URL
with your actual values. If using the customerId parameter, replace CUSTOMER_ID
with the actual customer ID. Alternatively, you could set the API_KEY in your environment variables.
Usage with Claude Desktop
Add the following to your claude_desktop_config.json
. See here for more details.
{
"mcpServers": {
"commercetools": {
"command": "npx",
"args": [
"-y",
"@commercetools/mcp-essentials@latest",
"--tools=all",
"--clientId=CLIENT_ID",
"--clientSecret=CLIENT_SECRET",
"--authUrl=AUTH_URL",
"--projectKey=PROJECT_KEY",
"--apiUrl=API_URL"
]
}
}
}
Alternative: To use only read-only tools, replace "--tools=all"
with "--tools=all.read"
Available tools
Special Tool Options
Tool | Description |
---|---|
all | Enable all available tools (read, create, and update operations) |
all.read | Enable all read-only tools (safe for read-only access) |
Individual Tools
To view information on how to develop the MCP server, see this README.
MCP Essentials
The commercetools MCP Essentials enables popular agent frameworks including LangChain, Vercel's AI SDK, and Model Context Protocol (MCP) to integrate with APIs through function calling. The library is not exhaustive of the entire commercetools API. It includes support for TypeScript and is built directly on top of the [Node][node-sdk] SDK.
Included below are basic instructions, but refer to the TypeScript package for more information.
TypeScript
Installation
You don't need this source code unless you want to modify the package. If you just want to use the package run:
npm install @commercetools/agent-essentials
Requirements
- Node 18+
Usage
The library needs to be configured with your commercetools project API client credentials which is available in your Merchant center.
Important: Ensure that the API client credentials have the necessary scopes aligned with the actions you configure in the agent essentials. For example, if you configure products: { read: true }
, your API client must have the view_products
scope.
Additionally, configuration
enables you to specify the types of actions that can be taken using the agent essentials.
import { CommercetoolsAgentEssentials } from "@commercetools/agent-essentials/langchain";
const commercetoolsAgentEssentials = new CommercetoolsAgentEssentials({
clientId: process.env.CLIENT_ID!,
clientSecret: process.env.CLIENT_SECRET!,
projectKey: process.env.PROJECT_KEY!,
authUrl: process.env.AUTH_URL!,
apiUrl: process.env.API_URL!,
configuration: {
actions: {
products: {
read: true,
create: true,
update: true,
},
project: {
read: true,
},
},
},
});
Tools
The agent essentials work with LangChain and Vercel's AI SDK and can be passed as a list of tools. For example:
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";
const tools = commercetoolsAgentEssentials.getTools();
const agent = await createStructuredChatAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
});
Model Context Protocol
The commercetools MCP Essentials also supports setting up your own MCP server. For example:
import { CommercetoolsAgentEssentials } from "@commercetools/agent-essentials/modelcontextprotocol";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new CommercetoolsAgentEssentials({
clientId: process.env.CLIENT_ID!,
clientSecret: process.env.CLIENT_SECRET!,
projectKey: process.env.PROJECT_KEY!,
authUrl: process.env.AUTH_URL!,
apiUrl: process.env.API_URL!,
configuration: {
actions: {
products: {
read: true,
},
cart: {
read: true,
create: true,
update: true,
},
},
},
});
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("My custom commercetools MCP Server running on stdio");
}
main().catch((error) => {
console.error("Fatal error in main():", error);
process.exit(1);
});
getTools()
Returns the current set of available tools that can be used with LangChain, AI SDK, or other agent frameworks:
const tools = commercetoolsAgentEssentials.getTools();