toolruntime

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 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 toolruntime exposes an immutable provider-neutral Tool catalog over a process-wide, authenticated loopback gateway. MCP is deliberately confined to this internal package.

Index

Constants

View Source
const (
	// ServerKey is the reserved MCP server key used by every in-process tool
	// catalog. A process-wide gateway lets concurrent Agents safely materialize
	// the same URL into a shared provider profile.
	ServerKey = toolidentity.ServerKey
)

Variables

View Source
var (
	// ErrClosed means a registration can no longer be started or used.
	ErrClosed = errors.New("tool runtime is closed")
	// ErrInvalidCatalog means a Catalog cannot be represented by the internal
	// MCP server. The original SDK panic is deliberately not exposed because it
	// may contain descriptor or schema contents.
	ErrInvalidCatalog = errors.New("invalid tool catalog")
)

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	URL               string
	BearerTokenEnvVar string
}

Endpoint contains only non-secret connection metadata.

type Runtime

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

Runtime is one Agent's immutable catalog registration in the process-wide gateway. Start is lazy so listener failures remain pre-launch run errors.

func New

func New(definitions []tool.Definition) (*Runtime, error)

New validates and freezes the definitions' MCP projection without opening a socket. The tool package owns typed decoding, JSON Schema validation, and handler immutability; this package adds the sorted catalog fingerprint.

func (*Runtime) BearerToken

func (r *Runtime) BearerToken() (string, bool)

BearerToken returns this registration's secret. It is intended only for subprocess SecretEnv injection and is excluded from Endpoint, errors, logs, results, and fingerprints.

func (*Runtime) BearerTokenEnvVar

func (r *Runtime) BearerTokenEnvVar() string

BearerTokenEnvVar returns this Agent registration's unpredictable, non-secret credential carrier name. It is available before Start so MCP declarations can be checked for aliasing before the listener is opened.

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context) error

Close unregisters this Agent's token, drains its active calls, and shuts down the process-wide listener only when it was the final registration. It is idempotent and safe for concurrent callers.

func (*Runtime) Endpoint

func (r *Runtime) Endpoint() (Endpoint, bool)

Endpoint returns the shared non-secret endpoint after Start.

func (*Runtime) Fingerprint

func (r *Runtime) Fingerprint() string

Fingerprint returns the provider-neutral catalog compatibility identity. It never contains the bearer token or handler/closure addresses.

func (*Runtime) GoString

func (r *Runtime) GoString() string

GoString provides the same redaction for %#v formatting.

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context) (Endpoint, error)

Start registers the catalog once and returns the process-wide stable endpoint. A failed bind does not poison the Runtime, so preparation may be retried before a provider prompt is delivered.

func (*Runtime) String

func (r *Runtime) String() string

String intentionally omits credentials. Runtime occasionally appears in diagnostic structs during pre-launch failures, and formatting it must not turn an Agent's bearer token into a log value.

Jump to

Keyboard shortcuts

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