Documentation
¶
Overview ¶
Package elicit provides the MCP elicitation gate and write-tool sentinels.
Gate runs the elicitation handshake that fronts a write tool. It first requires the client to advertise the elicitation capability (else ErrNoElicitation), then issues the request and maps the returned action to a result:
accept -> nil (the caller proceeds with the mutating call) decline -> ErrUserDeclined cancel -> ErrUserCanceled other -> ErrUnexpectedElicitAction
A transport/protocol failure is wrapped with ErrElicitationFailed. Only the action gates the call; returned field values are not inspected.
ErrNoElicitation has a second, easily-missed cause: a stateless HTTP handler. It uses a temporary session with default init params, so the client's elicitation capability is never retained and server->client requests are rejected — Gate then fails even when the client did advertise the capability. Serve write tools over stdio or a stateful HTTP handler (see package server).
The sentinels live in errors.go; toolkit re-exports them so callers need not import elicit directly.
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 " + "(a stateless HTTP server handler also drops this capability)", ) ErrUnexpectedElicitAction = errors.New("unexpected elicit action") ErrElicitationFailed = errors.New("elicitation failed") )
Sentinels for write-tool elicitation outcomes, wrapped with detail.
Functions ¶
func Gate ¶
func Gate( ctx context.Context, session *mcp.ServerSession, params *mcp.ElicitParams, ) error
Gate runs write-tool elicitation: accept->nil, else a sentinel error.
Types ¶
type DescribeFunc ¶
DescribeFunc renders a confirmation message from a decoded In request.
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 building the prompt via describe.
func SimpleConfirmation ¶
func SimpleConfirmation[In any](message string) ParamsFunc[In]
SimpleConfirmation returns a ParamsFunc that prompts with message, no fields.