proxy

package
v0.59.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCacheDir

func EnsureCacheDir(cacheDir string) error

EnsureCacheDir creates the cache directory if it doesn't exist.

func ParseConfig

func ParseConfig() (*types.ProxyConfig, error)

ParseConfig parses proxy configuration from environment variables.

func RegisterUpstreamTools

func RegisterUpstreamTools(ctx context.Context, fastPath bool) bool

RegisterUpstreamTools attempts to connect to configured upstreams and register their tools. This function supports two modes controlled by the fastPath parameter:

  • fastPath=true: Uses 5-second timeout, only succeeds if tokens are cached. Intended for startup path to avoid blocking MCP server initialisation.

  • fastPath=false: Uses 30-second timeout, allows OAuth flow if needed. Intended for background goroutine registration after server starts.

Returns true if tools were successfully registered, false otherwise. The fallback ProxyTool is registered via init() and is always available.

Types

type DynamicProxyTool

type DynamicProxyTool struct {
	// contains filtered or unexported fields
}

DynamicProxyTool represents a single upstream tool exposed as a first-class tool.

func (*DynamicProxyTool) Definition

func (d *DynamicProxyTool) Definition() mcp.Tool

Definition returns the tool's definition for MCP registration.

func (*DynamicProxyTool) Execute

func (d *DynamicProxyTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute executes the upstream tool.

type ProxyManager

type ProxyManager struct {
	// contains filtered or unexported fields
}

ProxyManager is a singleton that manages upstream connections and is shared across all dynamic tools.

func GetGlobalProxyManager

func GetGlobalProxyManager() *ProxyManager

GetGlobalProxyManager returns the singleton proxy manager instance.

func (*ProxyManager) EnsureInitialised

func (pm *ProxyManager) EnsureInitialised(ctx context.Context, logger *logrus.Logger) error

EnsureInitialised ensures the proxy manager is initialised (lazy initialisation).

func (*ProxyManager) GetAggregator

func (pm *ProxyManager) GetAggregator() *aggregator.Aggregator

GetAggregator returns the tool aggregator (after initialisation).

func (*ProxyManager) GetManager

func (pm *ProxyManager) GetManager() *upstream.Manager

GetManager returns the upstream manager (after initialisation).

func (*ProxyManager) IsInitialised

func (pm *ProxyManager) IsInitialised() bool

IsInitialised returns whether the manager has been initialised.

type ProxyTool

type ProxyTool struct {
	// contains filtered or unexported fields
}

ProxyTool implements the tools.Tool interface for proxying to upstream MCP servers. This tool uses lazy initialisation to connect to upstreams on first use.

func (*ProxyTool) Definition

func (t *ProxyTool) Definition() mcp.Tool

Definition returns the tool's definition for MCP registration.

func (*ProxyTool) Execute

func (t *ProxyTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute executes the tool's logic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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