mcpbatch

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mcpbatch owns strict, snapshot-gated MCP batch input validation and execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOK

func AllOK(results []Result) bool

AllOK reports whether each returned result completed successfully.

func Validate

func Validate(input Input, approved, current []*protocol.Tool) error

Validate confirms every call against approved and current read-only tools. It runs before Execute so no partially validated batch can invoke a tool.

Types

type Call

type Call struct {
	ID        string         `json:"id"`
	Tool      string         `json:"tool"`
	Arguments map[string]any `json:"arguments,omitempty"`
	Select    *string        `json:"select,omitempty"`
	Head      *int           `json:"head,omitempty"`
}

Call is one named, schema-validated read-only tool invocation.

type Caller

type Caller interface {
	Call(context.Context, string, map[string]any) (*protocol.CallToolResult, error)
}

Caller is the connected MCP client surface used by a batch worker pool.

type Input

type Input struct {
	Version        int           `json:"version"`
	MaxConcurrency *int          `json:"max_concurrency,omitempty"`
	FailFast       bool          `json:"fail_fast,omitempty"`
	Calls          []Call        `json:"calls"`
	CallTimeout    time.Duration `json:"-"`
}

Input is the versioned, bounded batch request document.

func Decode

func Decode(reader io.Reader) (Input, error)

Decode reads one strict JSON object without accepting more than 1 MiB.

type Projector

type Projector func(*protocol.CallToolResult, Call) (any, error)

Projector adapts normal tool results to the optional call projection contract.

type Result

type Result struct {
	ID         string `json:"id"`
	OK         bool   `json:"ok"`
	Status     string `json:"status"`
	DurationMS int64  `json:"duration_ms"`
	Result     any    `json:"result,omitempty"`
	Error      string `json:"error,omitempty"`
}

Result is one ordered batch call outcome.

func Execute

func Execute(parent context.Context, caller Caller, input Input, projector Projector) []Result

Execute invokes a prevalidated batch through one bounded worker pool.

Jump to

Keyboard shortcuts

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