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
- Variables
- func CallAll(ctx context.Context, c Caller, tool string, args map[string]any) (string, error)
- func ReadToken(path string) (string, error)
- func ToolText(raw json.RawMessage) (string, error)
- type AllCaller
- type Allowed
- type Caller
- type Config
- type HTTP
- type Lister
- type RefusedError
- type Stdio
- type ToolInfo
Constants ¶
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 ¶
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
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 ¶
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 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.
type Config ¶
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.
type Lister ¶ added in v0.4.0
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 ¶
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.