UNPKG

@salesforce/pwa-kit-mcp

Version:

MCP server that helps you build Salesforce Commerce Cloud PWA Kit Composable Storefront

61 lines (60 loc) 3.47 kB
#!/usr/bin/env node /* * 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 */ "use strict"; var _mcp = require("@modelcontextprotocol/sdk/server/mcp.js"); var _stdio = require("@modelcontextprotocol/sdk/server/stdio.js"); var _zod = require("zod"); var _tools = require("../tools"); function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // NOTE: This is a workaround to import JSON files as ES modules. // eslint-disable-next-line @typescript-eslint/no-var-requires const packageJson = require('../package.json'); const FALLBACK_VERSION = '0.1.0'; class PwaStorefrontMCPServerHighLevel { constructor() { // Using McpServer instead of Server this.server = new _mcp.McpServer({ name: 'pwa-kit-mcp', version: (packageJson === null || packageJson === void 0 ? void 0 : packageJson.version) || FALLBACK_VERSION }, { capabilities: { tools: {} } }); this.createNewComponentTool = new _tools.CreateNewComponentTool(); this.versionControlGitTool = new _tools.VersionControlGitTool(); this.testWithPlaywrightTool = new _tools.TestWithPlaywrightTool(); this.setupTools(); } setupTools() { // Register CreateProjectTool this.server.tool(_tools.CreateAppGuidelinesTool.name, _tools.CreateAppGuidelinesTool.description, _tools.CreateAppGuidelinesTool.inputSchema, _tools.CreateAppGuidelinesTool.fn); this.server.tool(_tools.DeveloperGuidelinesTool.name, _tools.DeveloperGuidelinesTool.description, _tools.DeveloperGuidelinesTool.inputSchema, _tools.DeveloperGuidelinesTool.fn); this.server.tool('run_site_test', 'Run site performance or accessibility test for a given site URL (e.g. https://pwa-kit.mobify-storefront.com)', { testType: _zod.z.enum(['performance', 'accessibility']).describe('Type of test to run'), siteUrl: _zod.z.string().optional().describe('Site URL to test (optional)') }, ({ testType, siteUrl }) => this.testWithPlaywrightTool.run(testType, siteUrl)); this.server.tool(this.createNewComponentTool.name, this.createNewComponentTool.description, this.createNewComponentTool.inputSchema, this.createNewComponentTool.handler); this.server.tool(_tools.CreateNewPageTool.name, _tools.CreateNewPageTool.description, _tools.CreateNewPageTool.inputSchema, _tools.CreateNewPageTool.handler); this.server.tool(this.versionControlGitTool.name, this.versionControlGitTool.description, this.versionControlGitTool.inputSchema, this.versionControlGitTool.handler); } run() { var _this = this; return _asyncToGenerator(function* () { const transport = new _stdio.StdioServerTransport(); yield _this.server.connect(transport); console.error('PWA Storefront MCP server (McpServer version) running on stdio'); })(); } } const server = new PwaStorefrontMCPServerHighLevel(); server.run().catch(console.error);