AshAi.Mcp.Router (ash_ai v0.8.2)

Copy Markdown View Source

MCP Router implementing the RPC functionality over HTTP.

This router handles HTTP requests according to the Model Context Protocol specification.

Usage

forward "/mcp", AshAi.Mcp.Router, tools: [:tool1, :tool2], otp_app: :my_app

Tool schemas are generated without the OpenAI strict-mode transformation by default — MCP clients don't constrain sampling with the schema, so the honest form is smaller and clearer. Pass strict: true to restore it.

A tool_argument_transformer option may be a three-arity function receiving the resolved %AshAi.Tool{}, its argument map, and the request's Ash tool context. It must return {:ok, arguments} or {:error, message}. Rejections are rendered as ordinary MCP tool errors in the selected protocol envelope.

Summary

Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.