tetherlink

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 14 Imported by: 1 module, 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 tetherlink calls Tether's tools over MCP for a module: a stdio command (the local bridge, one process per call) or MCP's streamable HTTP. Each client names the only tools it may call; nothing else is reachable through it, whatever the far side offers. A tool's own failure is reported without its text: what Tether says may carry more than a reason.

Extracted from the Design module's client (modules/design/mcp.go), which it will replace.

Index

Constants

View Source
const ResultNext = "tether_result_next"

ResultNext is the gateway's tool that hands out the rest of a result it cut. Its cursor is good only in the session that got the first part, so CallAll asks for the rest in the same session. It reads only what an allowed call already returned, so it is not in Allowed.

Variables

View Source
var ErrRefused = errors.New("tether: the call was refused")

ErrRefused is a tool's own failure. Its text is not passed on: what Tether says may carry more than a reason, and nothing from the far side is echoed into the conversation.

Functions

func CallAll added in v0.4.0

func CallAll(ctx context.Context, c Caller, tool string, args map[string]any) (string, error)

CallAll calls a tool and, when the gateway cut its answer short (a long list), reads the rest in the same session and returns the tool's JSON whole. A Caller that cannot (a test's stand-in) is simply called.

func ReadToken

func ReadToken(path string) (string, error)

ReadToken reads a bearer token from a file. The token is never logged or returned in an error.

func ToolText

func ToolText(raw json.RawMessage) (string, error)

ToolText reads a tools/call result: its text content, or the error it reports. When the gateway cut a large result short, the answer is two text blocks: the result (as much of it as was kept) and a {"gateway_truncated": ...} note. The note is set aside, so the text is still the tool's own JSON; ask for less (a smaller limit) to get it whole, or use CallAll.

Types

type AllCaller added in v0.4.0

type AllCaller interface {
	CallAll(ctx context.Context, tool string, args map[string]any) (string, error)
}

AllCaller is a Caller that can read the whole of a result the gateway cut short.

type Allowed

type Allowed map[string]bool

Allowed is the set of tools a client may call.

type Caller

type Caller interface {
	Call(ctx context.Context, tool string, args map[string]any) (string, error)
}

Caller calls one tool on an MCP server and returns its text result.

func New

func New(module string, cfg Config, allowed Allowed) Caller

New is a client for cfg, or nil when it names no way to reach Tether.

type Config

type Config struct {
	URL       string
	TokenFile string
	Command   string
}

Config is how a module reaches Tether: an MCP URL (with a token file) or a stdio command.

type HTTP

type HTTP struct {
	// Module names the caller in errors and to the server.
	Module    string
	URL       string
	TokenFile string
	Client    *http.Client
	Allowed   Allowed
	// contains filtered or unexported fields
}

HTTP speaks MCP's streamable HTTP transport: JSON-RPC posted to one URL, answered with JSON or with an event stream carrying the answer.

func (*HTTP) Call

func (c *HTTP) Call(ctx context.Context, tool string, args map[string]any) (string, error)

func (*HTTP) CallAll added in v0.4.0

func (c *HTTP) CallAll(ctx context.Context, tool string, args map[string]any) (string, error)

CallAll is Call that reads the whole of a result the gateway cut short (see CallAll).

func (*HTTP) List added in v0.4.0

func (c *HTTP) List(ctx context.Context) ([]ToolInfo, error)

List lists the allowed tools the endpoint has.

type Lister added in v0.4.0

type Lister interface {
	List(ctx context.Context) ([]ToolInfo, error)
}

Lister lists the server's tools that the client's Allowed names (tools/list, every page).

type RefusedError added in v0.4.0

type RefusedError struct{ Detail string }

RefusedError is a tool's own failure with what the far side said. It reads as ErrRefused (errors.Is holds, and Error() says no more), so a module that reports err.Error() passes nothing on. Detail is for a caller that hands the result to a model as material, such as the agent's own Tether tools, where the reason a call failed is what lets it try again.

func (*RefusedError) Error added in v0.4.0

func (e *RefusedError) Error() string

func (*RefusedError) Is added in v0.4.0

func (e *RefusedError) Is(target error) bool

type Stdio

type Stdio struct {
	Module  string
	Argv    []string
	Timeout time.Duration
	Allowed Allowed
}

Stdio runs a command that speaks MCP over stdio (newline-delimited JSON-RPC), one process per call: calls are rare and a process is the simplest thing to get right.

func (*Stdio) Call

func (c *Stdio) Call(ctx context.Context, tool string, args map[string]any) (string, error)

func (*Stdio) CallAll added in v0.4.0

func (c *Stdio) CallAll(ctx context.Context, tool string, args map[string]any) (string, error)

CallAll is Call that reads the whole of a result the gateway cut short (see CallAll).

func (*Stdio) List added in v0.4.0

func (c *Stdio) List(ctx context.Context) ([]ToolInfo, error)

List lists the allowed tools the command's server has.

type ToolInfo added in v0.4.0

type ToolInfo struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	InputSchema json.RawMessage `json:"inputSchema,omitempty"`
}

ToolInfo is one tool as the server lists it.

Jump to

Keyboard shortcuts

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