π CLI tool to bootstrap MCP (Model Context Protocol) servers with ChatGPT widget support.
Quickly set up an MCP server with widgets and a complete development environment in seconds.
- π― Interactive CLI - Guided project setup with validation
- β‘ Multiple Frameworks - Choose between Next.js or Vite
- π§ Pre-configured MCP Server - Ready-to-use MCP protocol implementation
- π¨ Widget System - React-based widgets with hot reload
- π¦ Complete Dev Environment - Everything you need to start building
- π§ͺ Testing Ready - Includes MCP Inspector integration
- π ChatGPT Integration - Connect to ChatGPT via ngrok for E2E testing
- π TypeScript Support - Full TypeScript support for both Next.js and Vite templates
# Using npx (recommended)
npx mcp-widget create my-app
# Or install globally
npm install -g mcp-widget
mcp-widget create my-app
# Or use specific package manager
pnpm dlx mcp-widget create my-app
yarn dlx mcp-widget create my-appSimply run the command and follow the prompts:
npx mcp-widget create my-appYou'll be asked:
- Project name - Must be lowercase, alphanumeric with hyphens only
- Framework - Choose between:
- Vite - TypeScript + React with fast HMR
- Next.js - Full-stack with TypeScript and App Router
For scripts and automation, you can specify all options via command line arguments:
# Create with specific template
npx mcp-widget create my-app --template vite
npx mcp-widget create my-app --template nextjs
# Use short flags
npx mcp-widget create my-app -t vite
# Skip all prompts with --yes flag (uses defaults)
npx mcp-widget create my-app --yes
# Combine options
npx mcp-widget create my-app -t nextjs -yAvailable Options:
--template,-t- Template to use (viteornextjs)--yes,-y- Skip interactive prompts and use defaults
Examples:
# Interactive mode
npx mcp-widget create
# Mixed mode - name provided, prompt for template
npx mcp-widget create my-app
# Full non-interactive mode
npx mcp-widget create my-app -t nextjsYour new project includes:
my-chatgpt-app/
βββ src/
β βββ server/
β β βββ server.ts # MCP server implementation
β βββ widgets/
β βββ hello-world/
β βββ index.tsx # Example widget
βββ scripts/
β βββ dev.js # Development server
βββ package.json
βββ tsconfig.json # TypeScript configuration
βββ tsconfig.node.json # TypeScript config for Node.js
βββ tsconfig.server.json # TypeScript config for server
βββ vite.config.js # Widget build configuration
βββ README.md # Project-specific documentation
Perfect for quick prototyping and widget-focused development with full TypeScript support.
Architecture:
- Widget Dev Server (Port 4450) - Vite with HMR for widget development
- MCP Server (Port 8000) - SSE endpoint at
/mcp - Preview Server (Port 5173) - Local widget preview UI
Start Development:
cd my-app
npm run devEndpoints:
- Widget preview: http://localhost:5173
- MCP endpoint: http://localhost:8000/mcp
- Widget assets: http://localhost:4450
Full-stack application with TypeScript and API routes.
Architecture:
- Next.js App (Port 3000) - Full application with API routes
- MCP SSE Route -
/api/mcpfor MCP protocol - MCP Messages Route -
/api/mcp/messagesfor tool calls
Start Development:
cd my-app
npm run devEndpoints:
- Application: http://localhost:3000
- MCP endpoint: http://localhost:3000/api/mcp
npx mcp-widget create my-app
# Follow the promptscd your-project-name
npm install # If dependencies weren't auto-installed
npm run dev# In a new terminal
npx @modelcontextprotocol/inspector http://localhost:8000/mcpOr for Next.js:
npx @modelcontextprotocol/inspector http://localhost:3000/api/mcpTest your MCP server with ChatGPT using ngrok:
# Install ngrok
brew install ngrok/ngrok/ngrok
# Start tunnel (while your app is running)
ngrok http 8000 # or 3000 for Next.js
# Use the HTTPS URL to create a Custom GPT in ChatGPTFull guide: See docs/CHATGPT_INTEGRATION.md
npm run buildThe generated projects implement the Model Context Protocol with:
- β Tools - Execute functions with structured input/output
- β Resources - Serve widget HTML with proper MIME types
- β Resource Templates - Widget templates for dynamic loading
- β Structured Content - Rich responses with metadata
The hello-world tool demonstrates the complete flow:
// Call the tool
{
"name": "hello-world",
"arguments": {
"message": "Hello from ChatGPT!"
}
}
// Returns
{
"content": [
{ "type": "text", "text": "Hello World Tool called..." }
],
"structuredContent": [
{
"type": "message",
"message": "Hello from ChatGPT!",
"timestamp": "2025-10-19T..."
}
],
"_meta": {
"outputTemplate": "ui://widget/hello-world.html"
}
}Widgets are React components that can:
- Access
window.openai.toolOutputfor data - Detect
window.openai.displayMode(light/dark) - Hot reload during development
- Build to standalone HTML+JS
- Create directory:
src/widgets/my-widget/ - Add
index.tsx:
import React, { useState, useEffect } from "react";
import { createRoot } from "react-dom/client";
// Define types for tool output
interface ToolOutput {
message?: string;
[key: string]: any;
}
// Extend window interface
declare global {
interface Window {
openai?: {
toolOutput?: ToolOutput;
displayMode?: string;
};
}
}
function MyWidget() {
const [data, setData] = useState<ToolOutput | null>(null);
useEffect(() => {
const output = window.openai?.toolOutput;
if (output) {
setData(output);
}
}, []);
return <div>My Custom Widget: {data?.message}</div>;
}
const root = createRoot(document.getElementById("root")!);
root.render(<MyWidget />);- Register in MCP server (auto-detected by Vite config)
- Access via
ui://widget/my-widget.html
npm testSee TESTING.md for comprehensive testing guide.
The Inspector is your best friend for testing:
npx @modelcontextprotocol/inspector http://localhost:8000/mcpVerify:
- β Connection successful
- β Tools are listed
- β Resources are accessible
- β Tool calls return expected data
- Node.js 18+ (LTS recommended)
- npm 7+ / pnpm 8+ / yarn 1.22+
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT Β© [Your Name]
Check out the examples/ directory for:
- Custom widget examples
- Advanced MCP server patterns
- Integration with external APIs
- Multi-widget applications
- React Native template
- Svelte/Vue widget support
- GraphQL integration example
- Docker deployment templates
- Monorepo template
- Testing utilities package
The templates currently use SSE (Server-Sent Events) for MCP communication. While the MCP SDK is moving towards StreamableHttp, SSE is simple and works reliably for development.
Both templates now use TypeScript by default, providing better developer experience with type safety and IntelliSense. However, you can easily use JavaScript by simply renaming .ts/.tsx files to .js/.jsx and removing type annotations.
See the authentication example in examples/auth/ (coming soon).
Yes! See deployment guides in docs/DEPLOYMENT.md (coming soon).
- Model Context Protocol by Anthropic
- React team for React 18
- Vite team for the amazing build tool
- Next.js team for the framework
Happy Building! π
If you find this tool helpful, please β star the repo!
- Node.js 18+
- pnpm (recommended) or npm
MIT