Generate Python Code for MCP Servers
Meta MCP server that generates other MCP servers: define tools and resources, then export runnable FastMCP Python code.
Why it matters
Dynamically generate and configure MCP servers with custom tools and resources. Automate the creation of Python code for your servers, streamlining development and deployment.
Outcomes
What it gets done
Create new MCP server configurations on the fly.
Add custom synchronous or asynchronous tools to servers.
Manage static and dynamic resources with template support.
Generate complete, ready-to-run Python code for servers.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-mcp-server-creator | bash Capabilities
Tools your agent gets
Create a new MCP server configuration
List all server configurations in memory
Get detailed information about a specific server
Add a tool to an existing server with support for sync/async and custom parameters
Add a resource to an existing server with templates and custom MIME types
Generate complete Python code for the server
Save the generated server code to a file
Create a complete Weather Service example server
Overview
MCP Server Creator MCP Server
A meta MCP server that generates other MCP servers - define tools and resources through create_server/add_tool/add_resource, then export runnable FastMCP Python code. Use when prototyping or scaffolding a new MCP server instead of hand-writing boilerplate. Generates code that still needs review and completion, requires Python 3.8+ and FastMCP 0.1.0+.
What it does
MCP Server Creator is a meta MCP server that creates other MCP servers - it dynamically generates FastMCP server configurations and complete, runnable Python code. It supports dynamic server creation (defining new MCP server configurations on the fly), a tool builder (adding custom tools with parameters, types, and implementations, supporting both sync and async, with automatic import management), a resource manager (adding static or dynamic resource templates with parameters and custom MIME types), code generation (producing complete Python code for a defined server), and file export (saving the generated server directly to a Python file). It also ships a built-in example server template demonstrating its own capabilities.
from mcp_server_creator import create_server, add_tool, generate_server_code
result = create_server(
name="My API Server",
description="A custom API integration server",
version="1.0.0"
)
add_tool(
server_id="my_api_server",
tool_name="fetch_data",
description="Fetch data from the API",
parameters=[{"name": "endpoint", "type": "str"}],
return_type="dict",
implementation='return {"data": f"Fetched from {endpoint}"}'
)
code = generate_server_code("my_api_server")
Used as an MCP server itself with Claude Desktop or any MCP client, it exposes server management tools (create_server, list_servers, get_server_details), tool management (add_tool for adding custom logic to an in-progress server), resource management (add_resource for static data or parameterized dynamic templates), and code generation tools (generate_server_code, save_server, and create_example_server for a complete demo Weather Service). It can also be used programmatically as a Python library, as shown by its full worked example that creates a Weather Service with a get_weather async tool and a weather://{city}/current dynamic resource template, then saves the result to weather_service.py.
When to use - and when NOT to
Use this connector when you're prototyping or scaffolding a new MCP server - defining its tools and resources conversationally through Claude, then exporting working FastMCP Python code rather than hand-writing the server boilerplate from scratch.
It generates server configuration and code, not a running production server - the generated Python still needs to be reviewed, completed where implementation stubs are provided, and deployed like any other MCP server. It requires Python 3.8+ and FastMCP 0.1.0 or later as runtime dependencies for the servers it generates. The upstream repository (GongRzhe/MCP-Server-Creator on GitHub) is archived and no longer receiving updates.
Capabilities
Server management: create_server, list_servers, get_server_details. Tool management: add_tool (sync/async, typed parameters with defaults, automatic imports). Resource management: add_resource (static or dynamic templated resources with custom MIME types). Code generation: generate_server_code, save_server, and create_example_server for a working demo.
How to install
Install via pip (pip install mcp-server-creator), run directly with uvx (uvx mcp-server-creator, recommended), or run as a module (python -m mcp_server_creator). Add to Claude Desktop's claude_desktop_config.json mcpServers block with command uvx and args ["mcp-server-creator"]. For development, clone the repository and install in editable mode (pip install -e .).
Who it's for
MCP developers who want to scaffold new MCP servers - defining tools and resources through Claude and exporting working FastMCP Python code - instead of writing server boilerplate by hand.
Source README
MCP Server Creator ๐๏ธ
A powerful Model Context Protocol (MCP) server that creates other MCP servers! This meta-server provides tools for dynamically generating FastMCP server configurations and Python code.
๐ Quick Start
Install with pip
pip install mcp-server-creator
Run with uvx (recommended)
uvx mcp-server-creator
Run as a module
python -m mcp_server_creator
Features
- Dynamic Server Creation: Create new MCP server configurations on the fly
- Tool Builder: Add custom tools with parameters, return types, and implementations
- Resource Manager: Add static and dynamic resources with template support
- Code Generation: Generate complete, runnable Python code for your servers
- File Export: Save generated servers directly to Python files
- Example Templates: Built-in example server to demonstrate capabilities
Usage
As an MCP Server
The MCP Server Creator is itself an MCP server that can be used with Claude Desktop or any MCP client.
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mcp-server-creator": {
"command": "uvx",
"args": ["mcp-server-creator"]
}
}
}
Programmatic Usage
from mcp_server_creator import create_server, add_tool, generate_server_code
# Create a new server configuration
result = create_server(
name="My API Server",
description="A custom API integration server",
version="1.0.0"
)
# Add a tool
add_tool(
server_id="my_api_server",
tool_name="fetch_data",
description="Fetch data from the API",
parameters=[{"name": "endpoint", "type": "str"}],
return_type="dict",
implementation='return {"data": f"Fetched from {endpoint}"}'
)
# Generate the code
code = generate_server_code("my_api_server")
print(code)
Available Tools
Server Management
create_server: Create a new MCP server configurationlist_servers: List all server configurations in memoryget_server_details: Get detailed information about a specific server
Tool Management
add_tool: Add a tool to an existing server- Supports both sync and async tools
- Custom parameter definitions with types and defaults
- Automatic import management
Resource Management
add_resource: Add a resource to an existing server- Static resources for fixed data
- Dynamic resource templates with parameters
- Custom MIME types
Code Generation
generate_server_code: Generate complete Python code for a serversave_server: Save generated server code to a filecreate_example_server: Create a complete example Weather Service
Example: Creating a Weather Service
import asyncio
from mcp_server_creator import create_server, add_tool, add_resource, save_server
async def create_weather_service():
# Create the server
create_server(
name="Weather Service",
description="Get weather information",
version="1.0.0"
)
# Add a weather tool
add_tool(
server_id="weather_service",
tool_name="get_weather",
description="Get current weather for a city",
parameters=[
{"name": "city", "type": "str"},
{"name": "units", "type": "str", "default": '"celsius"'}
],
return_type="dict",
is_async=True,
implementation='''
# Your weather API logic here
return {
"city": city,
"temperature": 20,
"units": units,
"condition": "sunny"
}'''
)
# Add a resource
add_resource(
server_id="weather_service",
uri="weather://{city}/current",
name="Current Weather",
description="Get current weather data",
is_template=True,
implementation='return {"city": city, "weather": "sunny"}'
)
# Save to file
await save_server("weather_service", "weather_service.py")
# Run the creation
asyncio.run(create_weather_service())
Development
Setup
git clone https://github.com/GongRzhe/mcp-server-creator.git
cd mcp-server-creator
pip install -e .
Testing
python test_mcp_creator.py
Requirements
- Python 3.8+
- FastMCP >= 0.1.0
Author
GongRzhe - gongrzhe@gmail.com
Links
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.