manager

package
v0.2.49 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRTProvider added in v0.2.9

type AuthRTProvider func(ctx context.Context) *authtransport.RoundTripper

AuthRTProvider returns a per-request auth RoundTripper (e.g., per-user) chosen from context. When provided, it takes precedence over the static authRT set via WithAuthRoundTripper.

type JarProvider added in v0.2.9

type JarProvider func(ctx context.Context) (http.CookieJar, error)

JarProvider returns a per-request CookieJar (e.g., per-user) chosen from context. When provided, it takes precedence over the static cookieJar set via WithCookieJar.

type Manager

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

Manager caches MCP clients per (conversationID, serverName) and handles idle reaping.

func New

func New(prov Provider, opts ...Option) (*Manager, error)

New creates a Manager with the given Provider and options.

func (*Manager) CloseConversation

func (m *Manager) CloseConversation(convID string)

CloseConversation drops all clients for a conversation. Note: underlying transports may keep connections if the library doesn't expose Close.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, convID, serverName string) (mcpclient.Interface, error)

Get returns an MCP client for (convID, serverName), creating it if needed.

func (*Manager) Options added in v0.2.10

func (m *Manager) Options(ctx context.Context, serverName string) (*mcpcfg.MCPClient, error)

Options exposes the underlying provider client options (authoring metadata, timeouts, etc.) for a given server name.

func (*Manager) Reap

func (m *Manager) Reap()

Reap closes idle clients beyond TTL by dropping references.

func (*Manager) Reconnect added in v0.2.14

func (m *Manager) Reconnect(ctx context.Context, convID, serverName string) (mcpclient.Interface, error)

Reconnect drops the cached client for (convID, serverName) and creates a new one. It returns the fresh client or an error if recreation fails.

func (*Manager) StartReaper

func (m *Manager) StartReaper(ctx context.Context, interval time.Duration) (stop func())

StartReaper launches a background goroutine that periodically invokes Reap until the provided context is cancelled or the returned stop function is called. If interval is non-positive, ttl/2 is used with a minimum of 1 minute.

func (*Manager) Touch

func (m *Manager) Touch(convID, serverName string)

Touch updates last-used time for (convID, serverName).

func (*Manager) UseIDToken added in v0.2.35

func (m *Manager) UseIDToken(ctx context.Context, serverName string) bool

UseIDToken reports whether the MCP server config prefers using an ID token when authenticating outbound calls to this server.

func (*Manager) WithAuthTokenContext added in v0.2.35

func (m *Manager) WithAuthTokenContext(ctx context.Context, serverName string) context.Context

WithAuthTokenContext injects the selected auth token into context under the MCP auth transport key so HTTP transports can emit the appropriate Bearer header. This is a best-effort helper; when no token is available it returns ctx as-is.

type Option

type Option func(*Manager) error

Option configures Manager. It can return an error which will be bubbled up by New.

func WithAuthRoundTripper added in v0.2.9

func WithAuthRoundTripper(rt *authtransport.RoundTripper) Option

WithAuthRoundTripper enables auth integration by attaching the provided RoundTripper as an Authorizer interceptor to created MCP clients.

func WithAuthRoundTripperProvider added in v0.2.9

func WithAuthRoundTripperProvider(p AuthRTProvider) Option

WithAuthRoundTripperProvider injects a provider that selects an auth RoundTripper per request.

func WithCookieJar added in v0.2.9

func WithCookieJar(jar http.CookieJar) Option

WithCookieJar injects a host-controlled CookieJar that will be applied to newly created MCP clients via ClientOptions, overriding any per-provider jar.

func WithCookieJarProvider added in v0.2.9

func WithCookieJarProvider(p JarProvider) Option

WithCookieJarProvider injects a provider that selects a CookieJar per request (e.g., per user).

func WithHandlerFactory

func WithHandlerFactory(newHandler func() protoclient.Handler) Option

WithHandlerFactory sets a factory for per-connection client handlers (for elicitation, etc.).

func WithTTL

func WithTTL(ttl time.Duration) Option

WithTTL sets idle TTL before reaping a client.

type Provider

type Provider interface {
	Options(ctx context.Context, serverName string) (*mcpcfg.MCPClient, error)
}

Provider returns client options for a given MCP server name.

type RepoProvider

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

RepoProvider loads MCP client options from the Agently workspace repo ($AGENTLY_WORKSPACE/mcp).

func NewRepoProvider

func NewRepoProvider() *RepoProvider

func (*RepoProvider) Options

func (p *RepoProvider) Options(ctx context.Context, name string) (*mcpcfg.MCPClient, error)

Jump to

Keyboard shortcuts

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