Help us shape the future of Go! Take the 2026 Go Developer Survey

elicit

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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.

Ask does not inspect client capabilities. The SDK rejects clients that cannot answer with a call error that has no matchable sentinel.

Clients must check CallToolResult.NeedsInput. Ignoring InputRequests returns an empty successful result without running the write.

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")
	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, params *mcp.ElicitParams) *mcp.CallToolResult

Ask returns an input-required confirmation result keyed by gateID.

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