-
Notifications
You must be signed in to change notification settings - Fork 79
feat: add @modelcontextprotocol/create-mcp-app package #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Enable scaffolding new MCP App projects via `npm create @modelcontextprotocol/mcp-app`. Features: - Interactive CLI with @clack/prompts for beautiful UX - React and Vanilla JS templates included - Uses tsx for broader compatibility (no bun dependency) - Templates include server, UI, and build configuration - Supports --template and --no-install flags Changes: - Add packages/create-mcp-app/ with CLI and templates - Add packages/* to workspaces in root package.json - Add publish-packages job to npm-publish workflow Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
- Add Quick Start section to README with npm create command - Add tip callout to quickstart guide for faster project setup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jonathanhefner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, but I think my biggest qualm is testing. I think we need to be 100% sure that the code we generate works end-to-end. Right now, it looks like the scaffold code isn't being tested nor even type-checked (unless I missed it?).
| > [!TIP] | ||
| > **Want to skip the setup?** Run `npm create @modelcontextprotocol/mcp-app my-app` to scaffold this project automatically, then skip to [Section 3: Build the View](#3-build-the-view). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually replaces all but the last step of the Quickstart guide ("See it in action").
I don't think we want to pitch this in the Quickstart, because the Quickstart is a "learn by doing" tutorial. If we replace the "doing" with npm create @modelcontextprotocol/mcp-app my-app, that kind of defeats the purpose. 😄
| npm create @modelcontextprotocol/mcp-app [project-name] [options] | ||
| ${pc.bold("Options:")} | ||
| -t, --template <name> Template to use (${TEMPLATES.map((t) => t.value).join(", ")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better named as --framework. (I would assume a --template option designates an actual template to use — i.e., a path to a directory.)
| ${pc.bold("Options:")} | ||
| -t, --template <name> Template to use (${TEMPLATES.map((t) => t.value).join(", ")}) | ||
| --no-install Skip npm install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: what's the use case for this option?
| /** Current SDK version - used in generated package.json files */ | ||
| export const SDK_VERSION = "0.4.1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a way for this to be dynamically computed or at least automatically updated.
| if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/i.test(name)) { | ||
| return "Project name must be lowercase alphanumeric with optional hyphens"; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this restriction?
| .main { | ||
| --color-primary: #2563eb; | ||
| --color-primary-hover: #1d4ed8; | ||
|
|
||
| width: 100%; | ||
| max-width: 425px; | ||
| box-sizing: border-box; | ||
| padding: 1rem; | ||
|
|
||
| > * { | ||
| margin-top: 0; | ||
| margin-bottom: 0; | ||
| } | ||
|
|
||
| > * + * { | ||
| margin-top: 1.5rem; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want this CSS either. It might be beneficial to include some basic styling that uses CSS variables from the host context, but I'm not sure if that would be better here or in global.css. 🤔
| useEffect(() => { | ||
| if (toolResult) { | ||
| setServerTime(extractTime(toolResult)); | ||
| } | ||
| }, [toolResult]); | ||
|
|
||
| const handleGetTime = useCallback(async () => { | ||
| try { | ||
| console.info("Calling get-time tool..."); | ||
| const result = await app.callServerTool({ | ||
| name: "get-time", | ||
| arguments: {}, | ||
| }); | ||
| console.info("get-time result:", result); | ||
| setServerTime(extractTime(result)); | ||
| } catch (e) { | ||
| console.error(e); | ||
| setServerTime("[ERROR]"); | ||
| } | ||
| }, [app]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my comment about the tool, I don't think we should be including this in a scaffold.
| "@modelcontextprotocol/sdk": "^1.24.0", | ||
| "cors": "^2.8.5", | ||
| "express": "^5.1.0", | ||
| "react": "^19.2.0", | ||
| "react-dom": "^19.2.0", | ||
| "zod": "^4.1.13" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/cors": "^2.8.19", | ||
| "@types/express": "^5.0.0", | ||
| "@types/node": "^22.0.0", | ||
| "@types/react": "^19.2.2", | ||
| "@types/react-dom": "^19.2.2", | ||
| "@vitejs/plugin-react": "^4.3.4", | ||
| "concurrently": "^9.2.1", | ||
| "cross-env": "^10.1.0", | ||
| "esbuild": "^0.25.0", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^6.0.0", | ||
| "vite-plugin-singlefile": "^2.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wary about hard-coding these version numbers.
| "lib": ["ESNext", "DOM", "DOM.Iterable"], | ||
| "module": "ESNext", | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "verbatimModuleSyntax": true, | ||
| "noEmit": true, | ||
| "jsx": "react-jsx", | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true, | ||
| "noFallthroughCasesInSwitch": true | ||
| }, | ||
| "include": ["src", "server.ts"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include is missing main.ts, but also there is a problem with this approach: using DOM APIs in server code isn't flagged by the IDE. We kind of accept / overlook that for our in-repo examples, but if we're generating code for other people's projects, I would like to do better.
| Then test with the basic-host: | ||
|
|
||
| ```bash | ||
| SERVERS='["http://localhost:3001/mcp"]' npx @modelcontextprotocol/basic-host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@modelcontextprotocol/basic-host is not a published package.
Closes #354
Summary
Enable scaffolding new MCP App projects with a single command:
Features
tsxfor running the dev server (broader compatibility than bun)esbuildfor bundling server files--template react|vanillajs- Skip template selection prompt--no-install- Skip automatic npm installPackage Structure
Changes
packages/create-mcp-app/with CLI implementation and templatespackages/*to workspaces in rootpackage.jsonpublish-packagesjob to npm-publish workflowTesting
Test plan
🤖 Generated with Claude Code