remote

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	Tools []*mcp.Tool `json:"tools"`
}

Meta represents the metadata exposed by the remote MCP server.

type MetaOnChangeFunc

type MetaOnChangeFunc func(ctx context.Context, meta *Meta)

MetaOnChangeFunc is a callback function invoked when metadata changes.

type Remote

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

Remote manages a single connection to a remote MCP server over HTTP. It maintains one client session and handles health checking and reconnection.

func NewRemoteManager

func NewRemoteManager(log *slog.Logger, cfg *config.API) *Remote

NewRemoteManager creates a new Remote instance for managing connections to the remote MCP server. The client is created lazily when capabilities are known.

func (*Remote) Close

func (r *Remote) Close()

Close closes the current session and releases resources. It is safe to call Close even if no session exists.

func (*Remote) Init

func (r *Remote) Init(localSession *mcp.ServerSession) error

func (*Remote) Meta

func (r *Remote) Meta() *Meta

Meta returns the cached metadata. Returns nil if metadata hasn't been loaded yet.

func (*Remote) Run

func (r *Remote) Run(ctx context.Context, checkInterval time.Duration) error

Run periodically fetches and updates metadata from the remote server. It runs until the context is cancelled.

func (*Remote) Session

func (r *Remote) Session() (*mcp.ClientSession, error)

Session returns the existing session or creates a new one if needed. When KeepAlive is enabled, it automatically handles health checks and closes the session if pings fail. This method will recreate the session if it was closed by KeepAlive or if no session exists.

func (*Remote) SetCallback

func (r *Remote) SetCallback(onChange MetaOnChangeFunc)

func (*Remote) ToolHandler

func (r *Remote) ToolHandler(toolName string) func(ctx context.Context, req *mcp.CallToolRequest, in ToolInput) (*mcp.CallToolResult, ToolOutput, error)

ToolHandler returns a handler function that proxies tool calls to the remote MCP server. The returned handler uses the Remote's managed session to forward tool invocations to the remote server and returns the structured output from the remote tool.

type ToolInput

type ToolInput map[string]any

ToolInput is a generic input type for proxied tools that maps parameter names to their values.

type ToolOutput

type ToolOutput map[string]any

ToolOutput is a generic output type for proxied tools that maps output field names to their values.

Jump to

Keyboard shortcuts

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