MCP.so
Sign In
Servers

🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务

@liuhaotian9420

A cli tool to auto discover and build MCP service from Python files

Overview

What is 🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务?

🚀 MCPY-CLI is a command-line toolkit that converts one or more Python functions or scripts into standard MCP (Model Context Protocol) services. It automatically generates service routes, supports multiple transport protocols, and offers one‑click deployment. It is designed for developers who want to quickly build and deploy MCP services from existing Python code.

How to use 🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务?

Install via pip install mcpy-cli (requires Python ≥ 3.10 and FastMCP). Use mcpy-cli run --source-path <file_or_dir> to launch a local MCP service on port 8080 (default). Use mcpy-cli package --source-path <path> --package-name <name> to package the service for production. Options include --mode (composed/routed) and --enable-event-store for persistence.

Key features of 🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务?

  • Converts Python functions into MCP tools automatically.
  • Supports two server architectures: composed and routed.
  • Provides both local run and production packaging commands.
  • Offers Streamable HTTP transport (default) and legacy SSE.
  • Supports event store persistence with SQLite.
  • Includes session‑level tool call caching for performance.

Use cases of 🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务?

  • Quickly expose existing Python utility functions as MCP tools.
  • Prototype and debug MCP services with automatic reload during development.
  • Package multiple Python modules into a deployable MCP service for production.
  • Build modular MCP services with separate routes for different tool groups (routed mode).

FAQ from 🚀 MCPY-CLI: 快速从 Python 文件构建 MCP 服务?

What are the dependencies and runtime requirements?

Python ≥ 3.10 and the FastMCP library are required. The uv package manager is recommended but not mandatory.

How does persistence work?

By using the --enable-event-store flag, the service stores JSON‑RPC messages in a local SQLite database (default ./mcp_event_store.db), enabling state recovery after restarts. The path can be customized with --event-store-path.

What transport protocols are supported?

The default transport is Streamable HTTP (stable and recommended). Legacy SSE mode can be enabled via --legacy-sse but is deprecated and may have path issues in cloud environments like Knative/Istio.

How does caching work?

The SessionToolCallCache is an in‑memory cache tied to a user session. It stores results of tool calls performed with the same arguments, avoiding redundant executions. It is primarily active in stateful JSON response mode.

What are the two server modes?

  • Composed mode (default): All tools are mounted under one FastMCP instance; tool names are prefixed with the source file name.
  • Routed mode: Each file gets its own FastMCP instance serving at a separate URL path (e.g., /math_tools).

Tags

More from Developer Tools