Documentation
¶
Overview ¶
Package elicit provides the shared MCP elicitation gate and write-tool sentinels used by the toolkit's write-tool builder.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserDeclined = errors.New("declined by user") ErrUserCanceled = errors.New("canceled by user") ErrNoElicitation = errors.New( "client must support MCP elicitation for write tools", ) ErrUnexpectedElicitAction = errors.New("unexpected elicit action") ErrElicitationFailed = errors.New("elicitation failed") )
Sentinels for write-tool elicitation outcomes, wrapped with detail at the call site.
Functions ¶
func Gate ¶
func Gate( ctx context.Context, session *mcp.ServerSession, params *mcp.ElicitParams, ) error
Gate runs the MCP elicitation handshake for a write tool. It requires the client to advertise the elicitation capability (else ErrNoElicitation), then issues the request and maps the action to a result:
accept -> nil (caller proceeds with the mutating call) decline -> ErrUserDeclined cancel -> ErrUserCanceled other -> ErrUnexpectedElicitAction
A transport/protocol failure is wrapped with ErrElicitationFailed. A nil params produces an empty prompt.
Only the action gates the call; any returned field values are not inspected.
Types ¶
type DescribeFunc ¶
DescribeFunc renders a confirmation message from a decoded request of type In. A returned error aborts before any prompt is shown.
type ParamsFunc ¶
ParamsFunc builds an elicitation prompt from a decoded request of type In.
func DynamicConfirmation ¶
func DynamicConfirmation[In any](describe DescribeFunc[In]) ParamsFunc[In]
DynamicConfirmation returns a ParamsFunc that builds the prompt message from the decoded input via describe, using SimpleConfirmation's requested schema. Use it for write tools whose confirmation text depends on the request (e.g. naming the affected resource). A describe error aborts the prompt and is returned as-is.
func SimpleConfirmation ¶
func SimpleConfirmation[In any](message string) ParamsFunc[In]
SimpleConfirmation returns a ParamsFunc that prompts with message and requests no input fields, for write tools needing a plain yes/no confirmation. Gate gates on the accept/decline/cancel action.