Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/pwa-storefront-mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## v1.0.0-dev.0 (Jun 26, 2025)
- Add `pwa-kit-create-app` guideline tool [#2663](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2663)
1 change: 1 addition & 0 deletions packages/pwa-storefront-mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"@babel/runtime": "^7.21.0",
"@modelcontextprotocol/sdk": "^1.0.0",
"@salesforce/pwa-kit-create-app": "3.11.0-dev.0",
"zod": "^3.25.56"
},
"devDependencies": {
Expand Down
12 changes: 10 additions & 2 deletions packages/pwa-storefront-mcp/src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {CreateNewComponentTool} from '../utils/CreateNewComponentTool.js'
import fs from 'fs/promises'
import path from 'path'
import {fileURLToPath} from 'url'
import {DeveloperGuidelinesTool} from '../utils/pwa-developer-guideline-tool.js'

import {CreateProjectTool, DeveloperGuidelinesTool} from '../utils/index.js'
class PwaStorefrontMCPServerHighLevel {
constructor() {
// Using McpServer instead of Server
Expand All @@ -38,6 +37,15 @@ class PwaStorefrontMCPServerHighLevel {
}

setupTools() {

// Register CreateProjectTool
this.server.tool(
CreateProjectTool.name,
CreateProjectTool.description,
CreateProjectTool.inputSchema,
CreateProjectTool.fn
)

// Register DeveloperGuidelinesTool
this.server.tool(
DeveloperGuidelinesTool.name,
Expand Down
10 changes: 10 additions & 0 deletions packages/pwa-storefront-mcp/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2025, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import CreateProjectTool from './pwa-create-app-guideline-tool.js'
import DeveloperGuidelinesTool from './pwa-developer-guideline-tool.js'

export {CreateProjectTool, DeveloperGuidelinesTool}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2025, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
// First party dependencies
import CREATE_APP_SCHEMA from '@salesforce/pwa-kit-create-app/program.json' assert { type: 'json' }

// Project dependencies
import {EmptyJsonSchema} from './utils.js'


const guidelinesDescription = `
# PWA Kit Create App — Agent Usage Guidelines

## Overview

This document defines the behavior agents must follow when using the \`@salesforce/pwa-kit-create-app\` CLI tool to generate new PWA Kit projects. The CLI supports both **presets** and **templates** for project creation, and agents must clearly distinguish between these two modes of operation.
Copy link
Contributor

@yhsieh1 yhsieh1 Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have a section explains presets and templates options? So that agent knows the difference if asked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent in fact already knows that because it has imported program.json from the create-app package itself which has all the schema's and data for presets and templates.

I did this so that the information defined by the create-app project stays co-located with that project and not in ours where it can become out-of-sync. This way if some we add a feature by means of new template type or preset, or argument to the create app project, the mcp will ingest that information without having to make a change to the tool.


---

## General Rules

- Always use this tool to initiate project creation. Never attempt to manually create a project outside of this process.
- Ask one question at a time when gathering information from the user.
- Do not mix presets and templates. Only show or ask about one based on the user's intent.
- Never proceed with project generation unless all required information has been collected.

---

## Creating a Project Using a Preset

If the user requests a project using a **preset**:

- List only the available presets.
- If a preset is provided, use the \`--preset\` flag with the CLI.
- Do not ask for or display any template options.

---

## Creating a Project Using a Template

If the user requests a project using a **template**:

- List only the available templates.
- If a template is provided:
- Use its associated questions to prompt the user, one at a time.
- Do not proceed with project generation until all required answers have been collected.
- Do not ask for or display any preset options.

---

## Important Reminders

- Never attempt to create a project without using this tool.
- When gathering answers for a template, ask questions one at a time to maintain clarity.
- Presets and templates are mutually exclusive paths. Do not offer both options unless explicitly requested.
`

export default {
name: 'create-app_guidelines',
description: guidelinesText,
description: `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. Do not attempt to create a project without using this tool first.`,
inputSchema: EmptyJsonSchema,
fn: async () => ({
content: [
{
type: 'text',
text: JSON.stringify(
{
guidelines: guidelinesText,
cli: CREATE_APP_SCHEMA.metadata.description,
schemas: {...CREATE_APP_SCHEMA.schemas},
data: {...CREATE_APP_SCHEMA.data}
},
null,
2
)}
]
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ This document offers guidelines in the development of Salesforce Commerce Compos
- Follow security best practices for all code.
`

export const DeveloperGuidelinesTool = {
export default {
name: 'development_guidelines',
description: `You must follow this development guidelines before attempting to analyze/ generate / refactor / modify / fix code.
- e.g. "Create a customer service Chat component", "Find bugs in my_script.jsx", "Refactor my_script.jsx to use React Hooks"`,
Expand Down
Loading