Wraith.Kiro.MCP behaviour (Wraith v0.1.0)

View Source

The MCP plumbing for the studio tool server (JSON-RPC 2.0 over Streamable HTTP with plain JSON replies): initialize, ping, tools/list, tools/call. A server is a module with

@callback tools(context) :: [tool_spec]
@callback call(context, name, arguments) :: result_map

where context is whatever handle/4 is given. handle/4 takes one decoded JSON-RPC message and returns the reply, or nil for notifications.

Summary

Callbacks

Optional: resources/read — {:ok, [%{uri, mimeType, text}]} | :error.

Optional: resources/list — [%{uri, name, description, mimeType}].

Callbacks

call(term, t, map)

@callback call(term(), String.t(), map()) :: map()

read_resource(term, t)

(optional)
@callback read_resource(term(), String.t()) :: {:ok, [map()]} | :error

Optional: resources/read — {:ok, [%{uri, mimeType, text}]} | :error.

resources(term)

(optional)
@callback resources(term()) :: [map()]

Optional: resources/list — [%{uri, name, description, mimeType}].

server_info(term)

@callback server_info(term()) :: %{name: String.t(), instructions: String.t()}

tools(term)

@callback tools(term()) :: [map()]

Functions

error(t)

handle(server, context, msg, label)

@spec handle(module(), term(), map(), String.t()) :: map() | nil

text(t)