[🧱 MCP Server Tool] Project Structure Cleanup#2699
[🧱 MCP Server Tool] Project Structure Cleanup#2699bendvc merged 8 commits intofeature/pwa-developer-agent-onlyfrom
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
Revert pty usage so it will be compatible with windows.
There was a problem hiding this comment.
I'm not sure why this was added as it wasn't in develop, so I removed it. Things still work without it.
| const printProgramJsonAndExit = async () => { | ||
| const output = JSON.stringify(PROGRAM, null, 2) | ||
| await new Promise((resolve) => { | ||
| process.stdout.write(output + '\n', () => { | ||
| resolve() | ||
| }) | ||
| }) |
There was a problem hiding this comment.
This was a bug that I originally made where the output was being printed and the program exited before the standard out could be flushed. This fixes that problem.
| ...parentConfig, | ||
| sourceType: 'module' | ||
| } | ||
| module.exports = require('internal-lib-build/configs/babel.config') |
There was a problem hiding this comment.
Module type was no longer required and our project is not an esm project anymore but we still use import syntax. Its a little weird, but that is how we currently do it in the pwa-kit mono repo. We could choose to change this, but we might have to drop pwa-kit-dev as a source of our jest integration.
| * 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 | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires |
There was a problem hiding this comment.
Fixing some lint errors now that we have linting for all files working.
| '!src/**/*.spec.js' | ||
| ], | ||
| testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'], | ||
| testPathIgnorePatterns: ['bin/*', 'coverage/*', 'dist/*', 'node_modules/*', 'scripts/*'], |
There was a problem hiding this comment.
Dont test node modules etc.
| "main": "dist/server/server.js", | ||
| "files": [ | ||
| "CHANGELOG.md", | ||
| "LICENSE", | ||
| "dist/**/*.{js,d.ts}", | ||
| "!dist/CHANGELOG.md", | ||
| "!dist/README.md", | ||
| "!**/*.test.{ts,js}" | ||
| ], |
There was a problem hiding this comment.
Just some clean up on how our package is configured, here we don't want to include test files in our package and some other stuff, we also want to use the built server as our main entry point.
| "build": "cross-env NODE_ENV=production internal-lib-build build", | ||
| "build:watch": "nodemon --watch 'src/**' --ext 'js,ts' --exec 'npm run build'", |
There was a problem hiding this comment.
New build and build watch commands. If you are developing the server use the build watch so that it's automatically built when you make changes to files.
| "engines": { | ||
| "node": "^16.11.0 || ^18.0.0 || ^20.0.0 || ^22.0.0", | ||
| "npm": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0" | ||
| }, |
There was a problem hiding this comment.
Add engines so that it's in alignment with the other projects
| "publishConfig": { | ||
| "directory": "dist" |
There was a problem hiding this comment.
This is required for when we decide to publish our package.
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const productDocument = require('../data/ProductDocument.json') | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const categoryDocument = require('../data/CategoryDocument.json') |
There was a problem hiding this comment.
here we fall back to using require since it works for json files without special syntax that confuses jest
There was a problem hiding this comment.
It seems weird to use require here. Probably we can convert .json to .js file and export it.
| const BABEL_NODE_PATH = path.resolve( | ||
| './node_modules/.bin/babel-node' + (process.platform === 'win32' ? '.cmd' : '') | ||
| ) |
There was a problem hiding this comment.
We'll run the server with babel-node for now so it doesn't complain about the import syntax of the source files. but in the future we migrate to ESM, maybe add out own test setup we can revert this.
| * | ||
| * This is useful for running CLI tools that emit different output | ||
| * when run in a TTY environment (e.g., with color, formatting, or paging). | ||
| * Runs a shell command and captures its stdout/stderr as a string. |
There was a problem hiding this comment.
the 3rd party npm package that I was using to communicate with the create-app script was old and didn't support newer versions of node. So I decided to remove it and use vanilla apis. I can do that because I found the root of the problem for truncated output in the create-app script itself.
| import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js' | ||
|
|
||
| // import {McpServer} from '@modelcontextprotocol/sdk/server/mcp' | ||
| // import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio' |
There was a problem hiding this comment.
Seems these commented out import should be removed.
|
I checked out the branch and tested. No issue found, all commands in package.json runs correctly. |
Description
🧹 This PR gives our mcp server project a little spring cleaning (in June, because who follows rules anymore?). The goal was to make things less "Where the heck is that file?" and more "Ah, there it is."
This PR:
No functionality changes. Just vibes and structure. 🏗️
Types of Changes
Changes
packages/pwa,packages/pwa-build, andpackages/pwa-devpackages/pwa/src/clicontents intopackages/pwa-devHow to Test-Drive This PR
npm run testfrom the root — all tests should still pass 🧪.Checklists
General
Accessibility Compliance
Localization
Let me know if you'd like a pun-filled title suggestion too!