Documentation
¶
Overview ¶
Package gateway connects to Upstreams and serves their tools to an Agent as Namespaced tools.
Index ¶
- func CheckOAuthUpstream(u config.Upstream) error
- func Login(ctx context.Context, u config.Upstream, env []string, browser bool, ...) error
- func NeedsLogin(ctx context.Context, u config.Upstream, env []string, version string, ...) (bool, error)
- func Status(store *credentials.Store, u config.Upstream) (string, error)
- type Gateway
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckOAuthUpstream ¶ added in v0.2.0
CheckOAuthUpstream reports why u is not an OAuth Upstream, or nil if it is: an HTTP Upstream without an Authorization header, over HTTPS or over plain HTTP on a loopback address. Whether it actually uses OAuth is up to the Upstream, which asks for it by answering 401.
func Login ¶ added in v0.2.0
func Login(ctx context.Context, u config.Upstream, env []string, browser bool, prompt io.Writer, version string, log *slog.Logger) error
Login runs the Login for u and stores the Credentials it gets. It uses the client that u's Config names, or registers one with Dynamic Client Registration, prints the Authorization Server's issuer, the scopes and the authorization URL to prompt, opens the URL if browser is set, and waits up to callbackTimeout for the Authorization Server to redirect the user's browser to a callback on a loopback port. env is where the proxy and the Credentials' directory come from.
func NeedsLogin ¶ added in v0.2.0
func NeedsLogin(ctx context.Context, u config.Upstream, env []string, version string, log *slog.Logger) (bool, error)
NeedsLogin reports whether the OAuth Upstream u needs a Login: whether serve, connecting to it now with its stored Credentials, renewing them if it has to, would be told to run one. A failure to tell, such as a network error, is an error.
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is a started set of Upstreams and the MCP server exposing their tools.
func Start ¶
func Start(ctx context.Context, configured []config.Upstream, env []string, startupTimeout time.Duration, version string, log *slog.Logger) *Gateway
Start launches every Upstream concurrently, collects their tools and returns a Gateway ready to serve them. env is the environment Upstream processes inherit. Each Upstream gets startupTimeout to connect and list its tools; one that fails or runs out of time is logged, left out and listed in the instructions the Agent gets.
func (*Gateway) Close ¶
func (g *Gateway) Close()
Close shuts every Upstream down at once, and waits for those still being stopped after failing to start.
func (*Gateway) Serve ¶
Serve serves MCP to one Agent over stdin/stdout until the Agent disconnects or ctx is done.
func (*Gateway) SkippedCount ¶ added in v0.2.0
SkippedCount reports how many Upstreams failed or timed out at startup.