技能潮 SkillTide 提交收录
官方说明开源项目7 天前
ori88c-python-templates/fastmcp-polyrepo-template

ori88c-python-templates/fastmcp-polyrepo-template

Production-grade FastMCP template built around dependency injection and zero global state
在 GitHub 查看 ↗直链 · 无中转页
官方说明FastMCP Polyrepo Template Production-grade FastMCP template built around **dependency injection** and **zero global state**.
★ 数取值
0 ★ · ori88c-python-templates/fastmcp-polyrepo-template · 取自该仓库的 GitHub 页面 · (2026-10-16 20:00:20 核对)
来源明细
从该仓库的 GitHub 页面直接读取 · 条目类型:开源项目
收录与活跃
收录于 2026-10-10 · 最近见到 2026-10-10 · 共见到 1 次 · 被 1 个来源列出
评分构成
综合分 103 · 1 个来源 · repo
常见问题(答案都来自我们的记录)
怎么安装?
我们【没有】从该仓库取到安装命令(我们的 install 覆盖率只有约 4%)。请看它的 README 或 releases 页。
它适合谁 / 用来做什么?
我们把它归在这些标签下: 开源项目。标签来自条目自身,不是我们强加的分类。
谁维护它、还在更新吗?
仓库 ori88c-python-templates/fastmcp-polyrepo-template;我们收录于 2026-10-10;最近见到 2026-10-10。这里没有"官方认证"或"质量评级"——我们只记录来源与时间。
第三方质量标记

FastMCP Polyrepo Template

以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →

Production-grade FastMCP template built around **dependency injection** and **zero global state**.
A composition root wires clients, services, and loggers so tests inject dependencies instead of monkeypatching; Cursor rules keep AI edits copying this architecture. Layered import DAG, Testcontainers, Prometheus, and Kubernetes probes included.
Table of Contents
- Highlights
- Why this template
- Architecture
- Layout
- Configuration
- Logging
- Demonstrative Feature - User Notes
- Running locally
- Container image
- Production deploy
- Testing
- Linting and type checking
- Pre-commit hooks
- CI
- Authentication
Highlights
- **Dependency injection, zero global state** 🧩: Every component takes dependencies in __init__; LifecycleManager (the composition root) constructs the clients, services, and loggers and wires them — main.py only builds AppConfig and that manager. No module-level config, logger, or client, so tests inject dependencies instead of monkeypatching or process-wide setup.
- **Three-layer import DAG, enforced** 🧭: The protocol surface (http_routes / mcp_primitives / middlewares / prometheus), services, and clients stay loosely coupled so you can test a service without FastMCP and a client without a registrator. Packages import downward only; lint-imports fails cycles and FastMCP leaking into services or clients.
- **Sample vertical slice** 🚩: UserNotesService plus its tool, resource, and prompt, Prometheus series, and matching integration and e2e tests. Copy that pattern for the next feature.
- **Nested Pydantic config** ⚙️: AppConfig composes resource-specific models (redis, logger, prometheus, …). Invalid config fails at startup, not on the first request.
- **Structured JSON logging** 📡: Every line carries prod-grade fields (app, instance, env, app.version, correlation_id). Each component gets a named child logger with its own context, so you can filter easily — with grep, or with observability tools such as Groundcover, Grafana, and Datadog.
- **Unit, integration, and e2e from day 1** 🧪: pytest is wired for all three: in-process units, Testcontainers against real Redis, and the real app through LifecycleManager. The notes slice is covered at each layer.
- **Cursor rules that keep the conventions** 🤖: Checked-in .cursor/rules encode layers, logging, tests, and metrics so AI-assisted edits copy this architecture instead of inventing a new one.
- **Production-shaped ops** 🚢: Non-root multi-stage image, Kubernetes liveness and readiness probes (GET /livez, GET /readyz), Prometheus scrape (GET /metrics), and GitHub Actions CI. HTTP-aware Prometheus series live in prometheus/; the notes counters live in metrics/.
- **Supply-chain hygiene** 🔒: SHA-pinned Actions, weekly Dependabot for the uv lockfile and GitHub Actions, and a separate uv audit workflow on push/PR plus a weekly schedule so a CVE published while main is idle still fails the Audit badge.
Why this template
Unlike opinionated application frameworks such as NestJS, Spring, and .NET, FastMCP does not
prescribe a strict architecture. Without widely shared project conventions, **tightly coupled
components, module-level globals, and related anti-patterns are common in Python codebases**, in
part because package docs favor short examples that use global state for brevity. The risk is
sharper in AI-assisted development: each existing pattern becomes the baseline the next
change copies. This template is a starting architecture that follows best practices from the
first commit, so you can spend the remaining effort on the product.
The guiding constraint: nothing important is reachable through a module-level global. No global
config object, no global logger, no import-time singletons. Every component declares what it needs
in its __init__, and a **single composition root** (LifecycleManager) wires those
dependencies together. That is what makes the code testable without monkeypatching and without
import-order surprises.
This template does not ship a database. For an MCP server, a database is not the usual
resource: a tool is more likely to call a service client than to query a database
来源
github · https://github.com/ori88c-python-templates/fastmcp-polyrepo-template
按领域浏览
开源项目
收录于
7 天前

更多开源项目

查看开源项目全部 731 条 →

所属领域与标签

每个标签都能点进去看同类的全部条目。数字是当前库里的真实条数。

浏览全部领域 →

← 返回索引