An AI-powered tool that automatically creates Model Context Protocol (MCP) servers using GPT-4.1.
This Python script uses GPT to create fully functional MCP servers. Each server is ready to use and can connect to AI tools like Claude Desktop.
The generator creates:
- API Wrappers: Servers that connect to public APIs (weather, jokes, facts, etc.)
- Utility Functions: Math operations, text tools, data processing
- Data Generators: Random numbers, UUIDs, mock data
Each generated MCP includes:
- Working Node.js server code
- Complete package.json with all dependencies
- README with instructions
- Error handling and logging
- Python 3.8 or newer
- Node.js 18 or newer
- OpenAI API key
- Install Python dependencies:
pip install -r requirements.txt- Create your .env file:
cp .env.example .env- Edit .env and add your OpenAI API key:
OPENAI_API_KEY=sk-your-key-here- (Optional) Enable npm auto-publishing:
Edit .env to add:
NPM_AUTO_PUBLISH=true
NPM_USERNAME=your-npm-username
NPM_USE_SCOPED=trueBefore enabling auto-publish:
- Sign up at https://www.npmjs.com/signup
- Run: npm login
- Verify: npm whoami
python mcp_generator.pyEnter how many servers you want to create when prompted.
Generated servers are saved in the generated_mcps folder:
generated_mcps/
├── manifest.json
├── weather-mcp/
│ ├── index.js
│ ├── package.json
│ └── README.md
└── jokes-mcp/
├── index.js
├── package.json
└── README.md
- Go to the server folder:
cd generated_mcps/weather-mcp- Install dependencies:
npm install- Run it:
node index.jsAdd to your Claude config file (~/Library/Application Support/Claude/claude_desktop_config.json on Mac):
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/full/path/to/generated_mcps/weather-mcp/index.js"]
}
}
}Restart Claude Desktop and your tools will be available.
When enabled, the generator automatically publishes each server to npm. This lets anyone install and use your servers.
Package names:
- With NPM_USE_SCOPED=true: @username/weather-mcp
- With NPM_USE_SCOPED=false: weather-mcp
After publishing, anyone can install with:
npx @username/weather-mcp- GPT-4.1 comes up with server ideas
- GPT-4.1 writes the complete code
- Script saves all files
- (Optional) Publishes to npm
- Creates manifest.json to track everything
- Start with 2-3 servers to see what gets created
- Run again if you want different ideas
- Edit the generated code to customize it
- Use scoped packages (@username/name) to avoid naming conflicts
- Set NPM_AUTO_PUBLISH=false to test without publishing
"OPENAI_API_KEY not found"
- Check that you created .env with your API key
- Make sure the key starts with sk-
"Error generating MCP"
- Check your OpenAI API quota
- Make sure you have access to GPT-4.1
Generated server doesn't work
- Go to the server folder and run: npm install
- Check the server's README
- Make sure Node.js 18+ is installed
NPM publishing fails
- Check you're logged in: npm whoami
- Package name might already exist
- Check version conflicts
- Model Context Protocol: https://modelcontextprotocol.io/
- MCP SDK: https://github.com/modelcontextprotocol/sdk
- OpenAI API: https://platform.openai.com/docs
MIT License