Skip to content

AI-powered tool to automatically generate Model Context Protocol (MCP) servers

dennisimoo/mcp-server-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server Generator

An AI-powered tool that automatically creates Model Context Protocol (MCP) servers using GPT-4.1.

What It Does

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

Quick Start

What You Need

  • Python 3.8 or newer
  • Node.js 18 or newer
  • OpenAI API key

Setup

  1. Install Python dependencies:
pip install -r requirements.txt
  1. Create your .env file:
cp .env.example .env
  1. Edit .env and add your OpenAI API key:
OPENAI_API_KEY=sk-your-key-here
  1. (Optional) Enable npm auto-publishing:

Edit .env to add:

NPM_AUTO_PUBLISH=true
NPM_USERNAME=your-npm-username
NPM_USE_SCOPED=true

Before enabling auto-publish:

Run the Generator

python mcp_generator.py

Enter how many servers you want to create when prompted.

Output

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

Using Your Generated Servers

Test a Server

  1. Go to the server folder:
cd generated_mcps/weather-mcp
  1. Install dependencies:
npm install
  1. Run it:
node index.js

Connect to Claude Desktop

Add 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.

NPM Auto-Publishing

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

How It Works

  1. GPT-4.1 comes up with server ideas
  2. GPT-4.1 writes the complete code
  3. Script saves all files
  4. (Optional) Publishes to npm
  5. Creates manifest.json to track everything

Tips

  • 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

Troubleshooting

"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

Learn More

License

MIT License

About

AI-powered tool to automatically generate Model Context Protocol (MCP) servers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages