Helpers for agent-scoped MCP tools.
Functions
required-param
fn (params: Map, name: Str): Str
Return a required string parameter or an Err with a helpful message.
Example
::mcp ::ai::agent::mcp
::mcp/required-param({title: "Launch"}, "title") // "Launch"
is-err(::mcp/required-param({}, "title")) // true
select-session
fn (params: Map, registered: Vec<::ai::session/Session>): ::ai::session/Session?
Pick a session for an MCP tool call. params.session_id may select
only a session already present in registered; otherwise the first
registered session is used. Returns null when no authorized session
can be selected.
Example
::mcp ::ai::agent::mcp
sessions [::ai::session/Session({id: "s1"}), ::ai::session/Session({id: "s2"})]
::mcp/select-session({session_id: "s2"}, sessions).id // "s2"
::mcp/select-session({}, sessions).id // "s1"
::mcp/select-session({session_id: "other"}, sessions) // null