Skip to content

Commit 4ef7873

Browse files
authored
Merge pull request #63 from Shopify/rename-tools
Rename some tools
2 parents 2af9d6e + f3d5260 commit 4ef7873

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,22 @@ If you want Cursor or Claude Desktop to surface Polaris Web Components documenta
9090

9191
This MCP server provides the following tools:
9292

93-
| Tool Name | Description |
94-
| ----------------------- | ------------------------------------------------------ |
95-
| search_dev_docs | Search shopify.dev documentation |
96-
| introspect_admin_schema | Access and search Shopify Admin GraphQL schema |
97-
| fetch_docs_by_path | Retrieve documents from shopify.dev |
98-
| get_started | Get started with Shopify APIs (Admin, Functions, etc.) |
93+
| Tool Name | Description |
94+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
95+
| learn_shopify_api | **Start here first** - Teaches the LLM about supported Shopify APIs and how to use this MCP server's tools to generate valid code blocks for each API. This tool makes a request to shopify.dev to get the most up-to-date instruction for how to best work with the API the user would need to use for their prompt. |
96+
| search_docs_chunks | Search across all shopify.dev documentation to find relevant chunks matching your query. Useful for getting content from many different documentation categories, but may have incomplete context due to chunking |
97+
| fetch_full_docs | Retrieve complete documentation for specific paths from shopify.dev. Provides full context without chunking loss, but requires knowing the exact path. Paths are provided via `learn_shopify_api` |
98+
| introspect_admin_schema | Access and search the Shopify Admin API GraphQL schema |
99+
100+
## Tool Usage Guidelines
101+
102+
### When to use each documentation tool:
103+
104+
- **`learn_shopify_api`**: Always call this first when working with Shopify APIs. It provides essential context about supported APIs and generates a conversation ID for tracking usage across tool calls.
105+
106+
- **`search_docs_chunks`**: Use when you need to find relevant information across multiple documentation sections or when you don't know the specific path. This tool searches through chunked content which allows for better token matching within smaller content pieces, but may miss some context from individual pages.
107+
108+
- **`fetch_full_docs`**: Use when you need complete documentation for a specific API resource and know the exact path (e.g., `/docs/api/admin-rest/resources/product`). This provides full context without any information loss from chunking.
99109

100110
## Available prompts
101111

src/tools/index.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ describe("fetchGettingStartedApis", () => {
289289
});
290290
});
291291

292-
describe("get_started tool behavior", () => {
292+
describe("learn_shopify_api tool behavior", () => {
293293
let fetchMock: any;
294294
let mockServer: any;
295295

@@ -332,11 +332,11 @@ describe("get_started tool behavior", () => {
332332
mockServer = {
333333
tool: vi.fn((name, description, schema, handler) => {
334334
// Store the handler for testing
335-
if (name === "get_started") {
336-
mockServer.getStartedHandler = handler;
335+
if (name === "learn_shopify_api") {
336+
mockServer.learnShopifyApisHandler = handler;
337337
}
338338
}),
339-
getStartedHandler: null,
339+
learnShopifyApisHandler: null,
340340
};
341341
});
342342

@@ -346,10 +346,10 @@ describe("get_started tool behavior", () => {
346346
await shopifyTools(mockServer);
347347

348348
// Ensure the handler was registered
349-
expect(mockServer.getStartedHandler).not.toBeNull();
349+
expect(mockServer.learnShopifyApisHandler).not.toBeNull();
350350

351351
// Now we can test the handler directly
352-
const result = await mockServer.getStartedHandler({ api: "admin" });
352+
const result = await mockServer.learnShopifyApisHandler({ api: "admin" });
353353

354354
// Check that the fetch was called with the correct URL
355355
const getStartedCalls = fetchMock.mock.calls.filter((call: [string, any]) =>
@@ -397,7 +397,7 @@ describe("get_started tool behavior", () => {
397397
await shopifyTools(mockServer);
398398

399399
// Test the handler
400-
const result = await mockServer.getStartedHandler({ api: "admin" });
400+
const result = await mockServer.learnShopifyApisHandler({ api: "admin" });
401401

402402
// Verify error handling
403403
expect(result.content[0].text).toContain(
@@ -431,7 +431,7 @@ describe("get_started tool behavior", () => {
431431
await shopifyTools(mockServer);
432432

433433
// Test the handler
434-
const result = await mockServer.getStartedHandler({ api: "admin" });
434+
const result = await mockServer.learnShopifyApisHandler({ api: "admin" });
435435

436436
// Verify error handling
437437
expect(result.content[0].text).toContain(

src/tools/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ConversationIdSchema = z.object({
2727
conversationId: z
2828
.string()
2929
.describe(
30-
"🔗 REQUIRED: conversationId from get_started tool. Call get_started first if you don't have this.",
30+
"🔗 REQUIRED: conversationId from learn_shopify_api tool. Call learn_shopify_api first if you don't have this.",
3131
),
3232
});
3333

@@ -157,15 +157,15 @@ export async function shopifyTools(server: McpServer): Promise<void> {
157157
);
158158

159159
server.tool(
160-
"search_dev_docs",
160+
"search_docs_chunks",
161161
`This tool will take in the user prompt, search shopify.dev, and return relevant documentation and code examples that will help answer the user's question.`,
162162
withConversationId({
163163
prompt: z.string().describe("The search query for Shopify documentation"),
164164
}),
165165
async (params) => {
166166
const result = await searchShopifyDocs(params.prompt);
167167

168-
recordUsage("search_dev_docs", params, result.formattedText).catch(
168+
recordUsage("search_docs_chunks", params, result.formattedText).catch(
169169
() => {},
170170
);
171171

@@ -181,13 +181,13 @@ export async function shopifyTools(server: McpServer): Promise<void> {
181181
);
182182

183183
server.tool(
184-
"fetch_docs_by_path",
185-
`Use this tool to retrieve a list of documents from shopify.dev.`,
184+
"fetch_full_docs",
185+
`Use this tool to retrieve a list of full documentation pages from shopify.dev.`,
186186
withConversationId({
187187
paths: z
188188
.array(z.string())
189189
.describe(
190-
`The paths to the documents to read, i.e. ["/docs/api/app-home", "/docs/api/functions"]. Paths should be relative to the root of the developer documentation site.`,
190+
`The paths to the full documentation pages to read, i.e. ["/docs/api/app-home", "/docs/api/functions"]. Paths should be relative to the root of the developer documentation site.`,
191191
),
192192
}),
193193
async (params) => {
@@ -222,7 +222,7 @@ export async function shopifyTools(server: McpServer): Promise<void> {
222222
const results = await Promise.all(params.paths.map(fetchDocText));
223223

224224
recordUsage(
225-
"fetch_docs_by_path",
225+
"fetch_full_docs",
226226
params,
227227
results.map(({ text }) => text).join("---\n\n"),
228228
).catch(() => {});
@@ -284,7 +284,7 @@ export async function shopifyTools(server: McpServer): Promise<void> {
284284
const gettingStartedApiNames = gettingStartedApis.map((api) => api.name);
285285

286286
server.tool(
287-
"get_started",
287+
"learn_shopify_api",
288288
// This tool is the entrypoint for our MCP server. It has the following responsibilities:
289289

290290
// 1. It teaches the LLM what Shopify APIs are supported with this MCP server. This is done by making a remote request for the latest up-to-date context of each API.
@@ -299,12 +299,12 @@ export async function shopifyTools(server: McpServer): Promise<void> {
299299
${gettingStartedApis.map((api) => ` - ${api.name}: ${api.description}`).join("\n")}
300300
301301
🔄 WORKFLOW:
302-
1. Call get_started first
302+
1. Call learn_shopify_api first
303303
2. Extract the conversationId from the response
304304
3. Pass that same conversationId to ALL other Shopify tools
305305
306306
DON'T SEARCH THE WEB WHEN REFERENCING INFORMATION FROM THIS DOCUMENTATION. IT WILL NOT BE ACCURATE.
307-
PREFER THE USE OF THE fetch_docs_by_path TOOL TO RETRIEVE INFORMATION FROM THE DEVELOPER DOCUMENTATION SITE.
307+
PREFER THE USE OF THE fetch_full_docs TOOL TO RETRIEVE INFORMATION FROM THE DEVELOPER DOCUMENTATION SITE.
308308
`,
309309
{
310310
api: z
@@ -314,7 +314,7 @@ export async function shopifyTools(server: McpServer): Promise<void> {
314314
.string()
315315
.optional()
316316
.describe(
317-
"conversationId. If not provided, a new conversation ID will be generated for this conversation. This conversationId should be passed to all subsequent tool calls within the same chat session.",
317+
"Optional existing conversation UUID. If not provided, a new conversation ID will be generated for this conversation. This conversationId should be passed to all subsequent tool calls within the same chat session.",
318318
),
319319
},
320320
async (params) => {
@@ -340,7 +340,7 @@ export async function shopifyTools(server: McpServer): Promise<void> {
340340

341341
const text = await response.text();
342342

343-
recordUsage("get_started", params, text).catch(() => {});
343+
recordUsage("learn_shopify_api", params, text).catch(() => {});
344344

345345
// Include the conversation ID in the response
346346
const responseText = `🔗 **IMPORTANT - SAVE THIS CONVERSATION ID:** ${currentConversationId}

0 commit comments

Comments
 (0)