Template Python

MCP运维云端

提供方 unrealandychan

运维云端 stdio · 本地进程 无需鉴权 社区 / 第三方 Claude DesktopClaudeCursor
查看接入方式

一个用于构建Python MCP服务器的生产就绪的启动模板,旨在成为干净、可维护和可扩展代码库的典范。

一句话选型结论

按资料字段整理

Template Python 属于运维云端类 MCP 服务器,stdio · 本地进程,无需鉴权,可直接接入 Claude Desktop、Claude、Cursor,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类运维云端 传输方式stdio · 本地进程 鉴权无需鉴权 部署方式本地部署
GitHub 星标 0 仓库热度,无公开仓库时显示未标注
工具数 27 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

运维云端
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量27暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

MCP服务器Python本地部署Python模板生产就绪代码库管理工具库

安装与配置

stdio · 本地进程 无需鉴权
客户端在本机拉起子进程,数据不出本机
python -m venv .venv

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后客户端会列出约 27 个工具,随便调一个只读工具确认能返回结果。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
云资源查询

查实例、存储、账单等云上资源状态。

部署与发布

把部署、重启、回滚这类操作接进对话。

监控与告警

拉取监控指标,异常时让模型帮你判断。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 资料标注 27 个工具,覆盖面较广,能满足多种调用。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。
  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在运维云端场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Template Python当前 27 stdio · 本地进程 本地部署 有 2026-05-17
lobehub 未标注 stdio · 本地进程 本地部署 有 2026-04-11
TrendRadar 未标注 stdio · 本地进程 本地部署 有 2026-04-13
Ui Tars Desktop 8a825770 未标注 stdio · 本地进程 本地部署 有 2026-05-17
ruflo 未标注 stdio · 本地进程 本地部署 有 2026-04-13
FastGPT 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

运维云端
字段来自项目仓库与公开索引,中文说明由本站标注
提供方unrealandychan上游标注的维护方 unrealandychan
分类运维云端本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

9.6 KB
来自项目仓库与上游目录的原文,未做删改

Table of Contents

  • Features
  • Project Structure
  • Quick Start
  • Configuration
  • Available Tools
  • CLI Reference
  • Running Tests
  • Adding a New Tool
  • Publishing to PyPI
  • Contributing

Features

  • ✅ src layout – proper Python packaging with Hatchling build backend
  • ✅ FastMCP – modern MCP server framework with full type support
  • ✅ Pydantic v2 configuration – strongly typed, environment-driven config
  • ✅ Structured logging – rotating file + console logging, level-controlled via env
  • ✅ Typer CLI – mcp-server start / mcp-server version with rich help
  • ✅ Built-in tool library – utility, math, text, and datetime tool modules
  • ✅ Full test suite – pytest with coverage, ready for CI
  • ✅ GitHub Actions CI – lint → test → build on every push/PR
  • ✅ GitHub Actions Publish – automated TestPyPI → PyPI on version tag push
  • ✅ scripts/publish.sh – local one-command publish helper

Project Structure```

mcp-server-template-python/
├── src/
│ └── mcp_server/
│ ├── init.py # Package version & public API
│ ├── main.py # Server entry point & tool registration
│ ├── cli.py # Typer CLI (start / version)
│ ├── config/
│ │ ├── init.py
│ │ └── config.py # Pydantic config models + load_config()
│ ├── tools/
│ │ ├── init.py
│ │ ├── utility.py # Echo, Ping, Server Info
│ │ ├── math_tools.py # Add, Subtract, Multiply, Divide, Power, √, !
│ │ ├── text_tools.py # Upper/Lower, Reverse, Word Count, Emails …
│ │ └── datetime_tools.py # UTC time, timezone, date arithmetic …
│ └── utils/
│ ├── init.py
│ └── logging.py # Rotating-file + console logging setup
├── tests/
│ ├── init.py
│ ├── test_config.py
│ ├── test_logging.py
│ ├── test_main.py
│ ├── test_tools_utility.py
│ ├── test_tools_math.py
│ ├── test_tools_text.py
│ └── test_tools_datetime.py
├── examples/
│ └── basic_usage.py # Minimal runnable example
├── docs/
│ └── README.md # Extended documentation
├── scripts/
│ └── publish.sh # Local PyPI publish helper
├── .github/
│ └── workflows/
│ ├── ci.yml # Lint → Test → Build
│ └── publish.yml # Publish to TestPyPI → PyPI on tag
├── .env.example # Environment variable reference
├── pyproject.toml # PEP 621 metadata + Hatchling build
├── CHANGELOG.md
├── CONTRIBUTING.md
└── LICENSE


---

## Quick Start

### 1 – Install```bash
# Clone
git clone https://github.com/your-username/mcp-server-template-python.git
cd mcp-server-template-python

# Create & activate a virtual environment
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate

# Install in editable mode (dev extras include pytest, ruff, mypy, black…)
pip install -e ".[dev]"

# Copy and configure env
cp .env.example .env

2 – Run```bash

HTTP transport (default)

mcp-server start

stdio transport (for Claude Desktop / Cursor integration)

mcp-server start --transport stdio

Custom host / port

mcp-server start --host 127.0.0.1 --port 9000


### 3 – Verify```bash
# Check version
mcp-server version

# Run as a Python module
python -m mcp_server.main

Configuration

All settings are read from environment variables (.env is loaded automatically).

Variable Default Description
APP_NAME mcp_server Server name
HOST 0.0.0.0 Bind host
PORT 8000 Bind port
DEBUG false Enable debug mode
TRANSPORT streamable-http Transport (stdio, streamable-http, sse)
LOG_LEVEL INFO Log level
LOG_FORMAT %(asctime)s - %(name)s - %(levelname)s - %(message)s Log format
LOG_FILE_ENABLED true Write logs to file
LOG_FILE_DIR logs Log file directory
API_KEY_ENABLED false Enable API key auth
API_KEY (unset) API key value
CORS_ORIGINS * Comma-separated allowed origins

Available Tools

Utility

Tool Name Description
hello-world Returns a greeting for a given name
Echo Message Returns the message unchanged
Get Server Info Returns server name, version, description
Ping Health-check – returns "pong"

Math

Tool Name Description
Add Numbers a + b
Subtract Numbers a − b
Multiply Numbers a × b
Divide Numbers a ÷ b (raises on zero divisor)
Power base ^ exponent
Square Root √value
Factorial n!

Text

Tool Name Description
Uppercase Text Convert to UPPER CASE
Lowercase Text Convert to lower case
Reverse Text Reverse a string
Count Words Count words in text
Count Characters Count chars (optionally exclude spaces)
Title Case Convert to Title Case
Split Text Split by delimiter
Replace Text Replace all occurrences
Trim Text Strip leading/trailing whitespace
Extract Emails Find all email addresses in text

Datetime

Tool Name Description
Current UTC Time Current UTC datetime in ISO 8601
Current Date Today's date (UTC) in ISO 8601
Time In Timezone Current time in a given IANA timezone
Add Days To Date Add/subtract days from a date
Days Between Dates Count days between two dates
Format Datetime Re-format an ISO datetime with strftime

CLI Reference```

mcp-server --help

Commands:
start Start the MCP server
version Display the current version

mcp-server start --help

Options:
-h, --host Host to bind the server to [default: 0.0.0.0]
-p, --port Port to bind the server to [default: 8000]
-t, --transport Transport protocol [default: streamable-http]
-d, --debug Enable debug mode
-l, --log-level Log level [default: INFO]


---

## Running Tests```bash
# All tests
pytest

# With coverage
pytest --cov=src/mcp_server --cov-report=term-missing

# Single module
pytest tests/test_tools_math.py -v

Adding a New Tool

  1. Create src/mcp_server/tools/_tools.py.
  2. Implement register__tools(mcp_instance: FastMCP) -> None.
  3. Add the register call in src/mcp_server/main.py.
  4. Export from src/mcp_server/tools/__init__.py.
  5. Write tests in tests/test_tools_.py.

See CONTRIBUTING.md for a full skeleton and guidelines.


Publishing to PyPI

Automated (recommended)

Push a version tag to trigger the GitHub Actions publish workflow:```bash

Bump version in pyproject.toml and src/mcp_server/init.py first, then:

git commit -am "chore: release v0.2.0"
git tag v0.2.0
git push origin main --tags


The workflow publishes to **TestPyPI** first, then promotes to **PyPI**.
You must configure **Trusted Publishing** (OIDC) on both registries – no API tokens needed.

> See PyPI Trusted Publishing docs for setup.

### Manual```bash
# Build only (no upload)
./scripts/publish.sh --build-only

# Upload to TestPyPI
./scripts/publish.sh --test

# Upload to PyPI
./scripts/publish.sh

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a PR.


License

MIT © Your Name

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Template Python 怎么安装?

在客户端按下面的安装命令接入:python -m venv .venv。装完在客户端配置里引用同一个包或端点。

Template Python 怎么在 Claude Desktop、Claude、Cursor 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Template Python 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Template Python 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Template Python 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Cursor;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Template Python 能提供哪些能力?

资料显示约 27 个工具;能力标签包括 Python、Claude、生产就绪。具体工具清单以官方文档为准。

Template Python 需要什么运行环境?

运行时为 Python;属于本地进程,需要在本机装好运行环境。

Template Python 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。