Documentation
¶
Overview ¶
Package upstream is the driven adapter for backend MCP servers: it turns a config.Backend into a live core.Upstream over the go-sdk client.
Transports: stdio spawns a subprocess (CommandTransport); http and sse dial remote endpoints (StreamableClientTransport / SSEClientTransport). Upstream auth — none, bearer, client_credentials, interactive OAuth — is assembled here from the backend's auth block; on streamable the SDK drives the OAuthHandler itself, on SSE we drive it once at connect.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is a connected upstream MCP server.
func Connect ¶
func Connect(ctx context.Context, name string, cfg *config.Backend, opts *Options) (*Backend, error)
Connect dials (or spawns) the backend and discovers its tool inventory. cfg's env: references resolve here — the copy that reaches transports carries secrets; the config file never does.
func (*Backend) Call ¶
func (b *Backend) Call(ctx context.Context, tool string, args json.RawMessage) (*mcp.CallToolResult, error)
func (*Backend) Passthrough ¶
Passthrough reports whether this upstream is a federated gateway — its tool names are already qualified. Part of core.Passthrough.
type Options ¶
type Options struct {
// Tokens is the persistent upstream-token store. Nil means no stored
// grants — an oauth backend then can only authorize interactively.
Tokens *oauth.Store
// Interactive permits the oauth fetcher to open a browser and wait on a
// loopback callback (`toolhost mcp auth`); serve/discover pass false so a
// missing grant fails fast instead of surprising a terminal.
Interactive bool
// OpenURL launches the authorization URL — nil uses the platform opener.
// Tests inject a redirect-following HTTP GET.
OpenURL func(string) error
// Out is where the interactive fetcher prints the authorization URL.
Out io.Writer
// contains filtered or unexported fields
}
Options carries the cross-cutting things a connect needs that config doesn't know: where tokens persist and whether a flow may open a browser.
func (*Options) DefaultCallTimeout ¶
DefaultCallTimeout is the call_timeout for backends without their own.
func (*Options) SetDefaultCallTimeout ¶ added in v0.0.4
SetDefaultCallTimeout sets the call_timeout for backends without their own. Safe while calls are in flight.