agentleFS
k3KAW8Pnf7mkmdSMPHz27k3KAW8Pnf7mkmdSMPHz27/MorgenMCP/.claude/skills/fastmcp/SKILL.md

fastmcp

Skill3 starsChanged 4 months agoApache-2.0View on GitHub

Up-to-date reference for FastMCP (Python MCP server framework) as used in MorgenMCP — middleware authoring, tool/resource/prompt registration, ToolError conventions, in-memory Client testing, transports. Use when modifying morgenmcp/server.py, tools/, resources.py, or writing/debugging tests against fastmcp.Client. Prefer this over memory: verify against docs/fastmcp/docs/ (pinned submodule) before relying on any API detail — FastMCP ships breaking changes across 3.x minors.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. metaspartan/cybara★ 38same name
    2. davidanthonyn/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository2 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Don't open Client inside a pytest fixture (event-loop issues) — only build/return the server there.

    line 63

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

FastMCP reference (MorgenMCP)

Pinned version: 3.4.3 (pyproject.toml: fastmcp>=3.4,<3.5). Local docs submodule docs/fastmcp/ is checked out at tag v3.4.3 (1eedd1f6) — matches the installed package exactly. Always check docs/fastmcp/docs/ before trusting a remembered API detail — online docs and this skill's own prose can describe a different version.

Facts here were verified against the pinned submodule and cross-checked with a deep-research pass (2026-07-07). Re-verify before relying on a signature if the submodule tag has moved — see reference/CHANGELOG.md.

Where MorgenMCP deviates from FastMCP defaults (know these first)

  • Call-expression registration, not decorators. server.py uses mcp.tool(name=...)(func) / mcp.resource(uri, ...)(func) instead of @mcp.tool. This is a documented-valid alternative (see reference/registration.md) chosen so tool/resource functions stay plain, independently importable async functions for unit testing.
  • ResponseCachingMiddleware is a FastMCP-provided class, imported directly from fastmcp.server.middleware.caching (not subclassed). MorgenMCP's contribution is only the configuration — CallToolSettings/ReadResourceSettings (60s TTL, which tools/resources are cached) — so a FastMCP upgrade touching this module directly affects this repo's cache behavior.
  • stdio transport only, no HTTP/auth surface. FastMCP auth (OAuth Proxy, MultiAuth) is HTTP-only by design — under stdio it is silently skipped, not rejected (run_stdio_async never reads self.auth; the server runs with skip_auth=True). So auth is simply inert here, and auth-hardening changelog entries can be skipped when assessing upgrade risk for this repo.

Quick recipes

Middleware (subclass fastmcp.server.middleware.Middleware, register via mcp.add_middleware):

from fastmcp.server.middleware import Middleware, MiddlewareContext

class LoggingMiddleware(Middleware):
    async def on_message(self, context: MiddlewareContext, call_next):
        return await call_next(context)

mcp.add_middleware(LoggingMiddleware())  # order = execution order, first added = outermost

Deny by raising, not returning falsy: ToolError / ResourceError / PromptError / McpError. on_initialize must reject before calling call_next() — raising after only logs.

Registration (call-expression form, as used in this repo):

mcp.tool(name="morgen_list_events", description=...)(list_events)
mcp.resource("morgen://calendar/{calendar_id}/events")(get_calendar_events)

Testing (in-memory, no transport — pass the server instance directly):

from fastmcp import Client

async def test_x():
    async with Client(mcp) as client:
        result = await client.call_tool("morgen_list_events", {...})
        assert result.data == {...}

Don't open Client inside a pytest fixture (event-loop issues) — only build/return the server there.

Errors: ToolError messages are always sent to the client, regardless of mask_error_details. Generic exceptions get masked to a generic string when mask_error_details=True. This is why utils.py's @handle_tool_errors converts everything to ToolError.

Transport (this repo only uses the first):

mcp.run()                                              # stdio (default) — what MorgenMCP uses
mcp.run(transport="http", host="127.0.0.1", port=8000) # Streamable HTTP → http://host:port/mcp

Topic reference (load as needed)

  • Middleware hook signatures, MiddlewareContext fields, deny-by-raising details → reference/middleware.md
  • Tool/resource/prompt registration forms, primitive-result auto-wrapping, RFC 6570 URI templates → reference/registration.md
  • Testing patterns (in-memory Client, run_server_async vs run_server_in_process) → reference/testing.md
  • Per-version changelog (3.0.0 → 3.4.3), what's a breaking change, security-hardening timeline → reference/CHANGELOG.md

Why FastMCP here (context)

MorgenMCP wraps the Morgen calendar API as an MCP server. It runs stdio-only with no auth provider, registers 22 tools, and layers FastMCP's ResponseCachingMiddleware (60s TTL, configured not subclassed) plus a virtual-ID system on top of FastMCP's tool/resource primitives. See the project's own CLAUDE.md for the full architecture — this skill only covers the FastMCP framework layer.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.