gateway

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package gateway connects to Upstreams and serves their tools to an Agent as Namespaced tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOAuthUpstream added in v0.2.0

func CheckOAuthUpstream(u config.Upstream) error

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.

func Status added in v0.2.0

func Status(store *credentials.Store, u config.Upstream) (string, error)

Status describes the Credentials of the OAuth Upstream u, as store holds them: whether it has any, when their access token expires, and whether they can be renewed. It contacts no server, so Credentials that the Authorization Server would reject read as good.

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

func (g *Gateway) Serve(ctx context.Context, stdin io.Reader, stdout io.Writer) error

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

func (g *Gateway) SkippedCount() int

SkippedCount reports how many Upstreams failed or timed out at startup.

Jump to

Keyboard shortcuts

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