agentleFS
matthullmatthull/my-skills/skills/technical/fastmcp-python/SKILL.md

fastmcp-python

Skill0 starsChanged 55 days agoMITView on GitHub

FastMCP/Python MCP server development — tool design, naming conventions, pytest, tmux-sidecar E2E testing. Load this skill when building or modifying MCP servers.

  • Reads credentials

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Use snake_case for tool function names

    line 12
  2. Distinctive:

    Test tool discoverability after adding new tools

    line 14
  3. Distinctive:

    Never use colon namespacing (FastMCP doesn't support it).

    line 16
  4. Distinctive:

    Verify tool appears in tool list

    line 25
  5. Distinctive:

    Test invocation in a fresh Claude session (tmux-sidecar)

    line 26
  6. Distinctive:

    When API credentials are available:

    line 34
  7. Distinctive:

    If credentials NOT yet available: flag in handoff, implementer must smoke-test first.

    line 46
  8. Distinctive:

    Default values for optional parameters

    line 63
  9. Very specific:

    Run pytest from the project directory.

    line 71
  10. Very specific:

    Project setup requirement: Every MCP project MUST have pytest in dev dependencies and [tool.pytest.ini_options] in pyproject.toml.

    line 79
  11. Distinctive:

    Use colon namespacing in tool names

    line 129
  12. Distinctive:

    Default parameter values for optional args

    line 139

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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/Python Practice

CRITICAL: Tool Naming Convention (ABSOLUTE)

FastMCP uses Python function names directly as MCP tool names.

  • Use snake_case for tool function names
  • MCP tool name will be: mcp__<server-name>__<function_name>
  • Test tool discoverability after adding new tools

Never use colon namespacing (FastMCP doesn't support it).


CRITICAL: Verify Tools are Discoverable (ABSOLUTE)

You MUST verify new/modified tools are visible to Claude Code before handoff.

  • Restart MCP server after code changes
  • Verify tool appears in tool list
  • Test invocation in a fresh Claude session (tmux-sidecar)

CRITICAL: Smoke-Test Real APIs Before Coding (ABSOLUTE)

Never build response parsing from documentation alone when wrapping an external API.

When API credentials are available:

  1. Make a real API call (curl) BEFORE writing parsing code
  2. Paste actual JSON response into implementation notes
  3. Build all data mappings from REAL response, not docs
  4. Note divergences from docs explicitly

Common divergences this catches:

  • Enum values with/without prefixes
  • Flat vs nested fields
  • Top-level vs array-nested data
  • Absent fields the docs claim exist

If credentials NOT yet available: flag in handoff, implementer must smoke-test first.


Tool Function Pattern

@mcp.tool()
async def tool_name(param1: str, param2: int = 10) -> str:
    """One-line description shown in tool list.

    Longer description with usage details.
    """
    return "result string"
  • Type hints on all parameters (used for tool schemas)
  • Default values for optional parameters
  • Docstring first line = tool description
  • Return strings (not dicts) — Claude reads return as text

Running Tests

Run pytest from the project directory. That's it.

pytest -v                        # all tests
pytest test_something.py -v      # one file
pytest test_something.py::TestClass::test_method -v  # one test

Project setup requirement: Every MCP project MUST have pytest in dev dependencies and [tool.pytest.ini_options] in pyproject.toml. If a project is missing this, add it before writing tests:

[dependency-groups]
dev = [
    "pytest>=8.0.0",
    "pytest-asyncio>=0.23.0",
]

[tool.pytest.ini_options]
testpaths = ["."]
python_files = ["test_*.py"]
asyncio_mode = "auto"

Verification Loops

Loop 1 (Unit Tests): pytest -v

Loop 2 (MCP Server Starts + Discovery) — MANDATORY:

CLAUDECODE= claude mcp list   # Must show ✓ Connected
claude mcp restart <server>    # Pick up changes

Unit tests alone are NOT sufficient — they don't exercise the full import chain, dependency resolution, or MCP protocol handshake.

Loop 3 (E2E via tmux-sidecar): Fresh Claude session in split pane, send test prompt, capture output. Kill and recreate pane between tests for fresh MCP server instance.


Checklist

  • Tool function names are snake_case
  • All tools have type-hinted parameters and docstrings
  • pytest passes
  • Tool is discoverable (claude mcp list shows Connected)
  • .env.example updated if new env vars
  • Error handling returns descriptive strings (not exceptions)
  • Tools are idempotent where possible
  • Existing tools still work

Anti-patterns

You MUST NEVER:

  • Use colon namespacing in tool names
  • Skip pytest
  • Skip E2E verification (unit tests don't catch MCP protocol issues)
  • Commit .env files
  • Return complex objects (return formatted strings)
  • Assume server auto-reloads

Prefer:

  • Single server.py for small servers
  • Descriptive first-line docstrings
  • Default parameter values for optional args
  • Graceful error messages in return strings
  • Fresh tmux pane per E2E test run

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.

Reviews can't be read right now.

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.