agentleFS
paulieb89paulieb89/property-shared/.claude/skills/add-mcp-tool/SKILL.md

add-mcp-tool

Skill16 starsChanged 7 months agoMITView on GitHub

Use when adding a new MCP tool to the property MCP server (mcp_server/server.py). Provides the exact pattern with a copy-paste template.

12 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Add a new tool to mcp_server/server.py following the established FastMCP pattern.

    line 8
  2. Very specific:

    Add to mcp_server/server.py.

    line 12

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “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

Add an MCP Tool

Add a new tool to mcp_server/server.py following the established FastMCP pattern.

Step 1: Add the Tool Function

Add to mcp_server/server.py. The docstring becomes the tool description for AI hosts.

@mcp.tool()
async def new_tool(
    required_param: str,
    optional_param: Optional[str] = None,
    limit: int = 50,
) -> ToolResult:
    """One-line description of what this tool does.

    Args:
        required_param: UK postcode (e.g. "SW1A 1AA")
        optional_param: Optional filter description
        limit: Maximum results (default 50)
    """
    from property_core import SomeService  # Step 2: lazy import

    # Step 3: call property_core (sync → thread)
    result = await anyio.to_thread.run_sync(
        partial(
            SomeService().method,
            param=required_param,
            limit=limit,
        )
    )

    # Step 4: build and return ToolResult
    data = result.model_dump(mode="json")
    summary = f"Found {result.count} items for {required_param}"
    return ToolResult(content=_content(summary, data), structured_content=data)

Key Rules

  1. Lazy imports — from property_core import X inside the function body, never at module top level
  2. Async wrapping — use anyio.to_thread.run_sync(partial(...)) for sync property_core calls. For already-async functions, just await them directly.
  3. ToolResult construction:
    • content = human-readable summary + slimmed JSON (via _content() helper)
    • structured_content = full data dict for programmatic consumers
  4. Configuration-gated tools — if the data source needs credentials, check is_configured() and return early with an explanatory message if not configured. See property_epc() for the pattern.

Helpers Available

  • _slim(obj) — strips raw, images, floorplans from dicts recursively
  • _content(summary, data) — builds content string: summary + "\n\n" + slimmed JSON

Checklist

  • Tool added to mcp_server/server.py with @mcp.tool()
  • Function is async
  • Imports are lazy (inside function body)
  • Returns ToolResult with both content and structured_content
  • Summary line includes key metrics (count, median, etc.)
  • Docstring includes Args: section for all parameters

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.