On this page
Tool export: descriptors for exposing CLI commands to tool-using LLM agents, mirroring Go tool.go and Python _build_json_schema/as_tools.
#typescript/src/tool
#typescript/src/tool
Tool export: descriptors for exposing CLI commands to tool-using LLM agents, mirroring Go tool.go and Python _build_json_schema/as_tools. Python is the divergence ground truth; the Go entry points are buildJSONSchema/AsTools/JsonSchema.
The JSON Schema builder maps the four scalar types to JSON Schema type strings (str -> string, bool -> boolean, int -> integer, float -> number); dict flags become "object" with additionalProperties, list flags and variadic args become "array" with items. Int enum values stay bigint -- MCP serialization (jsonCompact) emits them as bare integer tokens.
#Tool
export interface ToolA descriptor for exposing one CLI command to tool-using LLM agents.
effect and consequential publish the effects-regime classification BESIDE the argument schema (never inside it): a consumer rendering this tool must be able to see that the command changes things and that calling it requires stating consent. Same vocabulary as the schema dump: effect is mandatory, consequential defaults to false.
#buildJSONSchema
export function buildJSONSchema(Builds a JSON Schema parameters object for a command's flags and positional args (Go buildJSONSchema / Python _build_json_schema). Passthrough commands have no flags or args, so they yield the empty object schema.
#jsonSchemaForApp
export function jsonSchemaForApp(Produces the JSON Schema parameters object for a command path (Go App.JsonSchema / Python app.json_schema). Throws InvokeError when the path is invalid or resolves to a group.
#collectToolCommands
export function collectToolCommands(Collects non-hidden, non-interactive leaf commands as [dottedPath, cmd] pairs in registration order: top-level commands first, then groups (recursively; a hidden group hides its whole subtree). Shared by asTools and the MCP tools/list handler.
#asToolsForApp
export function asToolsForApp(app: AppImpl): Tool[]Exports non-hidden, non-interactive leaf commands as Tool descriptors, one per eligible command plus a trailing router tool. Each tool's execute wraps app.call().