Hermes.Server.Component.Schema (hermes_mcp v0.10.0)

Handles schema conversion between Peri and JSON Schema formats for MCP protocol compliance.

This module provides utilities to:

  • Convert Peri schemas to JSON Schema format
  • Transform schemas to prompt argument definitions
  • Format validation errors for client responses

Summary

Functions

Formats Peri validation errors into a human-readable string.

Converts a Peri schema definition to JSON Schema format.

Converts a Peri schema to prompt argument definitions.

Functions

format_errors(errors)

Formats Peri validation errors into a human-readable string.

to_json_schema(schema)

Converts a Peri schema definition to JSON Schema format.

Examples

iex> to_json_schema(%{name: :string, age: {:required, :integer}})
%{
  "type" => "object",
  "properties" => %{
    "name" => %{"type" => "string"},
    "age" => %{"type" => "integer"}
  },
  "required" => ["age"]
}

to_prompt_arguments(schema)

Converts a Peri schema to prompt argument definitions.

Examples

iex> to_prompt_arguments(%{language: {:required, :string}, focus: :string})
[
  %{"name" => "language", "description" => "Required string parameter", "required" => true},
  %{"name" => "focus", "description" => "Optional string parameter", "required" => false}
]