ExMCP.Protocol.ResultEnvelope (ex_mcp v1.0.0-rc.8)

Copy Markdown View Source

Classifies result envelopes according to the negotiated MCP protocol era.

Legacy peers may omit resultType; modern and unnegotiated peers may not. Extension result types are accepted only when the caller explicitly lists them as negotiated.

Summary

Functions

Classifies a result without changing its wire representation.

Validates a result and returns it unchanged with its classification.

Types

classification_error()

@type classification_error() ::
  :result_must_be_object
  | :missing_result_type
  | {:invalid_result_type, term()}
  | {:unknown_result_type, String.t()}
  | ExMCP.Protocol.CacheableResult.validation_error()

result_kind()

@type result_kind() :: :complete | :input_required | {:extension, String.t()}

Functions

classify(result, version_or_era, opts \\ [])

@spec classify(map(), :legacy | :modern | :unknown | String.t() | nil, keyword()) ::
  {:ok, result_kind()} | {:error, classification_error()}

Classifies a result without changing its wire representation.

validate(result, version_or_era, opts \\ [])

@spec validate(map(), :legacy | :modern | :unknown | String.t() | nil, keyword()) ::
  {:ok, result_kind(), map()} | {:error, classification_error()}

Validates a result and returns it unchanged with its classification.