fastmcp-spec

FastMCP service specification programming assistant. Used when developing new features, adding interfaces, refactoring existing projects, or needing to follow team coding conventions in MCP service projects based on the FastMcpSvcDemo template. Trigger scenarios include adding MCP tools, HTTP routes, writing OpenAPI documentation, creating test scripts, configuration management, logging and response format standards, dependency management, and MCP client configuration. Ensures the three-piece design (MCP tool + HTTP route + OpenAPI doc) and unified response format, and requires managing dependencies with uv and pyproject.toml.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "fastmcp-spec" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5e7307973a60e6ea7a6fabe8476bf269b0a41e4ae7017fe77d6bc031844485e1. Verify the upstream source and version against https://skillhub.cn/skills/user_b785198a/fastmcp-spec before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

FastMCP service specification programming assistant. Used when developing new features, adding interfaces, refactoring existing projects, or needing to follow team coding conventions in MCP service projects based on the FastMcpSvcDemo template. Trigger scenarios include adding MCP tools, HTTP routes, writing OpenAPI documentation, creating test scripts, configuration management, logging and response format standards, dependency management, and MCP client configuration. Ensures the three-piece design (MCP tool + HTTP route + OpenAPI doc) and unified response format, and requires managing dependencies with uv and pyproject.toml.

0 Downloads

Introduction source: third_party · user_b785198a · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: fastmcp-spec
description: "FastMCP 服务规约编程助手。当用户在基于 FastMcpSvcDemo 模板的 MCP 服务项目中开发新功能、添加接口、改造旧项目、或需要遵循团队编程规约时,应使用此 Skill。触发场景包括:添加新 MCP 工具、添加 HTTP 路由、编写 OpenAPI 文档、创建测试脚本、配置管理、日志规范、响应格式规范、依赖管理、MCP 客户端配置等。当用户说添加一个接口、新增一个工具、写个测试脚本、改造项目、添加依赖、配置 MCP 客户端时应自动触发此 Skill。此 Skill 确保所有开发工作遵循三件套设计模式(MCP工具+HTTP路由+OpenAPI文档)和统一的响应格式规范,并强制使用 uv + pyproject.toml 管理项目依赖。"

FastMCP 服务规约编程助手

概述

此 Skill 为基于 FastMcpSvcDemo 模板的 MCP 服务项目提供规约编程指导。确保所有开发工作遵循团队统一的编程规范,包括三件套设计模式、统一响应格式、日志规范、测试脚本规范、uv + pyproject.toml 依赖管理规范、MCP 客户端配置规范(mcp.json.example)等。

何时使用

  • 在 FastMcpSvcDemo 模板项目或其衍生项目中添加新功能
  • 需要同时创建 MCP 工具 + HTTP 路由 + OpenAPI 文档(三件套)
  • 创建 curl 测试脚本
  • 添加、移除或更新项目依赖(必须使用 uv + pyproject.toml)
  • 改造旧项目使其符合规约
  • 需要确认代码是否符合规约

核心规约速查

阅读 references/spec_rules.md 获取完整的规约规则。以下是关键规约摘要:

三件套设计模式(最重要)

添加新功能时必须同时完成四件事,缺一不可:

序号 文件 作用
1 src/tools/demo_tools.py 注册 MCP 工具 @mcp.tool()
2 src/routers/message_router.py 添加 HTTP 路由 @mcp.custom_route()
3 src/routers/openapi_router.py 在 OPENAPI_SPEC["paths"] 添加文档
4 tests/test_api_<name>.sh 创建 curl 测试脚本

统一响应格式

MCP 工具 返回:

{"success": true, "error": null, "data": { ... }}

HTTP 路由 返回:

{"success": true, "data": { ... }}

错误响应:

{"success": false, "error": "错误描述", "data": null}

文档字符串规范

每个函数必须有 docstring,包含功能描述、Args: 和 Returns::

def my_function(param: str) -> dict:
    """功能简述

    Args:
        param: 参数说明

    Returns:
        返回值说明
    """

工作流程

添加新功能

当用户要求添加新功能/接口/工具时,按以下顺序执行:

  1. 读取参考文档:阅读 references/spec_rules.md 了解完整规约
  2. 阅读现有代码:读取三件套文件了解现有代码风格
    • src/tools/demo_tools.py
    • src/routers/message_router.py
    • src/routers/openapi_router.py
  3. 创建 MCP 工具:在 src/tools/demo_tools.py 的 register_tools() 函数内添加 @mcp.tool() 装饰的函数
  4. 创建 HTTP 路由:在 src/routers/message_router.py 的 register_message_routes() 函数内添加 @mcp.custom_route() 路由
  5. 添加 OpenAPI 文档:在 src/routers/openapi_router.py 的 OPENAPI_SPEC["paths"] 中添加接口文档
  6. 更新端点列表:在 openapi_router.py 的 api_root 函数中添加新端点
  7. 创建测试脚本:在 tests/ 目录创建 test_api_<name>.sh,遵循 references/test_template.sh 模板
  8. 更新 README.md:在 MCP 工具表格和 HTTP 端点表格中添加新条目

代码编写规范

编写代码时遵循以下规范:

  • URL 命名:/api/v1/<模块名>/<操作名>
  • 日志:使用 logger = logging.getLogger(__name__),ERROR 级别带 exc_info=True,日志级别必须从 conf/config.ini 的 [logging].level 读取,禁止硬编码
  • 异常处理:所有函数用 try-except 包裹,错误返回统一格式
  • 配置:所有配置项走 conf/config.ini,通过 from src.config.config_loader import config 使用
  • 注释:所有函数必须有完整 docstring(功能、Args、Returns)
  • 依赖管理:所有依赖必须声明在 pyproject.toml 中,使用 uv add/remove 管理,禁止 pip 和 requirements.txt
  • Python 执行:必须通过 uv run python 运行,禁止直接 python 或 python3
  • MCP 客户端配置:项目必须提供 mcp.json.example,包含无鉴权和带鉴权两种配置,参考 references/mcp_json_template.json

改造旧项目

当用户要求改造旧项目时:

  1. 阅读 references/spec_rules.md 中的「旧项目改造指南」部分
  2. 按 Phase 1 → Phase 2 → Phase 3 顺序改造
  3. 改造完成后,对照改造检查清单逐条验证

参考文档

文件 内容
references/spec_rules.md 完整的规约规则(A~K),包含正例/反例和检查清单
references/test_template.sh curl 测试脚本模板
references/tool_template.py MCP 工具代码模板
references/route_template.py HTTP 路由代码模板
references/mcp_json_template.json MCP 客户端配置示例模板(mcp.json.example)

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 为 FastMcpSvcDemo 模板项目提供规约编程指导,解决开发标准化问题
  • 覆盖添加新功能、改造旧项目、依赖管理等多个实用场景
Trigger Precision90/100

Highlights

  • 触发场景描述详细,覆盖添加接口、新增工具、写测试脚本等多种情况
  • 边界清晰,易于用户理解何时使用此 Skill
Structure and Standards95/100

Highlights

  • 结构清晰,包含概述、核心规约、工作流程等完整部分
  • 步骤划分明确,提供了详细的执行流程和规范说明
Execution Reliability90/100

Highlights

  • 工具来源明确(uv、pyproject.toml),参数和配置管理规范
  • 覆盖了主要异常处理,不可逆操作有明确规范
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.