Wymcp. Tool. Schema
(Wymcp v0.1.1)
View Source
Builds the JSON Schema inputSchema for Wymcp tools.
One shape: the action field lists the declared action names as an enum
whose description carries the action summaries (via action_summaries/1),
one per line, and data is a bare object. The newline separator stays
unambiguous because Wymcp.Tool.validate_actions!/1 — run at boot and at
runtime registration — rejects a newline in an action's name or its
description, the two halves a summary joins. Wymcp.Tool's generated
input_schema/0 is the only caller.
The key set is closed and said so out loud: the root carries
additionalProperties: false, which is the server stating its contract in
tools/list so a schema-aware client can catch a misspelled key before it
sends. Enforcement is not this schema's job — Wymcp.Methods.ToolsCall
strips the declaration before validating and a dispatch gate answers a
stray key in the tool dialect, naming the key and pointing at help (see
"Dispatch errors and self-correction" in Wymcp.Tool). The declaration is
the root's alone: data stays a bare object, so a tool that nests
free-form structure under it is unaffected.
Per-action constraints are deliberately not encoded here: :required and
:required_one_of are enforced at dispatch by Wymcp.Tool, and the full
per-action schemas are surfaced on demand by Wymcp.Help. Property
values (types, formats) are not validated by the framework at all — a
tool that needs value guarantees checks them in run_action/3. This keeps
the tools/list payload compact; agents act from the action summaries
and pay for a tool's full schemas only when they ask.
Summary
Functions
An action summary is one action's name joined to its description as
"<action>: <description>". Returns one summary per action, sorted by
action name.
Types
Functions
An action summary is one action's name joined to its description as
"<action>: <description>". Returns one summary per action, sorted by
action name.
Single content source for both the tools/list action description and the
help tool's server index — the two render from the same list and cannot
drift.
Examples
iex> Wymcp.Tool.Schema.action_summaries(%{
...> get: %{description: "Get a widget"},
...> create: %{description: "Create a widget"}
...> })
["create: Create a widget", "get: Get a widget"]