Skip to main content

CLI tool and utilities for scaffolding Model Context Protocol (MCP) projects with enhanced logging

Project description

modelcontextprotocol

CLI tool and utilities for scaffolding Model Context Protocol (MCP) projects with enhanced logging

Create production-ready MCP servers and clients in seconds with built-in loguru logging and optional PostHog analytics.

✨ Features

  • 🚀 Quick Scaffolding - Generate MCP projects instantly
  • 📝 Enhanced Logging - Beautiful logs with loguru out of the box
  • 📊 Analytics - Optional PostHog integration for usage tracking
  • 🎨 Beautiful CLI - Rich terminal UI with helpful prompts
  • 🔧 Best Practices - Templates follow MCP best practices
  • 📦 uvx Compatible - No installation needed with uvx

🚀 Quick Start

With uvx (No Installation)

# Interactive mode
uvx modelcontextprotocol create

# Direct creation
uvx modelcontextprotocol create my-server --type server

With pip/uv

# Install
pip install modelcontextprotocol
# or
uv pip install modelcontextprotocol

# Create a project
modelcontextprotocol create
# or
mcp-create server my-weather-server

📖 Usage

Interactive Mode

Simply run without arguments for an interactive experience:

modelcontextprotocol create

You'll be prompted for:

  • Project name
  • Project type (server/client)
  • Template type (basic/advanced)
  • Project path

Command Line Mode

# Create a basic server
mcp-create server my-server

# Create an advanced server with PostHog
mcp-create server my-server \
  --template advanced \
  --posthog-key YOUR_KEY

# Create a client
mcp-create client my-client

# Specify custom path
mcp-create server my-server --path ./projects/my-server

Environment Variables

# PostHog configuration
export POSTHOG_API_KEY="your-api-key"
export POSTHOG_HOST="https://app.posthog.com"

# Now create with analytics
mcp-create server my-server --template advanced

📋 Generated Project Structure

Basic Server

my-server/
├── server.py          # Main server file with loguru
├── pyproject.toml     # Project configuration
├── .gitignore         # Git ignore rules
└── README.md          # Project documentation

Server Code (Basic)

from mcp.server.fastmcp import FastMCP
from loguru import logger

# Configure logging
logger.add("my-server.log", rotation="10 MB", level="INFO")
logger.info("Initializing my-server MCP server")

# Initialize server
mcp = FastMCP("my-server")

@mcp.tool()
async def example_tool(text: str) -> str:
    """An example tool that processes text."""
    logger.info(f"Processing text: {text}")
    result = f"Processed: {text}"
    logger.debug(f"Result: {result}")
    return result

if __name__ == "__main__":
    logger.info("Starting my-server server")
    mcp.run()

Advanced Server Features

The advanced template includes:

  • Error logging to separate file
  • HTTP client integration with httpx
  • PostHog analytics tracking (optional)
  • Graceful shutdown handling
  • Enhanced error tracking

🎯 Templates

Basic Template

Perfect for simple MCP servers:

  • Loguru logging to file
  • Example tool and resource
  • Clean structure

Advanced Template

For production servers:

  • Dual logging (info + errors)
  • HTTP client with retry logic
  • PostHog analytics integration
  • Error tracking
  • Graceful shutdown

📊 Logging with Loguru

All generated projects use loguru for beautiful, structured logging:

logger.info("Information message")
logger.success("Success message")
logger.warning("Warning message")
logger.error("Error message")
logger.debug("Debug message")

Logs are automatically:

  • Color-coded in terminal
  • Saved to files with rotation
  • Formatted consistently
  • Performance optimized

📈 PostHog Analytics (Optional)

Track your MCP server usage:

# Automatically included in advanced template
posthog.capture(
    distinct_id="server",
    event="tool_called",
    properties={"tool_name": "example_tool"}
)

🛠️ Development

After creating your project:

cd my-server

# Create virtual environment
uv venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dependencies
uv pip install -e .

# Run your server
python server.py

📚 Examples

Create Weather Server

mcp-create server weather-server --template advanced
cd weather-server
# Edit server.py to add weather API integration
python server.py

Create Database Client

mcp-create client db-client
cd db-client
# Edit client.py to connect to your MCP server
python client.py

With Analytics

export POSTHOG_API_KEY="phc_..."
mcp-create server analytics-server --template advanced
# PostHog tracking automatically included

🤝 Contributing

Contributions are welcome! This package helps developers:

  • Get started with MCP quickly
  • Follow best practices
  • Include production-ready logging
  • Track usage metrics (opt-in)

📦 Package Contents

  • cli.py - CLI interface with rich prompts
  • templates/ - Server and client templates
  • analytics.py - PostHog integration
  • Additional utilities for MCP development

🔗 Resources

📄 License

MIT License - See LICENSE file for details

🙏 Acknowledgments

  • Built on top of the official MCP Python SDK
  • Uses loguru for beautiful logging
  • Inspired by create-react-app and similar scaffolding tools

Made with ❤️ for the MCP community

# Get started now!
uvx modelcontextprotocol create

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelcontextprotocol-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelcontextprotocol-1.0.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file modelcontextprotocol-1.0.0.tar.gz.

File metadata

  • Download URL: modelcontextprotocol-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for modelcontextprotocol-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fcf94f36c514705dfa207198d025408fe50103082153bfba157aab2e53268491
MD5 3e025e83e18405d0e115485978c154a0
BLAKE2b-256 c3c93e8c1645c2bb519222de71de90aae01e7c034a851705680eb4b7b20932b0

See more details on using hashes here.

File details

Details for the file modelcontextprotocol-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for modelcontextprotocol-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03ba8d973403e657452cd237fed81191b23b3e5fec7641990263ce7955b69d1f
MD5 c537c0d204dbd18c91d94c2cab42cddf
BLAKE2b-256 ba63cd189d376ced98a32125ab4f8d7ec9cdb97ace871198d103badf289fdc80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page