Documentation
¶
Overview ¶
Package hostclient is how a subprocess plugin calls back into Tangent.
Why a plugin needs this at all ¶
The plugin wire is one-directional. `libs/plugin-sdk/subprocess` says so — "the subprocess does not initiate requests" — and its server never constructs one. A plugin receives `mcp/call_tool` and answers; it cannot ask the host for anything over that pipe.
Both application plugins need to ask. Opening a board is `tangent_session_create`; syncing one is `tangent_surface_get` and `tangent_session_advance`. Those are the feature, not an edge.
Why this is the front door rather than a workaround ¶
`pkg/plugin`'s `ToolCaller` (the in-process form lives in `internal/pluginhost`) is defined as granting "no authority a local MCP caller does not already have… the same host-assigned caller identity every direct MCP caller resolves to". A child connecting to `/mcp` does not approximate that equivalence — it IS a local MCP caller, so the claim needs no argument and nothing maintains its truth.
And a subprocess plugin is already a local process: it can reach `/mcp` whether or not the host intends it to. Nothing is granted by choosing this. The only thing the choice decides is whether the intended path is the real one, or whether there is a second private channel beside a public one the child can reach anyway — which is the shape `RegisterCRUDHandler` and `GetService` are already refused for.
The convergence is worth naming: an agent drives Tangent through MCP, and now a plugin does too. A plugin is another client of the service rather than a privileged insider with its own door.
Index ¶
Constants ¶
const ( KeyFileEnv = "TANGENT_MCP_KEY_FILE" KeyEnv = "TANGENT_MCP_KEY" )
KeyFileEnv names the environment variable carrying the path of the file that holds the plugin's current API key. The host mints one key per child, short-lived, and rewrites the file when it renews, so the client reads it on every request rather than once at start. KeyEnv carries a key directly instead, for a host that does not renew (a test, a fixed deployment).
const URLEnv = "TANGENT_MCP_URL"
URLEnv names the environment variable carrying Tangent's MCP endpoint.
It arrives in the environment rather than in the SDK's InitParams for the same reason the host sends an empty config map: the host says WHERE things are, and a plugin reads its own environment. Neither is configuration the host holds on a plugin's behalf, which is what keeps ADR 0005 §3.1's secret boundary true by construction.
Variables ¶
var ErrNoHost = errors.New("hostclient: " + URLEnv + " is not set")
ErrNoHost reports that a plugin was started without being told where its host is. It is returned rather than defaulted: a plugin that guessed a URL would either reach the wrong Tangent or fail with a connection error that says nothing about the real cause.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a plugin's connection to Tangent's tool surface.
It satisfies the same one-method shape `plugin.ToolCaller` does, so plugin code written against the in-process caller works unchanged out of process.
func New ¶
New returns a client for the host named by TANGENT_MCP_URL.
Connecting lazily is required, not an optimization ¶
The host loads plugins BEFORE the MCP and HTTP servers exist — a plugin-contributed kind has to be in the registry `mcp.New` reads, so plugins necessarily come first. A plugin that dialed its host at startup would dial a port nothing is listening on yet, and the failure would look like a misconfigured URL rather than an ordering problem. Registering a pool entry does not dial; go-mcp/client dials on first use, which is after boot by construction.