Documentation
¶
Index ¶
- type ConnectFunc
- type HTTPUpstream
- type Manager
- func (m *Manager) CallTool(ctx context.Context, serverName, toolName string, args json.RawMessage) (json.RawMessage, error)
- func (m *Manager) Close() error
- func (m *Manager) GetUpstream(ctx context.Context, serverName string) (Upstream, error)
- func (m *Manager) ListToolsAll(ctx context.Context) (map[string][]types.ToolEntry, error)
- type StdioUpstream
- type Upstream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectFunc ¶
ConnectFunc creates an Upstream from a ServerConfig. This allows injecting mock connections in tests.
func NewConnectFunc ¶
func NewConnectFunc(_ *auth.TokenStore) ConnectFunc
NewConnectFunc returns a ConnectFunc. Without the mcp_go_client_oauth build tag, this falls back to DefaultConnect (no OAuth support).
type HTTPUpstream ¶
type HTTPUpstream struct {
// contains filtered or unexported fields
}
HTTPUpstream connects to an upstream MCP server via HTTP (streamable HTTP or SSE) using the go-sdk.
func NewHTTPUpstream ¶
func NewHTTPUpstream(ctx context.Context, name string, cfg types.ServerConfig) (*HTTPUpstream, error)
NewHTTPUpstream creates and connects to an upstream HTTP MCP server (streamable HTTP).
func NewSSEUpstream ¶
func NewSSEUpstream(ctx context.Context, name string, cfg types.ServerConfig) (*HTTPUpstream, error)
NewSSEUpstream creates and connects to an upstream SSE MCP server.
func (*HTTPUpstream) Alive ¶
func (h *HTTPUpstream) Alive() bool
func (*HTTPUpstream) CallTool ¶
func (h *HTTPUpstream) CallTool(ctx context.Context, toolName string, args json.RawMessage) (json.RawMessage, error)
func (*HTTPUpstream) Close ¶
func (h *HTTPUpstream) Close() error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages connections to upstream MCP servers. It maintains a pool of active connections and reaps idle ones.
func NewManager ¶
func NewManager(configs map[string]types.ServerConfig, idleTimeout, callTimeout time.Duration, connect ConnectFunc) *Manager
NewManager creates a new transport manager and starts the idle reaper. callTimeout is optional — if zero, tool calls use the caller's context deadline only.
func (*Manager) CallTool ¶
func (m *Manager) CallTool(ctx context.Context, serverName, toolName string, args json.RawMessage) (json.RawMessage, error)
CallTool is a convenience method that gets the upstream for a server and invokes the named tool. If the call fails, it evicts the stale connection and retries once with a fresh connection.
func (*Manager) Close ¶
Close shuts down all pooled connections and stops the reaper. Safe to call multiple times.
func (*Manager) GetUpstream ¶
GetUpstream returns a pooled connection for the named server, creating one if necessary or if the existing connection is no longer alive.
type StdioUpstream ¶
type StdioUpstream struct {
// contains filtered or unexported fields
}
StdioUpstream connects to an upstream MCP server via stdio using the go-sdk.
func NewStdioUpstream ¶
func NewStdioUpstream(ctx context.Context, name string, cfg types.ServerConfig) (*StdioUpstream, error)
NewStdioUpstream creates and connects to an upstream stdio MCP server.
func (*StdioUpstream) Alive ¶
func (s *StdioUpstream) Alive() bool
func (*StdioUpstream) CallTool ¶
func (s *StdioUpstream) CallTool(ctx context.Context, toolName string, args json.RawMessage) (json.RawMessage, error)
func (*StdioUpstream) Close ¶
func (s *StdioUpstream) Close() error
type Upstream ¶
type Upstream interface {
// ListTools returns all tools from this upstream.
ListTools(ctx context.Context) ([]types.ToolEntry, error)
// CallTool invokes a tool on this upstream and returns the raw JSON result.
CallTool(ctx context.Context, toolName string, args json.RawMessage) (json.RawMessage, error)
// Close shuts down the connection.
Close() error
// Alive checks if the connection is still usable.
Alive() bool
}
Upstream represents a connection to an upstream MCP server.
func DefaultConnect ¶
DefaultConnect creates real upstream connections (stdio or HTTP).