elicit

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package elicit implements confirmation gates for MCP write tools.

Ask returns an input-required result. The client supplies an action and retries the call. Decide accepts the action or returns a matchable sentinel. The handler therefore runs once to ask and once to act. Work before the gate must not have side effects.

A response supplied with the initial call bypasses Ask. RequestState is not signed, so the retry is not bound to the original request. The gate records reported user intent; it does not authenticate the client or authorize the operation. Use authentication and idempotency controls where required.

Stateless HTTP supports gated writes for protocol 2026-07-28 and later. Earlier clients need stdio or a stateful HTTP handler.

Index

Constants

View Source
const GateID = "io.github.acidsailor.mcpkit/confirm"

GateID is the default key naming the write-tool confirmation request.

Variables

View Source
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 handler drops it for pre-2026-07-28 clients)",
	)
	ErrUnexpectedElicitAction = errors.New("unexpected elicit action")
	ErrElicitationFailed      = errors.New("elicitation failed")
)

Sentinels for write-tool elicitation outcomes, wrapped with detail.

Functions

func Ask added in v0.8.0

func Ask(
	gateID string,
	session *mcp.ServerSession,
	params *mcp.ElicitParams,
) (*mcp.CallToolResult, error)

Ask returns an input-required confirmation result.

func Decide added in v0.8.0

func Decide(resp mcp.InputResponse) error

Decide maps a fulfilled confirmation to nil (accept) or a sentinel error.

Types

type DescribeFunc

type DescribeFunc[In any] func(ctx context.Context, in In) (string, error)

DescribeFunc renders a confirmation message from a decoded In request.

type ParamsFunc

type ParamsFunc[In any] func(
	ctx context.Context, in In,
) (*mcp.ElicitParams, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL