Skip to main content

MCPify - Export all projects as MCP servers!

Python 3.10+ License: MIT

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 applications
  • python: Python modules and functions
  • commandline: Command-line tools and scripts
  • external: 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

📞 Support

  • Documentation: See docs/usage.md for detailed usage instructions
  • Examples: Check the examples/ directory for configuration templates
  • Issues: GitHub Issues
  • Discussions: GitHub Discussions

Metadata

Release files for mcpify 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcpify 0.1.4
File Size Uploaded
mcpify-0.1.4.tar.gz 38.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcpify 0.1.4
File Interpreter ABI Platform
mcpify-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 62.5 kB

Release files / mcpify-0.1.4.tar.gz

Download URL mcpify-0.1.4.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
494d836469b4abce014e954cff4a51213363bd892d73951ee5fd39422d6492f3
BLAKE2b-256 checksum
How to use checksums
e71f675aec29490de0ed0d5ecffa903125bff3cd606941017c3729d5e833379d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / mcpify-0.1.4-py3-none-any.whl

Download URL mcpify-0.1.4-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17735b6ef835456e6e8c326ac74c657dc9f087a973dbd4b43540ab7154368306
BLAKE2b-256 checksum
How to use checksums
ddbf161030466b42c5c5f0a165004ccdd5ff155c19a683c27f981fbb4ff0f536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.0

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page