Skip to main content

multimoda MCP framework

Project description

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

🧩 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

swiftmcp-0.0.7-cp313-cp313-win_amd64.whl (703.2 kB view details)

Uploaded CPython 3.13Windows x86-64

swiftmcp-0.0.7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

swiftmcp-0.0.7-cp313-cp313-macosx_11_0_arm64.whl (808.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

swiftmcp-0.0.7-cp312-cp312-win_amd64.whl (361.0 kB view details)

Uploaded CPython 3.12Windows x86-64

swiftmcp-0.0.7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (645.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

swiftmcp-0.0.7-cp312-cp312-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file swiftmcp-0.0.7-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: swiftmcp-0.0.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 703.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swiftmcp-0.0.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1e635872e922277237c96300f3a5e2188ad5367a30ce139b65692fcd7f12f01c
MD5 975f736d4c4506f24c1e63d05ad81598
BLAKE2b-256 349d054e407440eae86646c6c95be50fd6f22f7f99c8452afba6ef264b80302c

See more details on using hashes here.

File details

Details for the file swiftmcp-0.0.7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swiftmcp-0.0.7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bda80d9e1dcbf35d07185285d380e6a7eef94361a9b8bcef771d387ee887fe8f
MD5 65ed0bd736baea07b24e979cdc20aec8
BLAKE2b-256 993ba3f0cb7bb17d0e9593780516b83129e575564355f3d23436515fd87cef24

See more details on using hashes here.

File details

Details for the file swiftmcp-0.0.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for swiftmcp-0.0.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5389c97172e5119628b7111d9c5065432e99062ad1d45ff42debb239decbca0
MD5 242d18d48eca0520cd866cbb488c5d3a
BLAKE2b-256 e8514f793964da5effd38506f5aa5bcd3d786a5a0983703b9be1cc28a4e80d86

See more details on using hashes here.

File details

Details for the file swiftmcp-0.0.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: swiftmcp-0.0.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 361.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swiftmcp-0.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cb24251f8f0297b88ee3888fb1d9d106f2b6872478515156343f2539d285b099
MD5 3b5bb53c41e4c21de6ce53f717f7382d
BLAKE2b-256 069c8caed679ddcbbc3ed3d5a73ffcd2f26b035da01b5a3f23dd1658ac80005c

See more details on using hashes here.

File details

Details for the file swiftmcp-0.0.7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swiftmcp-0.0.7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab54ad3ae19bf665e19e030fa1c81c51f12f31497f9380d4d95742a1313cb8d7
MD5 74c85bfbc165d20428b5a820b5d35b1e
BLAKE2b-256 c8cc583f44007b7de58dfcf5575da16a5481d54310e1395cd392dc5764599912

See more details on using hashes here.

File details

Details for the file swiftmcp-0.0.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for swiftmcp-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70a33b8041193603e4c34cb1fbb7163f59db2b688a0cb55d7dc602bf0dfb4b47
MD5 acc8d965979e5ae8414c47d6b6473b3a
BLAKE2b-256 19c9301e35306ff257d5b0fe000fe2e09ec6f7ced85a82e8e6715df0132e5b2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page