Documentation
¶
Overview ¶
Package mcpconsole wires the Phase 73k (D-119) MCP-Connections Protocol surface to its runtime-side dependencies — the Phase 28 MCP driver registry and the Phase 30 tool-side OAuth provider.
Why a separate package ¶
The `internal/protocol` package owns the MCPSurface dispatcher and the MCPAccessor / MCPOAuthAccessor interfaces, but it MUST NOT import the `mcp` driver or the `tools/auth` package (CLAUDE.md §13 — the Protocol package stays driver-free; a Protocol type that re-exported a driver type would be the reject-on-sight smell). The adapters that bridge the two live here, in a wiring package both `cmd/harbor` and the Phase 73k integration test import. The MCPSurface depends ONLY on the interfaces; this package is the single concrete that satisfies them.
Concurrent reuse (D-025) ¶
RegistryAccessor and OAuthAccessor are thin, immutable adapters — the wrapped Registry / Provider are themselves D-025-safe compiled artifacts, and the adapters add no mutable state.
Index ¶
- Variables
- type NoOAuthAccessor
- type OAuthAccessor
- func (a *OAuthAccessor) InitiateBinding(ctx context.Context, server, _ string) (string, string, error)
- func (a *OAuthAccessor) ListBindings(ctx context.Context, server string) ([]protocol.MCPBindingRow, error)
- func (a *OAuthAccessor) RevokeBinding(ctx context.Context, server, _ string) (bool, error)
- type RegistryAccessor
- func (a *RegistryAccessor) GetServer(ctx context.Context, name string) (protocol.MCPServerRow, error)
- func (a *RegistryAccessor) Health(ctx context.Context, name string) (protocol.MCPHealthRow, error)
- func (a *RegistryAccessor) ListPrompts(ctx context.Context, name string) ([]protocol.MCPPromptRow, error)
- func (a *RegistryAccessor) ListResources(ctx context.Context, name string) ([]protocol.MCPResourceRow, error)
- func (a *RegistryAccessor) ListServers(ctx context.Context, f protocol.MCPListFilter) ([]protocol.MCPServerRow, string, error)
- func (a *RegistryAccessor) Probe(ctx context.Context, name string) (protocol.MCPProbeRow, error)
- func (a *RegistryAccessor) RefreshDiscovery(ctx context.Context, name string) (protocol.MCPDiscoveryRow, error)
- func (a *RegistryAccessor) SetRawHTMLTrust(ctx context.Context, name string, trusted bool) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoOAuthConfigured = errors.New("mcpconsole: no OAuth provider configured (set tools.oauth_providers in your config to enable OAuth binding flows)")
ErrNoOAuthConfigured — the Runtime has no OAuth providers configured, so OAuth flow methods cannot be served. Surfaces as a Protocol CodeRuntimeError with an actionable message naming the missing config key.
Functions ¶
This section is empty.
Types ¶
type NoOAuthAccessor ¶
type NoOAuthAccessor struct{}
NoOAuthAccessor is the protocol.MCPOAuthAccessor implementation for Runtimes that have an MCP registry but NO operator-configured OAuth providers — the V1 `harbor dev` default when an operator attaches an MCP server without OAuth (the common case today).
The accessor projects the canonical "no binding configured" shape: ListBindings returns an empty slice for every server (no bindings to project), and InitiateBinding / RevokeBinding fail loudly with ErrNoOAuthConfigured so the Console renders an actionable message instead of a silent no-op.
This keeps the F6 contract clean: a Runtime can serve the read-only `mcp.servers.list` / `.get` / `.resources` / `.prompts` / `.health` methods (which the Console MCP Connections page leans on) without needing OAuth wiring, while the OAuth-specific verbs fail loudly per CLAUDE.md §13 (no silent degradation).
func NewNoOAuthAccessor ¶
func NewNoOAuthAccessor() *NoOAuthAccessor
NewNoOAuthAccessor returns a NoOAuthAccessor.
func (*NoOAuthAccessor) InitiateBinding ¶
func (a *NoOAuthAccessor) InitiateBinding(_ context.Context, server, _ string) (string, string, error)
InitiateBinding fails loud — without an OAuth provider there is no flow to initiate. Operators see the message in the Console toast.
func (*NoOAuthAccessor) ListBindings ¶
func (a *NoOAuthAccessor) ListBindings(_ context.Context, _ string) ([]protocol.MCPBindingRow, error)
ListBindings reports zero bindings for every server. The Console MCP Connections page renders this as "OAuth not connected" rather than as an error — the empty list is a first-class state.
func (*NoOAuthAccessor) RevokeBinding ¶
RevokeBinding fails loud — without an OAuth provider there is no binding to revoke.
type OAuthAccessor ¶
type OAuthAccessor struct {
// contains filtered or unexported fields
}
OAuthAccessor adapts a *auth.Provider to the protocol.MCPOAuthAccessor interface — the runtime-side seam the MCPSurface calls for the OAuth binding methods (`bindings.list` read + the `refresh_binding` / `revoke_binding` admin verbs).
V1 binding-enumeration scope ¶
The Phase 30 `auth.Provider` keys tokens by `(BindingScope, subject, source)` and exposes no fleet-wide binding enumeration API. At V1 the adapter therefore projects the caller-visible binding state: it reports the configured binding scope for the source and the caller's own token freshness. A fleet-wide per-server binding catalog is a post-V1 `auth.Provider` extension (page-mcp-connections.md §8 — non-admin operators see only their own ScopeUser binding regardless).
func NewOAuthAccessor ¶
func NewOAuthAccessor(provider *auth.Provider) (*OAuthAccessor, error)
NewOAuthAccessor wraps a *auth.Provider as a protocol.MCPOAuthAccessor. A nil provider is rejected — fail closed.
func (*OAuthAccessor) InitiateBinding ¶
func (a *OAuthAccessor) InitiateBinding(ctx context.Context, server, _ string) (string, string, error)
InitiateBinding implements protocol.MCPOAuthAccessor. It invokes auth.Provider.InitiateFlow and returns the AuthorizeURL + flow State the Console opens in a popup. The principalID argument is reserved for a post-V1 delegated-flow API; V1 drives the flow for the caller's own identity (the auth.Provider reads the subject from ctx).
func (*OAuthAccessor) ListBindings ¶
func (a *OAuthAccessor) ListBindings(ctx context.Context, server string) ([]protocol.MCPBindingRow, error)
ListBindings implements protocol.MCPOAuthAccessor. It projects the configured binding for the server (the OAuthConfig's BindingScope + requested scopes) and the caller's own token freshness. NEVER returns token plaintext (D-083 invariant).
func (*OAuthAccessor) RevokeBinding ¶
RevokeBinding implements protocol.MCPOAuthAccessor. It invokes auth.Provider.Revoke for the server's binding.
type RegistryAccessor ¶
type RegistryAccessor struct {
// contains filtered or unexported fields
}
RegistryAccessor adapts a *mcp.Registry to the protocol.MCPAccessor interface. It is the runtime-side read/control seam the MCPSurface calls for the nine `mcp.servers.*` read methods plus the raw-HTML trust toggle.
func NewRegistryAccessor ¶
func NewRegistryAccessor(reg *mcp.Registry) (*RegistryAccessor, error)
NewRegistryAccessor wraps a *mcp.Registry as a protocol.MCPAccessor. A nil registry is rejected — fail closed (CLAUDE.md §5).
func (*RegistryAccessor) GetServer ¶
func (a *RegistryAccessor) GetServer(ctx context.Context, name string) (protocol.MCPServerRow, error)
GetServer implements protocol.MCPAccessor.
func (*RegistryAccessor) Health ¶
func (a *RegistryAccessor) Health(ctx context.Context, name string) (protocol.MCPHealthRow, error)
Health implements protocol.MCPAccessor.
func (*RegistryAccessor) ListPrompts ¶
func (a *RegistryAccessor) ListPrompts(ctx context.Context, name string) ([]protocol.MCPPromptRow, error)
ListPrompts implements protocol.MCPAccessor.
func (*RegistryAccessor) ListResources ¶
func (a *RegistryAccessor) ListResources(ctx context.Context, name string) ([]protocol.MCPResourceRow, error)
ListResources implements protocol.MCPAccessor.
func (*RegistryAccessor) ListServers ¶
func (a *RegistryAccessor) ListServers(ctx context.Context, f protocol.MCPListFilter) ([]protocol.MCPServerRow, string, error)
ListServers implements protocol.MCPAccessor.
func (*RegistryAccessor) Probe ¶
func (a *RegistryAccessor) Probe(ctx context.Context, name string) (protocol.MCPProbeRow, error)
Probe implements protocol.MCPAccessor.
func (*RegistryAccessor) RefreshDiscovery ¶
func (a *RegistryAccessor) RefreshDiscovery(ctx context.Context, name string) (protocol.MCPDiscoveryRow, error)
RefreshDiscovery implements protocol.MCPAccessor.
func (*RegistryAccessor) SetRawHTMLTrust ¶
func (a *RegistryAccessor) SetRawHTMLTrust(ctx context.Context, name string, trusted bool) (bool, error)
SetRawHTMLTrust implements protocol.MCPAccessor.