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

client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package client provides opt-in task-aware calls. It never retries an original tools/call or a failed mutation, and disconnect never means task cancellation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPeer    = errors.New("invalid MCP task response")
	ErrCancelled      = errors.New("task cancelled")
	ErrExpired        = errors.New("task TTL elapsed")
	ErrUncertainInput = errors.New("task input outcome is uncertain; reconcile before another attempt")
)

Functions

This section is empty.

Types

type Attempt

type Attempt struct {
	Fingerprint string          `json:"fingerprint"`
	Stage       string          `json:"stage"`
	Response    json.RawMessage `json:"response,omitempty"`
}

type Client

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

func New

func New(caller rpc.Caller, options Options) (*Client, error)

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, params *schema.CallToolRequestParams) (ToolOutcome, error)

CallTool preserves normal and MRTR results verbatim; a task handle is exposed separately. It sends exactly one original request and never asks for a task.

func (*Client) Cancel

func (c *Client) Cancel(ctx context.Context, id string) error

func (*Client) Discover

func (c *Client) Discover(ctx context.Context) (*schema.DiscoverResult, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, id string) (tasks.GetTaskResult, error)

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, ids []string, options SubscriptionOptions) error

Subscribe observes full canonical state and never handles inputs or cancels tasks. A dropped transport reconnects at most MaxReconnects times; each new subscription gets a fresh ID and a fresh server snapshot, not cursor replay.

func (*Client) Update

func (c *Client) Update(ctx context.Context, id string, responses tasks.InputResponses) error

func (*Client) Wait

func (c *Client) Wait(ctx context.Context, id string, options WaitOptions) (json.RawMessage, error)

type Cursor

type Cursor struct {
	TaskID    string             `json:"taskId"`
	CreatedAt time.Time          `json:"createdAt"`
	Attempts  map[string]Attempt `json:"attempts"`
}

Cursor must be persisted by SaveCursor before external input handling/update when crash recovery is required. Reuse it to resume; do not replay CallTool.

type InputRequiredError

type InputRequiredError struct{ Task tasks.GetTaskResult }

func (*InputRequiredError) Error

func (e *InputRequiredError) Error() string

type Options

type Options struct {
	Capabilities schema.ClientCapabilities
	Info         schema.Implementation
	Tasks        bool
	Clock        func() time.Time
	Wait         func(context.Context, time.Duration) error
}

type SubscriptionOptions

type SubscriptionOptions struct {
	MaxReconnects  int
	ReconnectDelay time.Duration
	OnAcknowledged func([]string) error
	OnTask         func(tasks.DetailedTask) error
}

type ToolOutcome

type ToolOutcome struct {
	Result json.RawMessage
	Task   *tasks.CreateTaskResult
}

type UncertainError

type UncertainError struct {
	Method, TaskID string
	Cause          error
}

func (*UncertainError) Error

func (e *UncertainError) Error() string

func (*UncertainError) Unwrap

func (e *UncertainError) Unwrap() error

type WaitOptions

type WaitOptions struct {
	Cursor     *Cursor
	Initial    *tasks.Task
	Input      InputHandler
	SaveCursor func(context.Context, Cursor) error
	OnState    func(tasks.GetTaskResult)
}

Jump to

Keyboard shortcuts

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