robonix_api.tool

Contract-enforced MCP tools on top of FastMCP + robonix-codegen ROS dataclasses.

The decorator stashes the codegen IO classes + contract id on the original handler so Capability.run() can derive atlas DeclareCapability metadata (JSON Schema, description) without re-reflecting annotations.

Functions

io_types_from_handler(user_fn, *, contract_id)

json_prop_to_py_type(prop)

make_shim(user_fn, input_cls, out_cls)

mcp_contract(mcp, *, contract_id[, ...])

Register an MCP tool bound to a contract.

wire_output_for_json(value)

robonix_api.tool.mcp_contract(mcp: FastMCP, *, contract_id: str, structured_output: bool | None = None) Callable[[Callable[..., Any]], Callable[..., Any]][source]

Register an MCP tool bound to a contract.

Use directly with your own FastMCP app, OR use the provider’s @<provider>.mcp(…) decorator (Primitive / Service / Skill) for a one-stop registration that also auto-declares to atlas + manages uvicorn.

The MCP-server-side tool name is always the contract_id’s leaf segment — executor’s dispatch derives the same value from contract_id (see executor/dispatch/mcp.rs mcp_tool_name). They must match; we enforce that by deriving from a single source.

Stashes the codegen IO classes + contract id on the original handler:

fn._robonix_input_cls fn._robonix_output_cls fn._robonix_contract_id

The provider framework picks these up via attribute reflection during run().