Add an MCP tool family#

Add tools to the MCP server from a part, without editing the toolkit’s own tools.

A tool family is a module the MCP server loads by name. The maritime pack’s packs/maritime/mcp/vessel_tools.py is the worked example: six tools that start, read, render and cancel vessel-detection runs through the pack’s API client.

Prerequisites#

  • A pack with routes the tools call. See Write a pack.

  • A typed API client for those routes, built on ServiceAreaClient (the maritime pack’s is packs/maritime/client/vessel_detection.py).

Steps#

  1. Create the family module, for example packs/mypack/mcp/my_tools.py, with these names. They are the whole contract, described in core/mcp/src/geonemo/mcp/families.py.

    Name

    Meaning

    ORDER

    Position among tools. Below 50 registers before the toolkit’s tools, otherwise after

    TOOL_NAMES

    A frozenset of the tool names the family adds

    attach(client)

    Adds the pack’s area client to the client the tools call

    register(context)

    Registers the tools on context.server

    SKILLS

    Optional. Skills that come with the tools, in every skills catalog

    EXECUTION_TOOL_NAMES, EXECUTION_SKILLS

    Optional. Tools and skills for durable executions only

    register_resources(context)

    Optional. MCP resources and resource templates

  2. Write attach and register. Check the scope first in every tool, then call the API through context.invoke.

    from geonemo.mcp.families import Identifier, ToolContext
    
    ORDER = 90
    TOOL_NAMES = frozenset({"my_tool_get"})
    
    def attach(client):
        client.my_area = MyAreaClient(transport=client.transport)
    
    def register(context: ToolContext) -> None:
        server, scope = context.server, context.scope
    
        @server.tool(
            name="my_tool_get",
            title="Get a thing",
            description="Read one thing by ID.",
            annotations=context.annotations["read"],
            structured_output=True,
        )
        async def get(thing_id: Identifier) -> Thing:
            context.require_tool(scope, "my_tool_get")
            return await context.invoke(
                context.factory, lambda client: client.my_area.get(thing_id)
            )
    

    context.annotations has start, read and cancel. A tool that starts work takes an IdempotencyKey. A tool that names a collection also calls context.require_collection(scope, collection).

  3. Add the module to DEFAULT_FAMILIES in core/mcp/src/geonemo/mcp/families.py. The server skips a family whose module is not installed, so the toolkit works without the pack.

  4. Grant the tools. A caller’s scope lists the tools it may call in allowed_tools (ToolScope, core/mcp/src/geonemo/mcp/scope.py); context.require_tool refuses any tool outside it. Add the names to the scopes that should use them, such as the allowed_tools of an agent definition.

  5. Update the pinned contract. contracts/mcp/tools-v1.json holds every tool with its input schema, plus resources and resource templates. There is no generator script: edit the file so it matches the live registrations, and run deploy/tests/test_production_mcp_canary.py, which compares the file with the registrations of a server that has every production part.

  6. If the tools need a skill, add it under packs/mypack/skills/ and list its name in SKILLS. See Write a skill. If the skill calls the tools, add them to skills/contracts/geonemo-services-tools.json.

  7. Test offline. packs/maritime/tests/test_mcp_server_with_vessel_tools.py shows how to build the server with a fake client and assert the tools, schemas and scope checks.

Result#

geonemo-mcp and the HTTP MCP server list the new tools when the pack is installed, and MCP tools shows them once the contract file is updated.