Skip to main content

mcp-modelservice-sdk

🚀 Easily build and deploy MCP (Model Context Protocol) services from your Python functions

PyPI version Python 3.10+ License: MIT

mcp-modelservice-sdk is a powerful toolkit that transforms your Python functions into fully-featured MCP services with minimal configuration. Perfect for developers who want to quickly expose their Python code as MCP tools without the complexity of manual service setup.

✨ Key Features

  • 📦 Zero-Config Packaging: Convert Python functions to MCP services instantly
  • 🚀 One-Command Deployment: Start services with a single command
  • 🔄 Smart Auto-Routing: Automatic endpoint generation based on your code structure
  • 🌐 Production Ready: Built-in support for Docker, cloud platforms, and scaling
  • 🛠️ Developer Friendly: Interactive testing interface and comprehensive documentation
  • 🎯 Type Safe: Full support for Python type hints and automatic validation

🚀 Quick Start

Installation

# Using pip
pip install mcp-modelservice-sdk

# Using uv (recommended)
pip install uv
uv pip install mcp-modelservice-sdk

Basic Usage

  1. Create your Python functions:
# my_tools.py
def add_numbers(a: float, b: float) -> float:
    """Add two numbers together"""
    return a + b

def get_weather(city: str) -> str:
    """Get weather information for a city"""
    return f"Weather in {city}: Sunny, 25°C"
  1. Run as MCP service:
# Start local development server
mcp-modelservice run --source-path my_tools.py --port 8080

# Or with uv
uvx mcp-modelservice-sdk run --source-path my_tools.py --port 8080
  1. Test your service:
    • Visit http://localhost:8080/mcp for interactive testing
    • Use any MCP client to connect and call your functions

Production Packaging

# Package for deployment
mcp-modelservice package --source-path ./my_code --output my-service.zip

# Extract and deploy
unzip my-service.zip
cd my-service/project
python main.py

🏗️ How It Works

The SDK automatically:

  • Discovers all functions in your Python files
  • Converts them to MCP-compatible tools with proper schemas
  • Generates REST endpoints and documentation
  • Packages everything into deployable services
  • Provides interactive testing interfaces

Architecture Modes

  • Composed Mode: All tools accessible from a single endpoint
  • Routed Mode: Directory-based routing with separate endpoints per module

🌐 Deployment Options

Deploy anywhere Python runs:

  • Local Development: Direct execution with python main.py
  • Docker: Pre-configured Dockerfile included
  • Cloud Platforms: Compatible with Heroku, AWS Lambda, Google Cloud Run, Azure
  • Traditional Servers: Standard WSGI/ASGI deployment

📚 Client Integration

Python Client Example

import requests

def call_tool(tool_name, params):
    response = requests.post(
        "http://localhost:8080/mcp",
        json={
            "jsonrpc": "2.0",
            "method": tool_name,
            "params": params,
            "id": 1
        }
    )
    return response.json()

# Use your functions
result = call_tool("add_numbers", {"a": 5, "b": 3})
print(result)  # {"jsonrpc": "2.0", "result": 8, "id": 1}

FastMCP Client Example

from fastmcp import FastMCP

client = FastMCP("http://localhost:8080")
result = await client.call_tool("add_numbers", {"a": 5, "b": 3})

⚙️ Configuration

Command Line Options

Option Description Default
--source-path Path to Python files/directory Current directory
--port Service port 8080
--host Service host 127.0.0.1
--mcp-name Service name Auto-generated

Environment Variables

# .env file
HOST=0.0.0.0
PORT=8080
MCP_SERVER_NAME=my-service
LOG_LEVEL=INFO

🤝 Use Cases

Perfect for:

  • Rapid Prototyping: Quickly expose Python functions as web services
  • Microservices: Convert existing Python modules to independent services
  • API Generation: Auto-generate REST APIs from Python functions
  • Tool Integration: Make Python tools accessible to MCP clients
  • Development Testing: Interactive testing of Python functions

🛠️ Requirements

  • Python: 3.10 or higher
  • Dependencies: FastAPI, FastMCP, Pydantic, Uvicorn (auto-installed)

📖 Documentation & Support

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ for the Python and MCP communities

Ready to transform your Python functions into powerful MCP services? Install mcp-modelservice-sdk today!

Metadata

Release files for mcp-modelservice-sdk 0.2.6

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

Source distribution (sdist)

Source distribution for mcp-modelservice-sdk 0.2.6
File Size Uploaded Provenance
mcp_modelservice_sdk-0.2.6.tar.gz 56.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-modelservice-sdk 0.2.6
File Interpreter ABI Platform
mcp_modelservice_sdk-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 111.5 kB

Release files / mcp_modelservice_sdk-0.2.6.tar.gz

Download URL mcp_modelservice_sdk-0.2.6.tar.gz
Size 56.0 kB
Tags Source
SHA-256 checksum
How to use checksums
de6404d4daa5cd5d1dcf7151fb4789692bd6951c71b1cc8dcf98997ab885f7e1
BLAKE2b-256 checksum
How to use checksums
b77a82a1276055364dfab5342fb0762afa2ded590f2ee75bb1d676343a499c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release files / mcp_modelservice_sdk-0.2.6-py3-none-any.whl

Download URL mcp_modelservice_sdk-0.2.6-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcb7757a7f25fe123ad3e5eaab3010fdb9dfd0a33fcb82cd245e51ae070135a2
BLAKE2b-256 checksum
How to use checksums
a9fa16b4864eb05e525ea75e22d8c0b89b677488940dd442e78ac5deacac870c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Security for mcp-modelservice-sdk 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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