ExAgent.Chat.InputForm (ExAgent v3.0.0)

View Source

Present and answer a bounded flat MCP form on an authorized deferred call.

Stability — Stable.

Load the call from the authorized Server and resolve the agent and tool for its saved definition. For a delegated call, use the child definition from the root's inbox item. present/2 runs the agent's tool-output guards on the form requests and returns form and field descriptors for display. The projection omits the peer's opaque state and the tool arguments. Render the strings as text.

responses/3 takes submitted strings in nested maps keyed by decimal form and field positions (starting at zero). It parses primitive values, checks the peer's schema and returns responses for the candidate MCP form-supply variant of ExAgent.Server.supply_result/4. Keep the original call server-side and project it again before parsing a submission.

Summary

Functions

Project flat forms after reviewing the peer's requests. The supported field types are "string", "integer", "number" and "boolean". Each choice is a submitted string and its display label.

Parse submitted values from present/2 for the same call. Omitted and empty optional fields are left out. Invalid submissions return {:error, :invalid_mcp_input}.

Types

field()

@type field() :: %{
  name: String.t(),
  label: String.t(),
  description: String.t(),
  type: String.t(),
  required?: boolean(),
  choices: [{String.t(), String.t()}]
}

form()

@type form() :: %{id: String.t(), message: String.t(), fields: [field()]}

Functions

present(call, agent)

@spec present(ExAgent.Continuation.DeferredCall.t(), ExAgent.t()) ::
  {:ok, [form()]} | {:error, :unsupported_mcp_form | :input_form_withheld}

Project flat forms after reviewing the peer's requests. The supported field types are "string", "integer", "number" and "boolean". Each choice is a submitted string and its display label.

An unsupported request or a missing MCP tool returns :unsupported_mcp_form. A guard that withholds the request returns :input_form_withheld.

responses(call, forms, values)

@spec responses(ExAgent.Continuation.DeferredCall.t(), [form()], map()) ::
  {:ok, map()} | {:error, :invalid_mcp_input}

Parse submitted values from present/2 for the same call. Omitted and empty optional fields are left out. Invalid submissions return {:error, :invalid_mcp_input}.