requeststate

package
v1.23.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package requeststate seals the requestState an MCP server returns in an InputRequiredResult and the client echoes back on its retry (MCP 2026-07-28, multi round-trip requests).

MCP treats an echoed requestState as attacker-controlled input: the server must protect its integrity and should bind it to the authenticated principal, a short expiry and the originating request. A server must also bind an elicitation to the client and user identity. A sealed value is encrypted and authenticated with AES-256-GCM under a security.KeyRing, and bound to:

  • the user and OAuth client of the validated token: the Issuer, ID and ClientID of its providers.UserInfo, and its current actor (ActorIssuer, ActorSubject) when the token is delegated;
  • the originating request, such as the method, the tool name and a digest of its arguments;
  • an expiry.

Seal and Open refuse a user without a ClientID: a token that does not name one client, such as a forwarded ID token with several audiences and no azp, cannot be given state.

Open refuses a value that was changed, sealed for another user, client, actor or request, expired, or sealed with a key the ring does not hold. A value can be opened more than once until it expires; a server whose state must be consumed at most once records that itself.

Each server seals with its own key ring, and a value is only ever opened by the server that sealed it.

Index

Constants

View Source
const (

	// MaxSealedLength bounds what Open decodes, so a client cannot make the
	// server decode an arbitrarily large value.
	MaxSealedLength = 16 << 10
)

Variables

View Source
var (
	// ErrInvalid is a value that is malformed, was changed, or was sealed
	// for another user, client, actor or request or with a key the ring
	// does not hold.
	ErrInvalid = errors.New("requeststate: invalid state")
	// ErrExpired is an authentic value past its expiry.
	ErrExpired = errors.New("requeststate: expired state")
)

Functions

This section is empty.

Types

type Sealer

type Sealer struct {
	// contains filtered or unexported fields
}

Sealer seals with its ring's active key and opens with any key the ring resolves.

func New

func New(ring security.KeyRing) (*Sealer, error)

New returns a Sealer over ring. ring must resolve its active key.

func (*Sealer) Open

func (s *Sealer) Open(user *providers.UserInfo, request, sealed string) ([]byte, error)

Open returns the payload of a value Seal returned for the same user and request. It answers ErrInvalid or ErrExpired otherwise.

func (*Sealer) Seal

func (s *Sealer) Seal(user *providers.UserInfo, request string, payload []byte, ttl time.Duration) (string, error)

Seal returns payload sealed for user and request, valid for ttl. user is the validated caller; request identifies the originating request. Open must be given the same user and request.

Jump to

Keyboard shortcuts

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