upstream

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 15 Imported by: 0 modules, 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 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) Close

func (b *Backend) Close() error

func (*Backend) Namespace

func (b *Backend) Namespace() string

func (*Backend) Passthrough

func (b *Backend) Passthrough() bool

Passthrough reports whether this upstream is a federated gateway — its tool names are already qualified. Part of core.Passthrough.

func (*Backend) Tools

func (b *Backend) Tools() []*mcp.Tool

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 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
	// DefaultCallTimeout bounds upstream calls for backends without their
	// own call_timeout. Zero means rely on the caller's deadline alone.
	DefaultCallTimeout time.Duration
}

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.

Jump to

Keyboard shortcuts

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