BB.MCP.JsonSchema (bb_mcp v0.3.3)

Copy Markdown View Source

Converts BB command argument definitions into JSON Schema fragments.

Used to advertise command argument types to MCP clients via the list_commands tool and the commands resource, so an agent knows what to pass to the command's own {robot}.{command} tool.

Maps BB argument types to JSON Schema types:

:integer             -> %{"type" => "integer"}
:float, :number      -> %{"type" => "number"}
:boolean             -> %{"type" => "boolean"}
:string              -> %{"type" => "string"}
:atom                -> %{"type" => "string"}
{:in, values}        -> %{"type" => ..., "enum" => values}
:map, {:map, fields} -> %{"type" => "object"}
:keyword_list        -> %{"type" => "object"}
{:list, inner}       -> %{"type" => "array", "items" => ...}
:any                 -> %{}
module               -> %{"description" => "complex type: #{inspect(module)}"}

An argument declared :atom or {:in, [:a, :b]} is advertised as a string, since JSON has no atoms; BB.MCP.PeriSchema converts what the client sends back to an atom on the way to the command's goal.

Summary

Functions

Build a JSON Schema fragment for a single command argument, including description and default value where present.

Build a JSON Schema object describing a command's arguments.

Functions

for_argument(argument)

@spec for_argument(BB.Dsl.Command.Argument.t()) :: map()

Build a JSON Schema fragment for a single command argument, including description and default value where present.

for_command(command)

@spec for_command(BB.Dsl.Command.t()) :: map()

Build a JSON Schema object describing a command's arguments.