tetherlink

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 13 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

This section is empty.

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 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.

Types

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)

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)

Jump to

Keyboard shortcuts

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