Generate dual-mode MCP servers with best practices
Project description
MCP Server Generator
A meta-generator for creating dual-mode MCP servers with best practices
Overview
Generate complete, production-ready MCP (Model Context Protocol) servers that work in two modes:
- MCP Server Mode: For AI agents (Claude Desktop, etc.)
- CLI Mode: For developers
This tool is itself an MCP server, enabling AI agents to generate other MCP servers! It demonstrates the dual-mode architecture pattern it creates.
Why Use This?
- โก Fast: Generate a complete MCP server in under 5 minutes
- ๐๏ธ Complete: Includes tests, documentation, packaging, and CI/CD
- โ Tested: Generated servers have comprehensive test suites with high coverage
- ๐ฏ Best Practices: Follows validated patterns from production MCP servers
- ๐ง Dual-Mode: Works as both MCP server and CLI tool
- ๐ฆ Ready to Publish: GitHub Actions workflows included for PyPI publishing
Features
- โ Dual-mode architecture (MCP + CLI)
- โ Package prefix support (avoid PyPI namespace conflicts with AUTO detection)
- โ Complete project scaffolding (tests, docs, packaging)
- โ GitHub Actions workflows (via pypi-workflow-generator)
- โ Comprehensive test suite (27+ tests with high coverage)
- โ Type hints and documentation
- โ Best practices enforcement
- โ Minimal dependencies
Installation
For MCP Server Usage (Recommended)
Using uvx (no installation required):
The easiest way to use this as an MCP server - just configure in Claude Desktop:
{
"mcpServers": {
"mcp-server-generator": {
"command": "uvx",
"args": ["hitoshura25-mcp-server-generator"]
}
}
}
Prerequisites: Install uv:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
For CLI Usage (Alternative)
Using pipx (isolated installation):
pipx install hitoshura25-mcp-server-generator
Using pip:
pip install hitoshura25-mcp-server-generator
From Source (Development)
git clone https://github.com/hitoshura25/mcp-server-generator.git
cd mcp-server-generator
pip install -e .
Quick Start
Interactive Mode (Recommended)
The easiest way to get started:
hitoshura25-mcp-server-generator-cli --interactive
This will guide you through:
- Project naming
- Author information
- Tool definitions
- Configuration options
Command-Line Mode
For automation or when you have a tool definition file:
hitoshura25-mcp-server-generator-cli \
--project-name my-mcp-tool \
--description "Does something useful" \
--author "Your Name" \
--email "you@example.com" \
--tools-file tools.json
MCP Server Mode (For AI Agents)
Configure mcp-server-generator as an MCP server in Claude Desktop to let Claude generate MCP servers for you:
Using uvx (recommended):
{
"mcpServers": {
"mcp-server-generator": {
"command": "uvx",
"args": ["hitoshura25-mcp-server-generator"]
}
}
}
Using pipx/pip installation:
{
"mcpServers": {
"mcp-server-generator": {
"command": "hitoshura25-mcp-server-generator"
}
}
}
For detailed MCP configuration, see MCP-USAGE.md
Package Prefix
To avoid namespace conflicts on PyPI, mcp-server-generator supports prefixing package names. This is highly recommended for unique package names.
Prefix Modes
AUTO (Recommended)
- Automatically detects your GitHub username from git config
- Priority:
github.userโ remote URL โuser.name(sanitized) - Example:
my-toolโusername-my-tool
Custom Prefix
- Use your own prefix (organization name, brand, etc.)
- Example:
--prefix acmeโacme-my-tool
NONE
- No prefix applied (only if you have a truly unique name)
- Example:
unique-server-nameโunique-server-name
Usage Examples
Interactive Mode:
hitoshura25-mcp-server-generator-cli --interactive
# You'll be prompted: "Prefix (default: AUTO): "
# - Press Enter for AUTO detection
# - Type "NONE" for no prefix
# - Type "acme" for custom prefix
Command-Line:
# AUTO mode (default)
hitoshura25-mcp-server-generator-cli --project-name calculator --prefix AUTO ...
# Custom prefix
hitoshura25-mcp-server-generator-cli --project-name calculator --prefix acme ...
# No prefix
hitoshura25-mcp-server-generator-cli --project-name unique-calculator --prefix NONE ...
MCP Server Mode:
{
"project_name": "calculator",
"prefix": "AUTO",
...
}
Generated Names
With prefix username and project my-tool:
- PyPI Package:
username-my-tool(install withpip install username-my-tool) - Python Import:
username_my_tool(use in code asimport username_my_tool) - CLI Command:
username-my-tool(run asusername-my-tool --help) - MCP Command:
mcp-username-my-tool(use in config)
For detailed MCP configuration, see MCP-USAGE.md
What Gets Generated
A complete, production-ready MCP server project:
my-mcp-tool/
โโโ .gitignore
โโโ README.md
โโโ MCP-USAGE.md
โโโ LICENSE
โโโ setup.py
โโโ pyproject.toml
โโโ requirements.txt
โโโ MANIFEST.in
โโโ my_mcp_tool/
โ โโโ __init__.py
โ โโโ server.py # MCP server implementation
โ โโโ cli.py # CLI interface
โ โโโ generator.py # Business logic (TODO stubs)
โ โโโ tests/
โ โโโ __init__.py
โ โโโ test_server.py # MCP protocol tests
โ โโโ test_generator.py # Core logic tests
โโโ .github/
โโโ workflows/
โโโ pypi-publish.yml # PyPI publishing workflow
Generated Features
- โ Working MCP server with proper JSON-RPC over stdio
- โ CLI interface with argparse
- โ Complete test suite (MCP protocol + business logic)
- โ GitHub Actions workflow for PyPI publishing
- โ Comprehensive documentation (README, MCP-USAGE)
- โ Proper Python packaging (setup.py, pyproject.toml)
- โ TODO stubs for easy implementation
Tool Definition Format
Create a tools.json file to define your MCP server's tools:
{
"tools": [
{
"name": "my_function",
"description": "Does something useful",
"parameters": [
{
"name": "input_text",
"type": "string",
"description": "Text to process",
"required": true
},
{
"name": "max_length",
"type": "number",
"description": "Maximum length",
"required": false
}
]
}
]
}
Supported Types
string/strnumber/int/integer/floatboolean/boolarray/listobject/dict
For complete examples, see EXAMPLES.md
Documentation
- MCP-USAGE.md - Detailed MCP server configuration guide
- EXAMPLES.md - Example projects and use cases
- CONTRIBUTING.md - Development and contribution guidelines
Testing
The project includes a comprehensive test suite:
# Run all tests
pytest
# Run with coverage report
pytest --cov=hitoshura25_mcp_server_generator --cov-report=term-missing
# Run specific test file
pytest hitoshura25_mcp_server_generator/tests/test_server.py -v
Test Statistics:
- 27+ comprehensive tests covering all functionality
- All async MCP protocol tests passing
- Template validation tests passing
Requirements
- Python โฅ3.8
- Jinja2 โฅ3.0
- hitoshura25-pypi-workflow-generator โฅ0.3.1
Development
See CONTRIBUTING.md for detailed development instructions.
Quick setup:
# Clone the repository
git clone https://github.com/hitoshura25/mcp-server-generator.git
cd mcp-server-generator
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
# Run tests
pytest
Architecture
mcp-server-generator follows a dual-mode architecture pattern:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ mcp-server-generator โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ MCP Mode โ โ CLI Mode โ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โ โ โ โ
โ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโผโโโโโโโโ โ
โ โ generator.py โ โ
โ โ (Core Logic) โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Both modes use the same core generator logic, ensuring consistency.
License
Apache-2.0
Author
Vinayak Menon
Links
- PyPI: https://pypi.org/project/hitoshura25-mcp-server-generator/
- GitHub: https://github.com/hitoshura25/mcp-server-generator
- Issues: https://github.com/hitoshura25/mcp-server-generator/issues
- Reference Implementation: pypi-workflow-generator
Acknowledgments
This project is based on patterns validated in pypi-workflow-generator, a production MCP server for generating GitHub Actions workflows.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hitoshura25_mcp_server_generator-0.2.0.tar.gz.
File metadata
- Download URL: hitoshura25_mcp_server_generator-0.2.0.tar.gz
- Upload date:
- Size: 92.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fe3ab353c314ab73daf01040fe20ace2a751a38c089243877f9fddb2a446810
|
|
| MD5 |
bbc11b36ea134c8f5fe804bc6441de2e
|
|
| BLAKE2b-256 |
c0fc9660198d00dbbafbcf55541991f67b5a757ed032b130cf8e416291864874
|
Provenance
The following attestation bundles were made for hitoshura25_mcp_server_generator-0.2.0.tar.gz:
Publisher:
release.yml on hitoshura25/mcp-server-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hitoshura25_mcp_server_generator-0.2.0.tar.gz -
Subject digest:
2fe3ab353c314ab73daf01040fe20ace2a751a38c089243877f9fddb2a446810 - Sigstore transparency entry: 683803405
- Sigstore integration time:
-
Permalink:
hitoshura25/mcp-server-generator@7ed41e23bd65e1aa709013cb66e9ac44640044fa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hitoshura25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ed41e23bd65e1aa709013cb66e9ac44640044fa -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file hitoshura25_mcp_server_generator-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hitoshura25_mcp_server_generator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5cb79a49d2782bb4a0f717d7e75843a6e209666fb6c79499a1b235fdc324e6c
|
|
| MD5 |
bcbd4915dfd22a60e0f21d7d707fbf0d
|
|
| BLAKE2b-256 |
5db180a0623f9b18970066161b9735dbebf4facc8a762a51f85bf9505f46be42
|
Provenance
The following attestation bundles were made for hitoshura25_mcp_server_generator-0.2.0-py3-none-any.whl:
Publisher:
release.yml on hitoshura25/mcp-server-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hitoshura25_mcp_server_generator-0.2.0-py3-none-any.whl -
Subject digest:
d5cb79a49d2782bb4a0f717d7e75843a6e209666fb6c79499a1b235fdc324e6c - Sigstore transparency entry: 683803425
- Sigstore integration time:
-
Permalink:
hitoshura25/mcp-server-generator@7ed41e23bd65e1aa709013cb66e9ac44640044fa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hitoshura25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ed41e23bd65e1aa709013cb66e9ac44640044fa -
Trigger Event:
workflow_dispatch
-
Statement type: