Documentation
¶
Index ¶
- Constants
- func CompositeSessionKey(mcpServerName string) string
- func ConnectURL(serverURL string) (string, error)
- func CredentialID(credentialValue string) (string, error)
- func CredentialMatches(credentialValue, token string) bool
- func CredentialPreview(credentialValue string) (string, error)
- func NewCredential() (token, credentialValue string, err error)
- func Run(ctx context.Context, serverURL, token string) error
- func ValidateCatalogEntryTunnelReferences(ctx context.Context, client kclient.Client, ...) error
- func ValidateReference(ctx context.Context, client kclient.Client, name, target string) error
- func ValidateServerTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerManifest) error
- type Authenticator
- type HTTPClientOptions
- type Manager
- func (m *Manager) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)
- func (m *Manager) BridgeAuthorization() (name, value string)
- func (m *Manager) BridgeHost() string
- func (m *Manager) BridgeURL(tunnelName, rawURL string) (string, error)
- func (m *Manager) ClaimCompositeSession(waitCtx, lifetimeCtx context.Context, key string) error
- func (m *Manager) Close()
- func (m *Manager) CloseAll()
- func (m *Manager) CloseCompositeSessions()
- func (m *Manager) Connections() []apitypes.TunnelConnection
- func (m *Manager) ConnectionsContext(ctx context.Context) ([]apitypes.TunnelConnection, error)
- func (m *Manager) ConsumeCompositeOwnerRequest(req *http.Request) (present, valid bool)
- func (m *Manager) Disconnect(name string)
- func (m *Manager) DisconnectCredential(name, credentialID string)
- func (m *Manager) ForwardComposite(w http.ResponseWriter, r *http.Request, key, mcpServerName string) error
- func (m *Manager) HTTPClient(tunnelName string, opts HTTPClientOptions) (*http.Client, error)
- func (m *Manager) HasCompositeSession(key string) bool
- func (m *Manager) ReconcilePeers(desired map[string]string)
- func (m *Manager) ServeBridge(w http.ResponseWriter, r *http.Request)
- func (m *Manager) ServeCompositeRegistration(w http.ResponseWriter, r *http.Request)
- func (m *Manager) ServeConnect(w http.ResponseWriter, r *http.Request, name string)
- func (m *Manager) ServePeer(w http.ResponseWriter, r *http.Request)
- type PeerConfig
Constants ¶
const (
PeerConnectPath = "/tunnel/peer"
)
PeerConnectPath is the internal websocket endpoint used to connect Obot tunnel servers to one another.
Variables ¶
This section is empty.
Functions ¶
func CompositeSessionKey ¶ added in v0.26.0
CompositeSessionKey derives the opaque remotedialer session key for a composite MCP server. Only the resolved MCP server name participates in the key so aliases that resolve to the same server share one owner.
func ConnectURL ¶
ConnectURL returns the tunnel websocket endpoint on an Obot instance.
func CredentialID ¶
CredentialID returns the non-secret identifier used to narrow credential lookups before the full digest is verified.
func CredentialMatches ¶
CredentialMatches reports whether token matches a stored credential digest.
func CredentialPreview ¶
CredentialPreview returns the 16-byte preview stored with a credential.
func NewCredential ¶
NewCredential creates a 64-byte bearer token and the non-reversible value stored on an MCPTunnel.
func Run ¶
Run keeps a tunnel connected until ctx is canceled. Failed handshakes and lost connections are retried with bounded exponential backoff.
func ValidateCatalogEntryTunnelReferences ¶
func ValidateCatalogEntryTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerCatalogEntryManifest) error
ValidateCatalogEntryTunnelReferences verifies every tunnel reference in a catalog manifest.
func ValidateReference ¶
ValidateReference checks that name identifies an MCPTunnel whose current AllowedURLs authorize target.
func ValidateServerTunnelReferences ¶
func ValidateServerTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerManifest) error
ValidateServerTunnelReferences verifies every tunnel reference in a runtime server manifest.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator authenticates the credential stored on the MCPTunnel that owns the supplied bearer token. It yields a non-user principal restricted by the API authorizer to opening a tunnel connection.
func NewTunnelAuthenticator ¶
func NewTunnelAuthenticator(tunnels kclient.Reader) *Authenticator
NewTunnelAuthenticator creates a tunnel credential authenticator.
func (*Authenticator) AuthenticateRequest ¶
func (a *Authenticator) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)
AuthenticateRequest implements authenticator.Request.
type HTTPClientOptions ¶ added in v0.26.0
type Manager ¶
type Manager struct {
PeerConfig
// contains filtered or unexported fields
}
Manager owns the tunnel sessions, the remotedialer peer mesh, and the HTTP bridge used by Obot's existing MCP HTTP client.
func NewManager ¶
func NewManager(ctx context.Context, bridgeBaseURL string, tunnels kclient.Reader, peerConfig PeerConfig) (*Manager, error)
NewManager creates a tunnel manager whose bridge is served from bridgeBaseURL. The caller must register ServeBridge on the HTTP server mux. Supplying a peer config enables remotedialer peering; the controller layer feeds discovered EndpointSlice peers through ReconcilePeers. An omitted or empty config keeps single-replica mode.
func (*Manager) AuthenticateRequest ¶
AuthenticateRequest authenticates requests generated for the internal tunnel bridge and websocket connections made by another Obot replica.
func (*Manager) BridgeAuthorization ¶
BridgeAuthorization returns the internal header that must accompany bridge requests. ServeBridge removes this header before forwarding the request to the tunnel client.
func (*Manager) BridgeHost ¶
BridgeHost returns the gateway host:port that must be allowlisted by the safe MCP HTTP client.
func (*Manager) BridgeURL ¶
BridgeURL converts an ordinary HTTP(S) target and MCPTunnel name into an internal URL on the gateway bridge.
func (*Manager) ClaimCompositeSession ¶ added in v0.26.0
ClaimCompositeSession coalesces local claims for key, starts a reconnecting loopback registration when needed, and waits for the key to become routable. waitCtx only bounds this caller; lifetimeCtx owns the registration.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops local tunnel sessions and all outgoing peer reconnect loops.
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll closes only the tunnel clients accepted by this replica. It must not disconnect sessions owned by healthy peers during a rolling shutdown.
func (*Manager) CloseCompositeSessions ¶ added in v0.26.0
func (m *Manager) CloseCompositeSessions()
CloseCompositeSessions cancels local registrations and waits for every reconnect loop to stop before the local composite handler is closed.
func (*Manager) Connections ¶
func (m *Manager) Connections() []apitypes.TunnelConnection
Connections preserves the process-local snapshot returned by earlier versions of Manager. Use ConnectionsContext for an installation-wide view.
func (*Manager) ConnectionsContext ¶
ConnectionsContext returns a deterministic installation-wide snapshot of the configured tunnels that currently have a local or peer-advertised session. A connection may disappear immediately after the snapshot is taken.
func (*Manager) ConsumeCompositeOwnerRequest ¶ added in v0.26.0
ConsumeCompositeOwnerRequest verifies and removes the private owner-local marker. It also strips every remotedialer control header before the request can reach MMMCP. A present but invalid marker must be rejected by the caller.
func (*Manager) Disconnect ¶
Disconnect closes all tunnel clients with this name attached to this replica. Call DisconnectCredential when the previous credential ID is available so clients attached to other replicas can also be reached.
func (*Manager) DisconnectCredential ¶
DisconnectCredential closes all sessions using a tunnel's previous credential. Control connections are routed through remotedialer so clients attached to other replicas can also be reached.
func (*Manager) ForwardComposite ¶ added in v0.26.0
func (m *Manager) ForwardComposite(w http.ResponseWriter, r *http.Request, key, mcpServerName string) error
ForwardComposite forwards a complete HTTP exchange to the advertised owner. Any disappearance or transport failure is returned to the caller, which must surface it as 503 rather than executing against a different local MMMCP.
func (*Manager) HTTPClient ¶
HTTPClient returns an HTTP client that routes every request through the named tunnel. Redirects rewritten by the bridge remain on the same tunnel.
func (*Manager) HasCompositeSession ¶ added in v0.26.0
HasCompositeSession reports whether this replica or one of its peers is currently advertising the composite owner key.
func (*Manager) ReconcilePeers ¶
ReconcilePeers updates the remotedialer peer mesh to match desired. It is called by the all-replica EndpointSlice controller.
func (*Manager) ServeBridge ¶
func (m *Manager) ServeBridge(w http.ResponseWriter, r *http.Request)
ServeBridge forwards an HTTP request over the tunnel selected by the encoded internal bridge target in the request path.
func (*Manager) ServeCompositeRegistration ¶ added in v0.26.0
func (m *Manager) ServeCompositeRegistration(w http.ResponseWriter, r *http.Request)
ServeCompositeRegistration accepts only capability-authenticated loopback websocket registrations for valid composite keys.
func (*Manager) ServeConnect ¶
ServeConnect upgrades an authorized request for name. The name must come from the tunnel principal established by TunnelAuthenticator.
type PeerConfig ¶
PeerConfig configures authentication and discovery of the other Obot replicas that participate in the tunnel remotedialer mesh. An entirely empty config disables peering; otherwise every field is required.
func (PeerConfig) Enabled ¶
func (c PeerConfig) Enabled() bool
Enabled reports whether a valid config enables tunnel peering. Call Validate first when an invalid partial config must be distinguished from a disabled config.
func (PeerConfig) Validate ¶
func (c PeerConfig) Validate() error
Validate verifies that tunnel peering is either fully disabled or fully configured.