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 ispacks/maritime/client/vessel_detection.py).
Steps#
Create the family module, for example
packs/mypack/mcp/my_tools.py, with these names. They are the whole contract, described incore/mcp/src/geonemo/mcp/families.py.Name
Meaning
ORDERPosition among tools. Below 50 registers before the toolkit’s tools, otherwise after
TOOL_NAMESA 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.serverSKILLSOptional. Skills that come with the tools, in every skills catalog
EXECUTION_TOOL_NAMES,EXECUTION_SKILLSOptional. Tools and skills for durable executions only
register_resources(context)Optional. MCP resources and resource templates
Write
attachandregister. Check the scope first in every tool, then call the API throughcontext.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.annotationshasstart,readandcancel. A tool that starts work takes anIdempotencyKey. A tool that names a collection also callscontext.require_collection(scope, collection).Add the module to
DEFAULT_FAMILIESincore/mcp/src/geonemo/mcp/families.py. The server skips a family whose module is not installed, so the toolkit works without the pack.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_toolrefuses any tool outside it. Add the names to the scopes that should use them, such as theallowed_toolsof an agent definition.Update the pinned contract.
contracts/mcp/tools-v1.jsonholds 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 rundeploy/tests/test_production_mcp_canary.py, which compares the file with the registrations of a server that has every production part.If the tools need a skill, add it under
packs/mypack/skills/and list its name inSKILLS. See Write a skill. If the skill calls the tools, add them toskills/contracts/geonemo-services-tools.json.Test offline.
packs/maritime/tests/test_mcp_server_with_vessel_tools.pyshows 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.