1 import { Note, Prerequisites, Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Medusa MCP`,
5 }
6
7 # {metadata.title}
8
9 In this guide, you'll learn how to connect AI tools like Claude, ChatGPT, and Cursor to your Cloud stores with the Medusa MCP server, and what they can do once connected.
10
11 ## What is the Medusa MCP Server?
12
13 The Medusa MCP server is a remote [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that gives AI tools access to the commerce data of your Medusa applications deployed on Cloud. MCP is an open standard that AI tools use to connect to external data and services.
14
15 Once you connect an AI tool to the Medusa MCP server, you can ask it questions about your stores in natural language, such as:
16
17 - "Show me the 5 most recent orders in my store, with each order's total and status."
18 - "How many orders are waiting to be fulfilled?"
19 - "What products are available to shoppers in my B2B sales channel?"
20
21 Your AI tool then retrieves the relevant data from your store and presents it to you in a human-readable format.
22
23 The Medusa MCP is available for all Cloud plans.
24
25 ---
26
27 ## Connect to the Medusa MCP Server
28
29 This section explains how to connect your AI tool to the Medusa MCP server.
30
31 ### Prerequisites
32
33 <Prerequisites
34 items={[
35 {
36 text: "Cloud account",
37 link: "/sign-up",
38 },
39 {
40 text: "Environment with a live deployment",
41 link: "/deployments/access",
42 },
43 {
44 text: "Medusa v2.12.4+ in the environment's Medusa application",
45 link: "https://github.com/medusajs/medusa/releases/tag/v2.12.4",
46 },
47 {
48 text: "Log in with Medusa Cloud enabled in the environment's Medusa Admin",
49 link: "/deployments/access#cant-find-the-log-in-with-medusa-cloud-button",
50 },
51 ]}
52 />
53
54 ### Step 1: Rebuild Environments
55
56 Medusa indexes an environment's API routes when the environment builds. Environments built on or after October 8, 2026 are already indexed, so you can skip to [connecting an AI tool](#step-2-connect-an-ai-tool).
57
58 If the environment's latest build is from before October 8, 2026, rebuild it so that Medusa indexes its API routes.
59
60 <Note type="warning">
61
62 You must start a new build of the environment. Redeploying an existing deployment reuses its previous build, so Medusa doesn't index the environment's API routes.
63
64 </Note>
65
66 To rebuild an environment:
67
68 1. If you're in a different organization, [switch to the organization](../organizations/page.mdx#switch-organization).
69 2. Click **Projects** in the sidebar and select the project that contains the environment.
70 3. Select the environment, then click **Trigger build** at the top right of the page.
71
72 You can also start a new build with the Cloud CLI's [`mcloud environments trigger-build`](../cli/commands/environments/page.mdx#environments-trigger-build) command.
73
74 Once the build finishes and the deployment is live, you can connect the environment to your AI tool.
75
76 ### Step 2: Connect an AI Tool
77
78 The Medusa MCP server is a Streamable HTTP server at the following URL:
79
80 ```text
81 https://cloud.medusajs.com/mcp
82 ```
83
84 The Medusa MCP server authenticates with OAuth, so you don't need to create an access key. When you connect, the AI tool opens a browser window where you log in to your Cloud account and [approve the connection](#approve-the-connection).
85
86 #### Claude
87
88 Add the [Claude Connector](./claude/page.mdx) from [Claude's connectors directory](https://claude.ai/directory/medusa).
89
90 #### Claude Code
91
92 Run the following command in your terminal:
93
94 ```bash
95 claude mcp add --transport http medusa-commerce \
96 https://cloud.medusajs.com/mcp
97 ```
98
99 Then, start Claude Code and run the `/mcp` command:
100
101 ```bash
102 claude
103 /mcp
104 ```
105
106 Select the `medusa-commerce` server and choose **Authenticate**.
107
108 #### ChatGPT
109
110 The [ChatGPT app](./chatgpt/page.mdx) is under review by OpenAI. In the meantime, add the Medusa MCP server as a custom plugin in ChatGPT's developer mode, as explained in the [ChatGPT app](./chatgpt/page.mdx#add-medusa-mcp-as-a-custom-plugin-in-chatgpt) guide.
111
112 #### Cursor
113
114 Add the following to your `.cursor/mcp.json` file or Cursor settings, as explained in the [Cursor documentation](https://cursor.com/docs/mcp):
115
116 ```json title=".cursor/mcp.json"
117 {
118 "mcpServers": {
119 "medusa-commerce": {
120 "url": "https://cloud.medusajs.com/mcp"
121 }
122 }
123 }
124 ```
125
126 Then, open **Settings** > **Tools & MCPs** and click **Connect** next to the `medusa-commerce` server.
127
128 #### VS Code
129
130 These steps also apply to GitHub Copilot in VS Code, since Copilot's agent mode uses the MCP servers that you configure in VS Code.
131
132 Add the following to the `.vscode/mcp.json` file in your workspace:
133
134 ```json title=".vscode/mcp.json"
135 {
136 "servers": {
137 "medusa-commerce": {
138 "type": "http",
139 "url": "https://cloud.medusajs.com/mcp"
140 }
141 }
142 }
143 ```
144
145 When you start the server, VS Code prompts you to log in to your Cloud account. Then, open the Copilot Chat view in agent mode to use the Medusa MCP server's tools.
146
147 #### Codex
148
149 Run the following commands in your terminal:
150
151 ```bash
152 codex mcp add medusa-commerce \
153 --url https://cloud.medusajs.com/mcp
154 codex mcp login medusa-commerce
155 ```
156
157 #### OpenCode
158
159 Add the following to your [OpenCode config file](https://opencode.ai/docs/config/), for example, `~/.config/opencode/opencode.json`:
160
161 ```json title="~/.config/opencode/opencode.json"
162 {
163 "$schema": "https://opencode.ai/config.json",
164 "mcp": {
165 "medusa-commerce": {
166 "type": "remote",
167 "url": "https://cloud.medusajs.com/mcp"
168 }
169 }
170 }
171 ```
172
173 Then, run the following command to log in to your Cloud account:
174
175 ```bash
176 opencode mcp auth medusa-commerce
177 ```
178
179 #### n8n
180
181 Add an **MCP Client Tool** to an **AI Agent** node in n8n Cloud, as explained in the [n8n](./n8n/page.mdx) guide. Self-hosted n8n instances can't connect to the Medusa MCP server.
182
183 #### Custom Agents
184
185 To connect an agent that you build yourself, follow the [Connect a Custom Agent](./custom-agents/page.mdx) guide.
186
187 #### Approve the Connection
188
189 After you log in to your Cloud account, Cloud shows a consent page with the AI tool's name and the access it requests.
190
191 1. Select the environments that the AI tool can access.
192 2. Click **Approve**.
193
194 <Note type="warning">
195
196 Only approve the connection if you started it yourself. Once approved, the AI tool can read data in the selected stores as you.
197
198 </Note>
199
200 Once you approve the connection, return to your AI tool and start asking questions about your stores.
201
202 ---
203
204 ## Manage Connected Stores
205
206 To connect more stores or remove stores from an AI tool, [change the connection's environments](../organizations/connections/page.mdx#change-accessible-environments) from your organization's **Connections** settings. Alternatively, re-authenticate the AI tool with the Medusa MCP server and select the environments again on the consent page.
207
208 To disconnect an AI tool, [revoke its connection](../organizations/connections/page.mdx#revoke-a-connection) from your organization's **Connections** settings, or remove the MCP server or connector from the AI tool.
209
210 ### Confirm Your Identity
211
212 If a store requires multi-factor authentication, the AI tool asks you to confirm your identity when it calls a [tool](#available-tools) that accesses the store's data, such as `read_admin_api`. Connecting the AI tool doesn't require this confirmation. The AI tool either opens a confirmation page in your browser or shows you its link.
213
214 After you confirm your identity, return to the AI tool and run the request again.
215
216 ---
217
218 ## Medusa MCP Features
219
220 - **Connect to environments**: Connect the AI tool to one or more environments across your organizations, and choose which ones it can access. When you connect multiple environments, mention the store you mean in your question.
221 - **Read store data**: Retrieve orders, products, customers, inventory, and other commerce data from your store's Admin API routes as your admin user. The AI tool can also retrieve storefront data, such as the products available in a sales channel, from your store's Store API routes as a guest customer.
222 - **Read custom store data**: Retrieve data from your store's custom `GET` API routes under the `/store` and `/admin` prefixes. Medusa indexes your store's API routes each time the environment builds, so the AI tool finds new custom routes after you deploy them.
223 - **Answer Medusa questions**: Search the Medusa documentation to answer general questions about Medusa.
224
225 ### Read-Only Access
226
227 The Medusa MCP server is read-only. The AI tool can retrieve data from your store's Admin and Store API routes, but it can't create, update, or delete data. For example, if you ask the AI tool to cancel an order, it explains that it can't and points you to the Medusa Admin.
228
229 The AI tool calls Store API routes as a guest customer, so it can't access routes that require a logged-in customer.
230
231 ---
232
233 ## Available Tools
234
235 The Medusa MCP server provides the following tools to AI tools. You don't call these tools directly. The AI tool chooses which tools to call based on your question.
236
237 <Table>
238 <Table.Header>
239 <Table.Row>
240 <Table.HeaderCell>
241 Tool
242 </Table.HeaderCell>
243 <Table.HeaderCell>
244 Description
245 </Table.HeaderCell>
246 </Table.Row>
247 </Table.Header>
248 <Table.Body>
249 <Table.Row>
250 <Table.Cell>
251
252 `list_connected_environments`
253
254 </Table.Cell>
255 <Table.Cell>
256 Lists the environments that you connected to the AI tool.
257 </Table.Cell>
258 </Table.Row>
259 <Table.Row>
260 <Table.Cell>
261
262 `find_commerce_api`
263
264 </Table.Cell>
265 <Table.Cell>
266 Searches a store's Admin and Store API routes, including its custom API routes, for routes that retrieve the requested data.
267 </Table.Cell>
268 </Table.Row>
269 <Table.Row>
270 <Table.Cell>
271
272 `describe_commerce_api`
273
274 </Table.Cell>
275 <Table.Cell>
276 Retrieves the parameters and details of a store's API route.
277 </Table.Cell>
278 </Table.Row>
279 <Table.Row>
280 <Table.Cell>
281
282 `read_admin_api`
283
284 </Table.Cell>
285 <Table.Cell>
286 Sends a `GET` request to a store's Admin API route as your admin user.
287 </Table.Cell>
288 </Table.Row>
289 <Table.Row>
290 <Table.Cell>
291
292 `list_medusa_publishable_keys`
293
294 </Table.Cell>
295 <Table.Cell>
296 Lists a store's publishable API keys and their sales channels.
297 </Table.Cell>
298 </Table.Row>
299 <Table.Row>
300 <Table.Cell>
301
302 `read_store_api`
303
304 </Table.Cell>
305 <Table.Cell>
306 Sends a `GET` request to a store's Store API route as a guest customer, scoped to a publishable API key's sales channels.
307 </Table.Cell>
308 </Table.Row>
309 <Table.Row>
310 <Table.Cell>
311
312 `ask_medusa_question`
313
314 </Table.Cell>
315 <Table.Cell>
316 Searches the Medusa documentation to answer a question.
317 </Table.Cell>
318 </Table.Row>
319 <Table.Row>
320 <Table.Cell>
321
322 `submit_medusa_feedback`
323
324 </Table.Cell>
325 <Table.Cell>
326 Sends your feedback to the Medusa team. The AI tool only sends feedback when you ask it to, or after you approve the message.
327 </Table.Cell>
328 </Table.Row>
329 </Table.Body>
330 </Table>
331
332 ### Custom API Routes
333
334 Medusa indexes a store's API routes, including its custom API routes, each time the environment builds. So, the AI tool can find and call your custom `GET` API routes after you deploy them.
335
336 Medusa only indexes custom API routes under the `/store` and `/admin` prefixes. The AI tool can't find or call custom API routes under other prefixes.
337
338 To learn how to create custom API routes that the AI tool can find and use, such as an API route that retrieves abandoned carts, refer to the [Retrieve Custom Data](./custom-data/page.mdx) guide.
339
340 ---
341
342 ## Medusa MCP vs Docs MCP
343
344 Medusa provides two MCP servers:
345
346 - The **Medusa MCP server**, at `https://cloud.medusajs.com/mcp`, reads data from your Cloud stores. It's the server this guide covers.
347 - The [Docs MCP server](!docs!/learn/introduction/build-with-llms-ai/docs-mcp-server), at `https://docs.medusajs.com/mcp`, answers development questions from the Medusa documentation and provides implementation guides.
348
349 The Medusa MCP server can also search the Medusa documentation, so you don't need both servers to ask general Medusa questions. If you're writing code for your Medusa application, use the Docs MCP server for its implementation guides.
350
351 ---
352
353 ## Troubleshooting
354
355 ### AI Tool Can't Find Your Store's API Routes
356
357 If the AI tool can't find your store's API routes, including your custom API routes, make sure that the environment's latest build is from October 8, 2026 or later. Otherwise, [rebuild the environment](#step-1-rebuild-environments). Redeploying an existing deployment doesn't index the environment's API routes.
358
359 {/* ### Permission Denied Errors
360
361 The AI tool can only access data that your admin user in the store has permission to access. If the AI tool shows a permission error, ask an admin of the store to update your admin user's permissions. */}
362
363 ### Store Login Errors
364
365 The Medusa MCP server logs in to your store with your Cloud account. If the AI tool shows an error that the store's Cloud login is disabled or misconfigured, make sure that:
366
367 - The store's Medusa application uses [Medusa v2.12.4](https://github.com/medusajs/medusa/releases/tag/v2.12.4) or later.
368 - The environment has a live deployment.
369 - You can log in to the store's Medusa Admin with the **Log in with Medusa Cloud** button, as explained in the [Access Deployment](../deployments/access/page.mdx#access-the-deployments-medusa-admin) guide.