Turn existing projects into MCP servers
Project description
MCPify
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
- MCP Server Generation: Convert any project into a fully functional MCP server
- Multiple Backend Support: Works with command-line tools, HTTP APIs, 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
- Flexible Configuration: Fine-tune tool definitions and parameters through JSON configuration
๐ฆ Installation
Using pip (recommended)
pip install mcpify
From source
git clone https://github.com/your-username/mcpify.git
cd mcpify
pip install -e .
๐ ๏ธ Quick Start
1. Detect APIs in your project
mcpify detect /path/to/your/project
This will analyze your project and generate a project-name.json configuration file containing the detected API structure.
2. Validate the configuration
mcpify validate project-name.json --verbose
This validates the generated configuration and shows any warnings or errors.
3. Start the MCP server
mcpify start project-name.json
Your project is now running as an MCP server, ready to be used by AI assistants and other MCP clients!
๐ Usage Examples
Command-Line Tool Integration
For CLI tools with argparse:
# cli_tool.py
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--hello', action='store_true', help='Say hello')
parser.add_argument('--echo', type=str, help='Echo a message')
parser.add_argument('--add', nargs=2, type=float, help='Add two numbers')
args = parser.parse_args()
if args.hello:
print("Hello!")
elif args.echo:
print(f"Echo: {args.echo}")
elif args.add:
print(f"Result: {args.add[0] + args.add[1]}")
MCPify automatically generates:
{
"backend": {
"type": "commandline",
"config": {
"command": "python3",
"args": ["cli_tool.py"],
"cwd": "."
}
},
"tools": [
{
"name": "hello",
"description": "Say hello",
"args": ["--hello"],
"parameters": []
},
{
"name": "echo",
"description": "Echo a message",
"args": ["--echo", "{message}"],
"parameters": [
{
"name": "message",
"type": "string",
"description": "The message value"
}
]
}
]
}
Interactive Command Applications
MCPify can detect interactive command-based applications:
# server.py
def main():
while True:
line = input()
if line.lower() == 'hello':
print("Hello there!")
elif line.lower().startswith('echo '):
message = line[5:]
print(f"Echo: {message}")
elif line.lower() == 'quit':
break
Detected commands:
hello- Simple commandecho- Command with message parameter
FastAPI Application
MCPify can automatically detect FastAPI applications and their endpoints:
# main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/todos/{todo_id}")
async def get_todo(todo_id: int):
return {"id": todo_id, "title": "Sample todo"}
@app.post("/todos")
async def create_todo(todo: dict):
return {"id": 1, **todo}
MCPify will detect:
- Route parameters (
{todo_id}) - HTTP methods (GET, POST, PUT, DELETE, PATCH)
- Query parameters
- Proper parameter types
Generated configuration:
{
"name": "fastapi-app",
"description": "FastAPI application",
"backend": {
"type": "http",
"config": {
"base_url": "http://localhost:8000",
"timeout": 30
}
},
"tools": [
{
"name": "root",
"description": "GET / endpoint",
"args": ["/"],
"parameters": []
},
{
"name": "get_todo",
"description": "GET /todos/{todo_id} endpoint",
"args": ["/todos/{todo_id}", "{todo_id}"],
"parameters": [
{
"name": "todo_id",
"type": "integer",
"description": "The todo_id parameter"
}
]
}
]
}
๐ง Configuration
MCPify uses JSON configuration files to define how your project should be exposed as an MCP server.
Backend Types
- commandline: Execute command-line tools
- http: Call HTTP REST APIs
- websocket: Connect to WebSocket endpoints
Parameter Types
MCPify supports various parameter types:
string: Text inputinteger: Whole number inputnumber/float: Numeric inputboolean: True/false valuesarray: List of values
Validation
The built-in validation system checks:
- Required fields presence
- Parameter type consistency
- Backend configuration validity
- Tool name uniqueness
- Parameter usage in arguments
๐ Example Projects
The repository includes several example projects:
FastAPI Todo Server
cd example-projects/fastapi-todo-server
uvicorn main:app --reload
# In another terminal:
mcpify detect . --output todo-api.json
mcpify validate todo-api.json
Features:
- Complete CRUD API for todo management
- Path parameters (
{todo_id}) - Query parameters for filtering
- Automatic OpenAPI documentation
Python Server Project
cd example-projects/python-server-project
python server.py &
mcpify detect . --output server-api.json
Features:
- Interactive command processing
- Simple text-based protocol
- Multiple command types
๐งช 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 test files
python -m pytest tests/test_detect.py tests/test_validate.py -v
Project Structure
mcpify/
โโโ mcpify/ # Main package
โ โโโ cli.py # Command-line interface
โ โโโ detect.py # API detection engine
โ โโโ validate.py # Configuration validation
โ โโโ backend.py # Backend abstraction layer
โ โโโ wrapper.py # MCP protocol wrapper
โ โโโ __init__.py
โโโ tests/ # Test suite
โ โโโ test_detect.py
โ โโโ test_validate.py
โ โโโ __init__.py
โโโ example-projects/ # Example configurations
โ โโโ fastapi-todo-server/
โ โโโ python-server-project/
โโโ README.md
โโโ pyproject.toml
Available Commands
# Detect APIs in a project
mcpify detect <project_path> [--output <file>] [--openai-key <key>]
# Validate a configuration file
mcpify validate <config_file> [--verbose]
# Start an MCP server (coming soon)
mcpify start <config_file>
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details on:
- Setting up the development environment
- Running tests and linting
- Submitting pull requests
- Reporting issues
Development Setup
git clone https://github.com/your-username/mcpify.git
cd mcpify
pip install -e ".[dev]"
python -m pytest tests/ -v
๐ 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: Full documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with โค๏ธ by the MCPify team
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.0.3.tar.gz.
File metadata
- Download URL: mcpify-0.0.3.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0f6225c9009f1f1993af6ad17ca957c5aeb6d67808e64de0fa556a2ca0c21a
|
|
| MD5 |
37aa7cef084efc9c4a86224492098810
|
|
| BLAKE2b-256 |
59ff86e28a3b94b3e724a41ba5af0fd20ed6096942a135d441f3f9e6bef30cb3
|
File details
Details for the file mcpify-0.0.3-py3-none-any.whl.
File metadata
- Download URL: mcpify-0.0.3-py3-none-any.whl
- Upload date:
- Size: 23.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 |
bd2c1d728458ae00ac4d65083652d37aa733958061cdbf8a83ec1817c4b869d1
|
|
| MD5 |
71b124b48308d16f6793f1222f4ab7d6
|
|
| BLAKE2b-256 |
46a936dd7165c7ecb4394c841ee6d5ec81adc881d2d77780603d243fb7760ecd
|