Skip to main content

SwiftMCP


中文   |   English  

📝 Introduction

SwiftMCP is a multimodal Model Control Protocol (MCP) framework designed to provide flexible and extensible service interfaces for integrating and managing various model services. It simplifies the implementation and deployment of MCP protocol, supports automatic conversion from OpenAPI to MCP, and provides toolchain integration capabilities to reduce the complexity of multimodal model service access.

🎉 News

  • 🎁 2025.09.02: Release v0.0.1 package.
More
  • 🎉 2024.09.02: Add swiftmcp command support.
  • 🔥 2025.08.25: Init the project.

🛠️ Installation

Prerequisites

  • Python >= 3.11 (Recommended: 3.12)
  • pip package manager

Install from PyPI

pip install swiftmcp -U

Install from Source

git clone https://github.com/yaqiangsun/SwiftMCP.git
cd SwiftMCP
pip install -e .

🚀 Quick Start

Run serve

Start the MCP service with the following command:

swiftmcp serve --port 8080 --path /mcp

This will start an HTTP server listening on port 8080 with the MCP endpoint at /mcp. You can then access the service at http://localhost:8080/mcp.

Command Line Options

  1. serve - Start the MCP composition service (MCP service composition tools will be fused with task tools into one MCP path)

    • --port: Specify the port number (default: 8000)
    • --path: Specify the service path (default: /mcp)
  2. splitserve - Start the split MCP composition service (MCP service tools and task tools are in two independent MCP paths)

    • --manager-port: Specify the manager endpoint port number (default: 8001)
    • --manager-path: Specify the manager endpoint path (default: /mcp_manager)
    • --task-port: Specify the task endpoint port number (default: 8002)
    • --task-path: Specify the task endpoint path (default: /mcp_task)
  3. openapi2mcp - Convert OpenAPI specification to MCP service

    • --port: Specify the port number (default: 8003)
    • --path: Specify the service path (default: /mcp)
    • --target-url: Specify the target URL for OpenAPI service (default: http://0.0.0.0:10050)
  4. mcp2mcp - Proxy one MCP service to another MCP service (Proxy HTTP MCP service to form a new HTTP MCP service)

    • --port: Specify the port number (default: 8003)
    • --path: Specify the service path (default: /mcp)
    • --target-url: Specify the URL of the target MCP service
  5. toolmanager - Start the tool management service (Supports tool modification functionality)

    • --port: Specify the port number (default: 8003)
    • --manager-path: Specify the manager endpoint path (default: /mcp_manager)
    • --task-path: Specify the task endpoint path (default: /mcp_task)
    • --mcp-url: Specify the URL of the target MCP service
  6. run - Run a YAMLMCP service from a Python script file (Code and configuration are completely decoupled)

    • script: Path to the Python script containing tool definitions
    • --host: Specify the host address (default: 0.0.0.0)
    • --port: Specify the port number (default: 8003)
    • --path: Specify the service path (default: /mcp)

    Example: swiftmcp run examples/split_define_serve/tools.py

🧩 YAMLMCP Usage

YAMLMCP is a subclass of FastMCP that automatically loads configuration from a descriptions.yaml file and provides decorator factories for tool, resource, and prompt, achieving complete decoupling between code and descriptions.

Example

server.py:

import os
import yaml
from swiftmcp.core.split_define.split_mcp import YAMLMCP

yaml_path = os.path.join(os.path.dirname(__file__), "descriptions.yaml")
mcp = YAMLMCP(yaml_path=yaml_path)

# Define pure logic functions (completely clean)
@mcp.tool_wrapper
def add_numbers(a: int, b: int, scale: float = 1.0) -> int:
    return int((a + b) * scale)

@mcp.tool_wrapper
def multiply(x: float, y: float) -> float:
    return x * y

@mcp.resource_wrapper("resource://{name}/details")  # uri read from "uri" field in descriptions.yaml
def user_greeting(name: str) -> str:
    return f"Hello, {name}! Welcome to MCP service."

@mcp.resource_wrapper("default://static")
def get_greeting() -> str:
    return "Hello from FastMCP!"

@mcp.prompt_wrapper
def code_review_prompt(code: str):
    from fastmcp.prompts import Message
    return [
        Message(f"Please review the following code and identify potential issues:\n``python\n{code}\n```"),
        Message("I'm here to help you review the code.")
    ]

# Start the service
if __name__ == "__main__":
    print("Starting completely decoupled MCP service...")
    mcp.run(transport="stdio")

descriptions.yaml:

server:
  name: "MyCompleteMCPServer"
  instructions: "A complete MCP example service: including tools, resources and prompt templates"

tools:
  add_numbers:
    description: "Add two integers with optional scaling"
    parameters:
      a: "First addend, must be integer"
      b: "Second addend, must be integer"
      scale: "Optional scaling factor, default 1.0"

  multiply:
    description: "Multiply two floating point numbers"

resources:
  get_greeting:
    description: "Return a friendly static greeting"

  user_greeting:               # Note: using function name as key since path contains {variable}
    uri: "resource://{name}/details"
    description: "Generate personalized greeting based on username"

prompts:
  code_review_prompt:
    description: "Generate a code review prompt template"

This approach allows you to define function logic separately from metadata configuration, making it easier to modify descriptions, parameters and other metadata without changing the code.

✨ Features

1. MCP Composition

SwiftMCP supports composing multiple MCP services into a single endpoint, allowing you to aggregate tools from different sources.

2. HTTP Proxy

The framework provides HTTP proxy capabilities to bridge local MCP services with remote clients.

3. OpenAPI Integration

SwiftMCP can automatically convert OpenAPI/Swagger specifications into MCP tools, making it easy to integrate existing HTTP APIs.

4. Tool Management

  • Dynamic addition and removal of MCP servers
  • List available tools from mounted servers
  • Support for hiding tools from the main interface
  • Dynamic modification of tool descriptions on remote MCP services

5. Multi-Protocol Support

  • HTTP transport for remote clients
  • STDIO transport for local applications like Claude Desktop

6. Multiple Service Architectures

  • Composed Architecture: Dynamically add remote MCP services to the main service
  • Split Architecture: Management functions and task execution functions are served by different endpoints

📚 API Reference

See API Documentation for detailed documentation on SwiftMCP APIs and tool development.

🤝 Contributing

We welcome contributions! Please see our contributing guidelines for details on how to submit pull requests, report issues, or request new features.

🏛 License

This framework is licensed under the Apache License (Version 3.0). For models and datasets, please refer to the original resource page and follow the corresponding License.

📚 Examples

The following examples demonstrate various use cases of SwiftMCP:

1. Composition

Demonstrates how to compose multiple independent MCP services into a unified service.

Key features:

  • Dynamically add/remove remote MCP services
  • Aggregate tools from different sources
  • Unified management of multiple service tools

2. FastAPI Composition

Demonstrates how to build a composite MCP service using FastAPI and SwiftMCP with a separation architecture.

Key features:

  • Separation of management and task execution functions
  • Mounting multiple MCP services under different paths of the same port
  • Suitable for production environments requiring clear functional separation

3. OpenAPI to MCP Conversion

Shows how to convert an OpenAPI service to MCP tools and use them.

Key features:

  • Automatic conversion from OpenAPI specification to MCP tools
  • Integration with existing HTTP APIs
  • Easy migration from traditional REST APIs to MCP

For detailed instructions on running these examples, please refer to their respective documentation.

Metadata

Release files for swiftmcp 0.1.1

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

Built distributions (wheels)

Table of built distributions (wheels) for swiftmcp 0.1.1
File Actions
swiftmcp-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for swiftmcp-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
swiftmcp-0.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for swiftmcp-0.1.1-cp312-cp312-win_amd64.whl
swiftmcp-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for swiftmcp-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
swiftmcp-0.1.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for swiftmcp-0.1.1-cp311-cp311-win_amd64.whl
swiftmcp-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for swiftmcp-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
swiftmcp-0.1.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for swiftmcp-0.1.1-cp310-cp310-win_amd64.whl
swiftmcp-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for swiftmcp-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Total release size: 9.6 MB

Release files / swiftmcp-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL swiftmcp-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6eb676bd3d2a14fcf8b2f14b7139bebd3f202ca3ad309b4ed001954f26d4f087
BLAKE2b-256 checksum
How to use checksums
5d383d011c3be16f7d0fd3c8fb4624315f5f2579100647bed8c90ef6f887e04d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp312-cp312-win_amd64.whl

Download URL swiftmcp-0.1.1-cp312-cp312-win_amd64.whl
Size 1.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ffc3b51d3e66934bf238ece855afd55c1c931f136794e65ebda485c036d5ccc3
BLAKE2b-256 checksum
How to use checksums
0dae4dea377eb716942a1b4ccd24a4f02425b14dcf0e3d1c1d10d64dd7880ed1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL swiftmcp-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e5ade89fe3606019df41d8c997b79643c7f362b340e34fede3a378782b9f7088
BLAKE2b-256 checksum
How to use checksums
84092e09085c2634110c56a8b4ce555c12dd0f80884b901074a5629e37c2246e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp311-cp311-win_amd64.whl

Download URL swiftmcp-0.1.1-cp311-cp311-win_amd64.whl
Size 982.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
374def37ad1631f6f7a1341f1f438e84debe6b1b09e5082f9fd6e6844eda3dd4
BLAKE2b-256 checksum
How to use checksums
cf7fafc7fc643c5119eeb54d55131fed9fcd09a7b66f9313906301de874ceb3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL swiftmcp-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8caf247c31567e62d3fac662cd5d4e33aff9367172721e6990dd94872cda85e6
BLAKE2b-256 checksum
How to use checksums
858740b10db3a2fabcd114d1766274d5218081558cb6b04b5b9520d2495192dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp310-cp310-win_amd64.whl

Download URL swiftmcp-0.1.1-cp310-cp310-win_amd64.whl
Size 982.9 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
2fa75d6206e7f00a250603d8bc71a2b99e79ae2c64e355851fa3e301c309a63f
BLAKE2b-256 checksum
How to use checksums
f2f855961a18f37b12bd28f910f9c42ec2b182ea8c15a5c3d217c614fc211b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / swiftmcp-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL swiftmcp-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 593.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
61a2bbe91fc2b36eb23fda7c89ce6f41847ba1e54a55b0aee436151d0c68adf8
BLAKE2b-256 checksum
How to use checksums
70f5161a5a6714528b1340fc3d3d2a5dfb872403dc1eea46815cda141a87822d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for swiftmcp 0.1.1

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