Documentation
¶
Index ¶
- type AuthRTProvider
- type JarProvider
- type Manager
- func (m *Manager) CloseConversation(convID string)
- func (m *Manager) Get(ctx context.Context, convID, serverName string) (mcpclient.Interface, error)
- func (m *Manager) Options(ctx context.Context, serverName string) (*mcpcfg.MCPClient, error)
- func (m *Manager) Reap()
- func (m *Manager) Reconnect(ctx context.Context, convID, serverName string) (mcpclient.Interface, error)
- func (m *Manager) StartReaper(ctx context.Context, interval time.Duration) (stop func())
- func (m *Manager) Touch(convID, serverName string)
- func (m *Manager) UseIDToken(ctx context.Context, serverName string) bool
- func (m *Manager) WithAuthTokenContext(ctx context.Context, serverName string) context.Context
- type Option
- func WithAuthRoundTripper(rt *authtransport.RoundTripper) Option
- func WithAuthRoundTripperProvider(p AuthRTProvider) Option
- func WithCookieJar(jar http.CookieJar) Option
- func WithCookieJarProvider(p JarProvider) Option
- func WithHandlerFactory(newHandler func() protoclient.Handler) Option
- func WithTTL(ttl time.Duration) Option
- func WithUserIDExtractor(fn UserIDExtractor) Option
- type Provider
- type RepoProvider
- type RepoProviderOption
- type UserIDExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRTProvider ¶
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 ¶
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 (userID:conversationID, serverName) and handles idle reaping.
func (*Manager) CloseConversation ¶
CloseConversation drops all clients for a conversation (across all users). Note: underlying transports may keep connections if the library doesn't expose Close.
func (*Manager) Get ¶
Get returns an MCP client for (user+convID, serverName), creating it if needed. When a UserIDExtractor is configured, the pool key includes the user ID to prevent shared conversations from leaking MCP auth/tokens across users.
func (*Manager) Options ¶
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 ¶
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 ¶
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) UseIDToken ¶
UseIDToken reports whether the MCP server config prefers using an ID token when authenticating outbound calls to this server.
func (*Manager) WithAuthTokenContext ¶
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 ¶
Option configures Manager. It can return an error which will be bubbled up by New.
func WithAuthRoundTripper ¶
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 ¶
func WithAuthRoundTripperProvider(p AuthRTProvider) Option
WithAuthRoundTripperProvider injects a provider that selects an auth RoundTripper per request.
func WithCookieJar ¶
WithCookieJar injects a host-controlled CookieJar that will be applied to newly created MCP clients via ClientOptions, overriding any per-provider jar.
func WithCookieJarProvider ¶
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 WithUserIDExtractor ¶
func WithUserIDExtractor(fn UserIDExtractor) Option
WithUserIDExtractor sets the function used to derive a user-scoped pool key.
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(opts ...RepoProviderOption) *RepoProvider
type RepoProviderOption ¶
type RepoProviderOption func(*RepoProvider)
RepoProviderOption configures RepoProvider.
func WithRepoStateStore ¶
func WithRepoStateStore(ss workspace.StateStore) RepoProviderOption
WithRepoStateStore injects a StateStore for resolving state directories.
type UserIDExtractor ¶
UserIDExtractor returns a user identifier from context for pool isolation. When set, the pool key becomes "userID:convID" instead of just "convID" to prevent shared conversations from leaking MCP auth across users.