Skip to content

Commit 4cbb360

Browse files
Merge pull request #3254 from SalesforceCommerceCloud/t/commerce/W-19545821/updateToolDescription
@W-19545821 - Refactoring parameter names
2 parents 083a542 + ad0f286 commit 4cbb360

File tree

7 files changed

+66
-24
lines changed

7 files changed

+66
-24
lines changed

packages/pwa-kit-mcp/src/server/server.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('PwaStorefrontMCPServerHighLevel integration', () => {
6060
expect(response.result).toHaveProperty('tools')
6161
// Check that at least the DeveloperGuidelinesTool is present
6262
const toolNames = response.result.tools.map((t) => t.name)
63-
expect(toolNames).toContain('development_guidelines')
63+
expect(toolNames).toContain('get_development_guidelines')
6464

6565
child.kill()
6666
}, 10000)

packages/pwa-kit-mcp/src/tools/create-app-guideline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ class CreateAppGuidelinesTool {
7272
name = 'create_storefront_app'
7373
description = `
7474
75-
This tool is used to provide the agent with the instructions on how to use the @salesforce/pwa-kit-create-app CLI tool to create a new PWA Kit projects.
75+
This tool is used to provide the agent with the instructions on how to use the @salesforce/pwa-kit-create-app CLI tool to create a new PWA Kit project.
7676
7777
Do not attempt to create a project without using this tool first.
7878
79-
Example Triggers:
79+
Example prompts:
8080
- "Create a new PWA Kit app"
8181
- "Start a new storefront using a preset"
8282
- "What templates are available for PWA Kit?"

packages/pwa-kit-mcp/src/tools/create-new-component.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ What is the main purpose of this component? Reply with exactly one of the follow
4343

4444
class CreateNewComponentTool {
4545
constructor() {
46-
this.name = 'create_sample_component'
46+
this.name = 'create_component'
4747
this.description =
4848
'Create a sample React component. Gather information from user for the MCP tool parameters **one at a time**, in a natural and conversational way. Do **not** ask all the questions at once.'
4949
this.inputSchema = {
50-
componentName: z.string().min(1, 'The name of the new Component to create?'),
50+
componentName: z.string().min(1, 'The name of the new component to create?'),
5151
purpose: z
5252
.string()
5353
.min(
5454
1,
55-
'The Purpose of the new component (e.g., Display a single Product, Display a list of Products or something else)'
55+
'The purpose of the new component (e.g., display a single Product, display a list of products or something else)'
5656
)
5757
.describe(systemPromptForComponentPurpose),
5858
location: z
5959
.string()
60-
.describe('The location of the component to be created')
60+
.describe('The location of the component to create')
6161
.default(process.env.PWA_STOREFRONT_APP_PATH)
6262
}
6363
this.handler = async (args) => {

packages/pwa-kit-mcp/src/tools/create-new-page-tool.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const systemPromptForCreatePage = `You are a smart assistant that can use tools
3232
- Is ccExtensibility.overridesDir set in your package.json? (true/false) \
3333
Collect answers to these questions, then call the tool with the collected information as input parameters.`
3434

35-
const systemPromptForProductHook = `User have added the ProductView component to the new page. Please ask user: \
35+
const systemPromptForProductHook = `User has added the ProductView component to the new page. Please ask user: \
3636
"To make it work, would you like to add the hook useProduct to your page?" \
37-
If user answers yes, please make sure do do following: \
37+
If user answers yes, please make sure to do following: \
3838
1. add the useProduct with ALL parameters following product-detail's useProduct as example, \
3939
2. update ProductView tag to pass product and isProductLoading as props, \
4040
3. in routes.jsx, update the path for the new page with '/:productId'. \
@@ -71,19 +71,19 @@ const systemPromptForUnfoundComponents = (unfoundComponents) =>
7171

7272
class CreateNewPageTool {
7373
constructor() {
74-
this.name = 'create_sample_page'
74+
this.name = 'create_page'
7575
this.description =
7676
'Create a sample PWA storefront page. Gather information from user for the MCP tool parameters **one at a time**, in a natural and conversational way. Do **not** ask all the questions at once.'
7777
this.inputSchema = {
78-
pageName: z.string().describe('The name of the new page to create?'),
78+
pageName: z.string().describe('The name of the new page to create'),
7979
componentList: z
8080
.array(z.string())
8181
.describe(
8282
'The existing components to include on the page, separated by commas. Component names should be in PascalCase (e.g., AddressDisplay, ProductView, Footer)'
8383
),
8484
route: z
8585
.string()
86-
.describe('The URL route for this page? (e.g., /new-home, /my-product-view)'),
86+
.describe('The URL route for this page (e.g., /new-home, /my-product-view)'),
8787
nodeModulesPath: z.string().describe('The absolute path to the node_modules directory'),
8888
componentsPath: z.string().describe('The absolute path to the components directory'),
8989
pagesPath: z.string().describe('The absolute path to the pages directory'),

packages/pwa-kit-mcp/src/tools/create-new-page-tool.test.js

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,17 @@ describe('CreateNewPageTool', () => {
117117
jest.spyOn(createNewPageTool, 'generatePageContent').mockResolvedValue(
118118
`const productId = '25592300M';\nexport default function Page() { return <div>{productId}</div>; }`
119119
)
120+
const internalPaths = {
121+
nodeModulesPath: '/mock/node_modules',
122+
componentsPath: '/mock/app/components',
123+
pagesPath: '/mock/app/pages',
124+
routesPath: '/mock/app/routes.jsx',
125+
hasOverridesDir: false
126+
}
120127
const pageContent = await createNewPageTool.generatePageContent(
121128
'Test',
122129
['ProductView'],
123-
mockAbsolutePaths
130+
internalPaths
124131
)
125132
expect(pageContent).toContain('25592300M')
126133
expect(pageContent).not.toMatch(/error|exception|fail/i)
@@ -131,10 +138,17 @@ describe('CreateNewPageTool', () => {
131138
jest.spyOn(createNewPageTool, 'generatePageContent').mockResolvedValue(
132139
`import Image from 'somewhere';\n${imageComponentString}`
133140
)
141+
const internalPaths = {
142+
nodeModulesPath: '/mock/node_modules',
143+
componentsPath: '/mock/app/components',
144+
pagesPath: '/mock/app/pages',
145+
routesPath: '/mock/app/routes.jsx',
146+
hasOverridesDir: false
147+
}
134148
const pageContent = await createNewPageTool.generatePageContent(
135149
'Test',
136150
['Image'],
137-
mockAbsolutePaths
151+
internalPaths
138152
)
139153
expect(pageContent).toContain('Image')
140154
expect(pageContent).toContain('static/img/hero.png')
@@ -146,10 +160,17 @@ describe('CreateNewPageTool', () => {
146160
`import Image from 'somewhere';\n${defaultImageString}`
147161
)
148162
// Simulate user says no to custom image (in real flow, this would be a follow-up, here we just check the generated content)
163+
const internalPaths = {
164+
nodeModulesPath: '/mock/node_modules',
165+
componentsPath: '/mock/app/components',
166+
pagesPath: '/mock/app/pages',
167+
routesPath: '/mock/app/routes.jsx',
168+
hasOverridesDir: false
169+
}
149170
const pageContent = await createNewPageTool.generatePageContent(
150171
'Test',
151172
['Image'],
152-
mockAbsolutePaths
173+
internalPaths
153174
)
154175
expect(pageContent).toContain('static/img/hero.png')
155176
expect(pageContent).not.toMatch(/https?:\/\//)
@@ -159,10 +180,17 @@ describe('CreateNewPageTool', () => {
159180
if (createNewPageTool.generatePageContent.mockRestore) {
160181
createNewPageTool.generatePageContent.mockRestore()
161182
}
183+
const internalPaths = {
184+
nodeModulesPath: '/mock/node_modules',
185+
componentsPath: '/mock/app/components',
186+
pagesPath: '/mock/app/pages',
187+
routesPath: '/mock/app/routes.jsx',
188+
hasOverridesDir: false
189+
}
162190
const pageContent = await createNewPageTool.generatePageContent(
163191
'Test',
164192
['Test'],
165-
mockAbsolutePaths
193+
internalPaths
166194
)
167195
expect(pageContent).toContain('import TestComponent from')
168196
expect(pageContent).toContain('<TestComponent />')
@@ -213,10 +241,17 @@ describe('CreateNewPageTool', () => {
213241
imgSrc: ["'self'", "https://edge.disstg.commercecloud.salesforce.com"]
214242
}
215243
}`
244+
const internalPaths = {
245+
nodeModulesPath: '/mock/node_modules',
246+
componentsPath: '/mock/app/components',
247+
pagesPath: '/mock/app/pages',
248+
routesPath: '/mock/app/routes.jsx',
249+
hasOverridesDir: false
250+
}
216251
const pageContent = await createNewPageTool.generatePageContent(
217252
'Test',
218253
['Image'],
219-
mockAbsolutePaths
254+
internalPaths
220255
)
221256
expect(pageContent).toContain(customSrc)
222257
expect(ssrContent).toContain('.commercecloud.salesforce.com')
@@ -239,10 +274,17 @@ describe('CreateNewPageTool', () => {
239274
imgSrc: ["'self'", "https://some-other-domain.com"]
240275
}
241276
}`
277+
const internalPaths = {
278+
nodeModulesPath: '/mock/node_modules',
279+
componentsPath: '/mock/app/components',
280+
pagesPath: '/mock/app/pages',
281+
routesPath: '/mock/app/routes.jsx',
282+
hasOverridesDir: false
283+
}
242284
const pageContent = await createNewPageTool.generatePageContent(
243285
'Test',
244286
['Image'],
245-
mockAbsolutePaths
287+
internalPaths
246288
)
247289
const isAllowed = ssrContent.includes('.commercecloud.salesforce.com')
248290
expect(isAllowed).toBe(false)

packages/pwa-kit-mcp/src/tools/developer-guideline.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ This document offers guidelines in the development of Salesforce Commerce Compos
106106
`
107107

108108
export default {
109-
name: 'development_guidelines',
110-
description: `You must follow this development guidelines before attempting to analyze/ generate / refactor / modify / fix code.
111-
- e.g. "Create a customer service Chat component", "Find bugs in my_script.jsx", "Refactor my_script.jsx to use React Hooks"`,
109+
name: 'get_development_guidelines',
110+
description: `You must follow the PWA Kit development guidelines before attempting to analyze, generate, refactor, modify, or fix code.
111+
Example prompts: "Create a customer service Chat component", "Find bugs in my_script.jsx", and "Refactor my_script.jsx to use React Hooks".`,
112112
inputSchema: EmptyJsonSchema,
113113
fn: async () => ({
114114
content: [{type: 'text', text: guidelinesText}]

packages/pwa-kit-mcp/src/tools/developer-guideline.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ describe('PWA Development Guidelines', () => {
1111
describe('DeveloperGuidelinesTool', () => {
1212
it('should have correct structure', () => {
1313
expect(DeveloperGuidelinesTool).toMatchObject({
14-
name: 'development_guidelines',
15-
description: `You must follow this development guidelines before attempting to analyze/ generate / refactor / modify / fix code.
16-
- e.g. "Create a customer service Chat component", "Find bugs in my_script.jsx", "Refactor my_script.jsx to use React Hooks"`,
14+
name: 'get_development_guidelines',
15+
description: `You must follow the PWA Kit development guidelines before attempting to analyze, generate, refactor, modify, or fix code.
16+
Example prompts: "Create a customer service Chat component", "Find bugs in my_script.jsx", and "Refactor my_script.jsx to use React Hooks".`,
1717
inputSchema: EmptyJsonSchema,
1818
fn: expect.any(Function)
1919
})

0 commit comments

Comments
 (0)