Labsco
GongRzhe logo

MCP Server Creator

โ˜… 41

from GongRzhe

A meta-server for dynamically generating MCP server configurations and Python code.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

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.

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

Available Tools

Server Management

  • create_server: Create a new MCP server configuration
  • list_servers: List all server configurations in memory
  • get_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 server
  • save_server: Save generated server code to a file
  • create_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

Author

GongRzhe - gongrzhe@gmail.com