MCPKit.Prompt behaviour (mcp_kit v0.2.4)

Copy Markdown View Source

Behaviour and schema DSL for MCP prompt modules.

Prompt modules declare their argument contract with schema/1, render MCP prompt messages via render/2, and may optionally implement complete/3 for argument suggestions.

Summary

Callbacks

Returns the prompt argument descriptors sent by prompts/list.

Returns prompt argument completion suggestions.

Returns the description shown in prompts/list.

Renders MCP prompt messages from validated arguments.

Validates and normalizes incoming prompt arguments.

Functions

Declares the argument schema for a prompt.

Callbacks

arguments()

@callback arguments() :: [map()]

Returns the prompt argument descriptors sent by prompts/list.

complete(t, map, map)

@callback complete(String.t(), map(), map()) :: {:ok, [String.t()]} | :unsupported

Returns prompt argument completion suggestions.

Return :unsupported when the prompt does not expose completions for the given argument.

description()

@callback description() :: String.t() | nil

Returns the description shown in prompts/list.

render(map, map)

@callback render(map(), map()) :: {:reply, [map()], map()}

Renders MCP prompt messages from validated arguments.

The context map currently includes at least :session.

validate_arguments(map)

@callback validate_arguments(map()) :: {:ok, map()} | {:error, String.t()}

Validates and normalizes incoming prompt arguments.

This callback is generated by schema/1 unless overridden.

Functions

schema(list)

(macro)

Declares the argument schema for a prompt.

This macro generates arguments/0 and validate_arguments/1 for the prompt module.