Skip to content

Commit 0099bec

Browse files
committed
Sync the mcp package with develop branch
1 parent 32b104c commit 0099bec

File tree

10 files changed

+382
-264
lines changed

10 files changed

+382
-264
lines changed

packages/pwa-kit-mcp/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## v0.2.0 (Sep 4, 2025)
2+
- Normalize tool names; Add introduction section for PWA Kit MCP and resize the images on README. [#3239](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3239)
23

34
## v0.1.1 (Aug 11, 2025)
45
- Add missing `shelljs` dependency. [#3053](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3053)

packages/pwa-kit-mcp/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@ It allows AI agents to query context-aware services like this server to help dev
1212
👉 **[Read more at modelcontextprotocol.io](https://modelcontextprotocol.io/)**
1313

1414

15+
## What is PWA-Kit-MCP?
16+
17+
PWA-Kit-MCP is a local STDIO MCP Server that communicates via STDIO and operates in conjunction with a running local process, making it a fully locally installed MCP server. It provides an initial suite of MCP tools intended to standardize and optimize the developer workflow for PWA Kit storefront development. These tools facilitate project creation, supply development guidelines, enable the generation of new components and pages, and support site validation through performance and accessibility testing.
18+
19+
1520
## 🧰 Features
1621

1722
The PWA Kit MCP Server offers the following intelligent tools tailored to Salesforce Commerce Cloud PWA development:
1823

19-
* **`create_app_guidelines`**:
24+
* **`create_storefront_app`**:
2025
Guides agents and developers through creating a new PWA Kit project with `@salesforce/pwa-kit-create-app`.
2126

22-
* **`create_new_sample_component`**:
27+
* **`create_sample_component`**:
2328
Walks developers through a brief Q\&A to scaffold a component using the commerce data model, layout, and structure.
2429

25-
* **`create_sample_storefront_page`**:
30+
* **`create_sample_page`**:
2631
Interactive tool to generate a new PWA storefront page with custom routing and components.
2732

2833
* **`development_guidelines`**:
@@ -32,10 +37,6 @@ The PWA Kit MCP Server offers the following intelligent tools tailored to Salesf
3237
Runs performance and accessibility audits on a provided site URL.
3338
*Example: `https://pwa-kit.mobify-storefront.com`*
3439

35-
* **`git_version_control`**:
36-
Manages the version control of your project using git.
37-
If the project is not already a git repo, project files will be committed as a new local git repo together with a basic .gitignore. If the project is already a git repo, just commit the changes in the project.
38-
3940

4041
## ▶️ Running the MCP Server
4142

@@ -44,10 +45,10 @@ The PWA Kit MCP Server offers the following intelligent tools tailored to Salesf
4445
1. Open **Cursor**.
4546

4647
2. Navigate to **Settings > Cursor Settings...**
47-
![](https://raw.githubusercontent.com/SalesforceCommerceCloud/pwa-kit/refs/heads/develop/packages/pwa-kit-mcp/docs/images/cursor-settings.png)
48+
<img src="https://raw.githubusercontent.com/SalesforceCommerceCloud/pwa-kit/refs/heads/develop/packages/pwa-kit-mcp/docs/images/cursor-settings.png" alt="Cursor Settings Screenshot" width="50%" />
4849

4950
3. Go to **Tools & Integrations > MCP Tools > New MCP Server**
50-
![](https://raw.githubusercontent.com/SalesforceCommerceCloud/pwa-kit/refs/heads/develop/packages/pwa-kit-mcp/docs/images/cursor-mcp-tools.png)
51+
<img src="https://raw.githubusercontent.com/SalesforceCommerceCloud/pwa-kit/refs/heads/develop/packages/pwa-kit-mcp/docs/images/cursor-mcp-tools.png" alt="Cursor MCP Tools Screenshot" width="50%" />
5152

5253
4. Update your `mcp.json` like this (edit the placeholders as needed):
5354
```json
@@ -86,7 +87,7 @@ Then send JSON-RPC requests like:
8687

8788
```json
8889
{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
89-
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "create_new_component", "arguments": {}}}
90+
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "create_sample_component", "arguments": {}}}
9091
```
9192

9293
---
@@ -127,6 +128,5 @@ the output on "MCP Logs".
127128
| `package.json` | Node.js dependencies and project scripts |
128129
| `mcp.json` | MCP client configuration (used by Cursor or other IDEs) |
129130
| `src/server/` | Main server entry point (`server.js`) |
130-
| `src/tools/` | Contains all MCP tools like `create-app-guideline`, `site-test`, etc. |
131-
| `src/utils/` | Shared utility functions |
132-
| `
131+
| `src/tools/` | Contains all MCP tools like `create-storefront-app`, `site-test`, etc. |
132+
| `src/utils/` | Shared utility functions |

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
CreateNewComponentTool,
1515
DeveloperGuidelinesTool,
1616
TestWithPlaywrightTool,
17-
CreateNewPageTool,
18-
VersionControlGitTool
17+
CreateNewPageTool
1918
} from '../tools'
2019

2120
// NOTE: This is a workaround to import JSON files as ES modules.
@@ -39,18 +38,18 @@ class PwaStorefrontMCPServerHighLevel {
3938
}
4039
)
4140
this.createNewComponentTool = new CreateNewComponentTool()
42-
this.versionControlGitTool = new VersionControlGitTool()
41+
this.createAppGuidelinesTool = new CreateAppGuidelinesTool()
4342
this.testWithPlaywrightTool = new TestWithPlaywrightTool()
4443
this.setupTools()
4544
}
4645

4746
setupTools() {
4847
// Register CreateProjectTool
4948
this.server.tool(
50-
CreateAppGuidelinesTool.name,
51-
CreateAppGuidelinesTool.description,
52-
CreateAppGuidelinesTool.inputSchema,
53-
CreateAppGuidelinesTool.fn
49+
this.createAppGuidelinesTool.name,
50+
this.createAppGuidelinesTool.description,
51+
this.createAppGuidelinesTool.inputSchema,
52+
this.createAppGuidelinesTool.fn
5453
)
5554
this.server.tool(
5655
DeveloperGuidelinesTool.name,
@@ -79,12 +78,6 @@ class PwaStorefrontMCPServerHighLevel {
7978
CreateNewPageTool.inputSchema,
8079
CreateNewPageTool.handler
8180
)
82-
this.server.tool(
83-
this.versionControlGitTool.name,
84-
this.versionControlGitTool.description,
85-
this.versionControlGitTool.inputSchema,
86-
this.versionControlGitTool.handler
87-
)
8881
}
8982

9083
async run() {

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

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
// Project dependencies
99
import {EmptyJsonSchema, getCreateAppCommand, isMonoRepo, runCommand} from '../utils/utils'
10+
import shell from 'shelljs'
11+
import fs from 'fs'
12+
import path from 'path'
1013

1114
const CREATE_APP_COMMAND = getCreateAppCommand()
1215
const DISPLAY_PROGRAM_FLAG = '--displayProgram'
@@ -59,12 +62,15 @@ If the user requests a project using a **template**:
5962
- Presets and templates are mutually exclusive paths. Do not offer both options unless explicitly requested.
6063
- Do not pass any flags to the \`${CREATE_APP_COMMAND}\` CLI tool that are not listed in the program.json options".
6164
- Use the \`${COMMAND_RUNNER}\` command to run the \`${CREATE_APP_COMMAND}\` CLI tool when creating a new project.
62-
- After project creation, prompt the user if **they want to do version control through git** using the **version_control_git** MCP tool.
65+
- After project creation, **MANDATORY**: Always ask the user whether they want to do git version control and commit the files locally.**
66+
- If the user replies "yes" or confirms they want version control:
67+
- Use the integrated version control function and call the \`setupVersionControl\` function to handle git setup
68+
- **IMPORTANT**: You cannot skip asking the user - this interaction is **mandatory** for every project creation.
6369
`
6470

65-
export default {
66-
name: 'create_app_guidelines',
67-
description: `
71+
class CreateAppGuidelinesTool {
72+
name = 'create_storefront_app'
73+
description = `
6874
6975
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.
7076
@@ -74,9 +80,102 @@ Example Triggers:
7480
- "Create a new PWA Kit app"
7581
- "Start a new storefront using a preset"
7682
- "What templates are available for PWA Kit?"
77-
- "What presets are available for PWA Kit?"`,
78-
inputSchema: EmptyJsonSchema,
79-
fn: async () => {
83+
- "What presets are available for PWA Kit?"`
84+
inputSchema = EmptyJsonSchema
85+
86+
/**
87+
* Handles the version control of your project using git.
88+
* If the directory is not a git repo, it creates a basic .gitignore, runs git init, adds all files, and makes an initial commit.
89+
* If already a git repo, it skips initialization and .gitignore creation, and just adds and commits all files locally.
90+
* @param {string} directory - The directory to initialize the git repository in.
91+
*/
92+
handleGitVersionControl(directory) {
93+
if (!shell.which('git')) {
94+
throw new Error(
95+
'git is not installed or not found in PATH. Please install git to initialize a repository.'
96+
)
97+
}
98+
const isGitRepo = fs.existsSync(path.join(directory, '.git'))
99+
let result
100+
if (isGitRepo) {
101+
// Already a git repo: only add and commit
102+
result = shell.exec('git add .', {cwd: directory, silent: true})
103+
if (result.code !== 0) {
104+
throw new Error(`git add failed: ${result.stderr || result.stdout}`)
105+
}
106+
result = shell.exec('git commit -m "Initial commit"', {cwd: directory, silent: true})
107+
if (result.code !== 0) {
108+
throw new Error(`git commit failed: ${result.stderr || result.stdout}`)
109+
}
110+
} else {
111+
// Not a git repo: create .gitignore, init, add, commit
112+
this.createBasicGitignore(directory)
113+
result = shell.exec('git init', {cwd: directory, silent: true})
114+
if (result.code !== 0) {
115+
throw new Error(`git init failed: ${result.stderr || result.stdout}`)
116+
}
117+
result = shell.exec('git add .', {cwd: directory, silent: true})
118+
if (result.code !== 0) {
119+
throw new Error(`git add failed: ${result.stderr || result.stdout}`)
120+
}
121+
result = shell.exec('git commit -m "Initial commit"', {cwd: directory, silent: true})
122+
if (result.code !== 0) {
123+
throw new Error(`git commit failed: ${result.stderr || result.stdout}`)
124+
}
125+
}
126+
}
127+
128+
/**
129+
* Creates a basic .gitignore file in the given directory.
130+
* @param {string} directory - The directory to create the .gitignore file in.
131+
*/
132+
createBasicGitignore(directory) {
133+
const gitignorePath = path.join(directory, '.gitignore')
134+
if (!fs.existsSync(gitignorePath)) {
135+
fs.writeFileSync(
136+
gitignorePath,
137+
`# Node
138+
node_modules/
139+
.env
140+
.DS_Store
141+
npm-debug.log
142+
yarn-debug.log
143+
yarn-error.log
144+
coverage/
145+
dist/
146+
build/
147+
.next/
148+
out/
149+
logs/
150+
*.log
151+
.idea/
152+
.vscode/
153+
`
154+
)
155+
}
156+
}
157+
158+
/**
159+
* Integrated version control function that can be called after project creation
160+
* @param {string} projectDirectory - The directory where the project was created
161+
* @returns {Object} Result object with success status and message
162+
*/
163+
async setupVersionControl(projectDirectory) {
164+
try {
165+
this.handleGitVersionControl(projectDirectory)
166+
return {
167+
success: true,
168+
message: 'Git version control initialized and committed locally.'
169+
}
170+
} catch (error) {
171+
return {
172+
success: false,
173+
message: `Error: ${error.message}`
174+
}
175+
}
176+
}
177+
178+
fn = async () => {
80179
// Run the display program and get the output.
81180
const programOutput = await runCommand(COMMAND_RUNNER, [
82181
...(COMMAND_RUNNER === 'npx' ? ['--yes'] : []),
@@ -110,3 +209,5 @@ Example Triggers:
110209
}
111210
}
112211
}
212+
213+
export default CreateAppGuidelinesTool

0 commit comments

Comments
 (0)