Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Turning skills into rmcp tool routes.

route_skill adapts one Skill into an rmcp ToolRoute you can add to a ToolRouter<S>. The adapter applies the framework’s intrinsic pre-call behavior — the declarative validation gate — and then invokes the skill body:

  1. Build the MCP Tool metadata (name, description, inputSchema) from the skill.
  2. On each call, run Skill::validate. On failure, return the structured {"validation_failed": [...]} payload as the result so the calling model can correct itself without parsing English error strings — the body never runs.
  3. On success, build a SkillCtx and await the skill body.

Application-specific concerns (capability gating, backgrounding, recall, per-tool metrics) are intentionally NOT baked in here — wrap or replace this adapter when you need them. with_extra_property helps with one common extension: injecting a global argument into every tool’s schema.

Functions§

route_skill
Adapt one boxed Skill into a ready-to-register ToolRoute. Applies the declarative validation gate before invoking the skill body. See the module docs for the exact behavior.
route_skill_gated
Like route_skill, but also enforces a system-requirements gate.
routes_gated
Resolve capabilities for a whole tool set and build a capability-gated ToolRoute for every skill in one step. Returns the routes alongside the resolved Capabilities map — keep the map for a startup log line or a status snapshot. Equivalent to crate::capability::resolve followed by route_skill_gated per skill.
with_extra_property
Inject a property into a tool’s argument schema, returning a new schema.