Turn existing projects into MCP servers
Project description
MCPify - Export all projects as MCP servers!
MCPify is a powerful tool that automatically detects APIs in existing projects and transforms them into Model Context Protocol (MCP) servers. This enables seamless integration of your existing command-line tools, web APIs, and applications with AI assistants and other MCP-compatible clients.
๐ Features
- Automatic API Detection: Analyze existing projects and extract their API structure
- CLI Tools: Detect argparse-based command-line interfaces
- Web APIs: Support for Flask and FastAPI applications with route detection
- Interactive Commands: Identify command-based interactive applications
- Flexible MCP Server: Multiple ways to start and control MCP servers
- Multiple Backend Support: Works with command-line tools, HTTP APIs, Python modules, and more
- Configuration Validation: Built-in validation system to ensure correct configurations
- Parameter Detection: Automatically extract route parameters, query parameters, and CLI arguments
- Zero Code Changes: Transform existing projects without modifying their source code
- Professional Architecture: Clean separation between detection, configuration, and server execution
๐ฆ Installation
Using pip (recommended)
pip install mcpify
From source
git clone https://github.com/your-username/mcpify.git
cd mcpify
pip install -e .
๐๏ธ Project Architecture
mcpify/
โโโ mcpify/ # Core package
โ โโโ cli.py # CLI interface (mcpify command)
โ โโโ __main__.py # Module entry point
โ โโโ wrapper.py # MCP protocol wrapper
โ โโโ backend.py # Backend adapters
โ โโโ detect.py # API detection engine
โ โโโ validate.py # Configuration validation
โโโ examples/ # Example projects
โโโ docs/ # Documentation
โ โโโ usage.md # Detailed usage guide
โโโ tests/ # Test suite
๐ ๏ธ Quick Start
1. Detect APIs in your project
mcpify detect /path/to/your/project --output config.json
This analyzes your project and generates a configuration file containing the detected API structure.
2. View and validate the configuration
mcpify view config.json
mcpify validate config.json
This validates the generated configuration and shows any warnings or errors.
3. Start the MCP server
MCPify provides multiple ways to start MCP servers:
# Method 1: Using mcpify CLI (recommended)
mcpify serve config.json
# Method 2: Direct module invocation
python -m mcpify serve config.json
# HTTP mode for web integration
mcpify serve config.json --mode streamable-http --port 8080
# Example with provided configurations
mcpify serve examples/python-server-project/server.json
mcpify serve examples/python-server-project/server.json --mode streamable-http --port 8888
mcpify serve examples/python-cmd-tool/cmd-tool.json
๐ฏ Usage Scenarios
For Developers (API Detection & Testing)
# Detect and test your APIs
mcpify detect my-project --output my-project.json
mcpify view my-project.json
mcpify serve my-project.json
For MCP Clients (Server Integration)
# MCP clients can start servers directly
mcpify serve config.json # stdio mode
mcpify serve config.json --mode streamable-http # HTTP mode
For Production Deployment
# Deploy as HTTP server
mcpify serve config.json --mode streamable-http --host 0.0.0.0 --port 8080
๐ Backend Types & Examples
FastAPI/Flask Web Applications
{
"name": "my-web-api",
"description": "Web API server",
"backend": {
"type": "fastapi",
"base_url": "http://localhost:8000"
},
"tools": [
{
"name": "get_user",
"description": "Get user information",
"endpoint": "/users/{user_id}",
"method": "GET",
"parameters": [
{
"name": "user_id",
"type": "string",
"description": "User ID"
}
]
}
]
}
Python Modules
{
"name": "my-python-tools",
"description": "Python module backend",
"backend": {
"type": "python",
"module_path": "./my_module.py"
},
"tools": [
{
"name": "calculate",
"description": "Perform calculation",
"function": "calculate",
"parameters": [
{
"name": "expression",
"type": "string",
"description": "Mathematical expression"
}
]
}
]
}
Command-Line Tools
{
"name": "my-cli-tool",
"description": "Command line tool backend",
"backend": {
"type": "commandline",
"config": {
"command": "python3",
"args": ["./my_script.py"],
"cwd": "."
}
},
"tools": [
{
"name": "process_data",
"description": "Process data with CLI tool",
"args": ["--process", "{input_file}"],
"parameters": [
{
"name": "input_file",
"type": "string",
"description": "Input file path"
}
]
}
]
}
๐ง Configuration
Supported Backend Types
fastapi: FastAPI web applicationspython: Python modules and functionscommandline: Command-line tools and scriptsexternal: External programs and services
Server Modes
stdio: Standard input/output (default MCP mode)streamable-http: HTTP Server-Sent Events mode
Parameter Types
string,integer,number,boolean,array- Automatic type detection from source code
- Custom validation rules
โ๏ธ Server Configuration
Command Line Options
# Basic usage
mcpify serve config.json
# Specify server mode
mcpify serve config.json --mode stdio # Default mode
mcpify serve config.json --mode streamable-http # HTTP mode
# Configure host and port (HTTP mode only)
mcpify serve config.json --mode streamable-http --host localhost --port 8080
mcpify serve config.json --mode streamable-http --host 0.0.0.0 --port 9999
# Real examples with provided configurations
mcpify serve examples/python-server-project/server.json
mcpify serve examples/python-server-project/server.json --mode streamable-http --port 8888
mcpify serve examples/python-cmd-tool/cmd-tool.json --mode stdio
Server Modes Explained
STDIO Mode (Default)
- Uses standard input/output for communication
- Best for local MCP clients and development
- No network configuration needed
mcpify serve config.json
# or explicitly
mcpify serve config.json --mode stdio
Streamable HTTP Mode
- Uses HTTP with Server-Sent Events
- Best for web integration and remote clients
- Requires host and port configuration
# Local development
mcpify serve config.json --mode streamable-http --port 8080
# Production deployment
mcpify serve config.json --mode streamable-http --host 0.0.0.0 --port 8080
Environment Integration
For MCP Clients
# Claude Desktop or other MCP clients can invoke:
mcpify serve your-config.json
For Web Applications
# Start HTTP server for web integration
mcpify serve your-config.json --mode streamable-http --port 8080
# Then connect from web clients to http://localhost:8080
๐ Examples
Explore the examples/ directory for ready-to-use configurations:
# View example configurations
mcpify view examples/python-server-project/server.json
mcpify view examples/python-cmd-tool/cmd-tool.json
# Test with examples - STDIO mode (default)
mcpify serve examples/python-server-project/server.json
mcpify serve examples/python-cmd-tool/cmd-tool.json
# Test with examples - HTTP mode
mcpify serve examples/python-server-project/server.json --mode streamable-http --port 8888
mcpify serve examples/python-cmd-tool/cmd-tool.json --mode streamable-http --port 9999
๐งช Development
Running Tests
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=mcpify --cov-report=html
# Run specific tests
python -m pytest tests/test_detect.py -v
Development Setup
git clone https://github.com/your-username/mcpify.git
cd mcpify
pip install -e ".[dev]"
python -m pytest tests/ -v
Available Commands
MCPify CLI Commands
mcpify detect <project_path> [--output <file>] # Detect APIs
mcpify view <config_file> # View configuration
mcpify validate <config_file> # Validate configuration
mcpify serve <config_file> [--mode <mode>] # Start server
๐ Deployment Options
1. Package Installation
pip install mcpify
# Use mcpify serve for all scenarios
2. Module Invocation
# Run as Python module
python -m mcpify serve config.json
python -m mcpify serve config.json --mode streamable-http --port 8080
3. Docker Deployment
FROM python:3.10-slim
COPY . /app
WORKDIR /app
RUN pip install .
CMD ["mcpify", "serve", "config.json", "--mode", "streamable-http", "--host", "0.0.0.0", "--port", "8080"]
4. Production HTTP Server
# Start HTTP server for production
mcpify serve config.json --mode streamable-http --host 0.0.0.0 --port 8080
# With custom configuration
mcpify serve config.json --mode streamable-http --host 127.0.0.1 --port 9999
๐ค Contributing
We welcome contributions! Please see our development setup above and:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Code Quality
# Linting and formatting
ruff check mcpify/
ruff format mcpify/
# Type checking
mypy mcpify/
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Related Projects
- Model Context Protocol - The protocol specification
- MCP Python SDK - Official Python implementation
๐ Support
- Documentation: See
docs/usage.mdfor detailed usage instructions - Examples: Check the
examples/directory for configuration templates - Issues: GitHub Issues
- Discussions: GitHub Discussions
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 mcpify-0.1.4.tar.gz.
File metadata
- Download URL: mcpify-0.1.4.tar.gz
- Upload date:
- Size: 38.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
494d836469b4abce014e954cff4a51213363bd892d73951ee5fd39422d6492f3
|
|
| MD5 |
b3ba1990806d4570698d437d53189b58
|
|
| BLAKE2b-256 |
e71f675aec29490de0ed0d5ecffa903125bff3cd606941017c3729d5e833379d
|
File details
Details for the file mcpify-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mcpify-0.1.4-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17735b6ef835456e6e8c326ac74c657dc9f087a973dbd4b43540ab7154368306
|
|
| MD5 |
16a6cd2cd8d0f5c77b8835b85c84cc2f
|
|
| BLAKE2b-256 |
ddbf161030466b42c5c5f0a165004ccdd5ff155c19a683c27f981fbb4ff0f536
|