Documentation
¶
Overview ¶
Package registry is the listener-independent server registry for the MCP Security Gateway (PR-2, Capability B only). It holds the immutable set of registered upstream MCP servers, each bound to a stable opaque ServerID and a PINNED verified identity, and it owns the server enable/disable lifecycle and the identity-change transition (MCP-SERVER-001/002/003).
It is a pure data engine: it binds no socket, performs no TLS handshake or certificate retrieval, and makes no outbound call. Verified identity and endpoint data arrive as EXPLICIT caller-supplied inputs; the registry owns the comparison and the resulting state transition, never the network verification. Readers consult immutable Snapshots with no lock.
Index ¶
- type CredentialProfile
- type Endpoint
- type Identity
- type OwnerScope
- type Registration
- type Registry
- func (r *Registry) Current() *Snapshot
- func (r *Registry) Register(in Registration) (ServerRecord, error)
- func (r *Registry) Repin(id ServerID, newIdentity Identity, updatedAt time.Time) (ServerRecord, error)
- func (r *Registry) SetEnabled(id ServerID, enabled bool) (ServerRecord, error)
- func (r *Registry) VerifyIdentity(id ServerID, observed Identity) (Verification, ServerRecord, error)
- type ServerID
- type ServerRecord
- type Snapshot
- type Verification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CredentialProfile ¶
type CredentialProfile string
CredentialProfile is an OPAQUE reference to a scoped upstream credential class. The registry stores and compares it as an identifier only — it never holds a bearer token, password, private key or any raw credential material.
type Endpoint ¶
type Endpoint string
Endpoint is a canonical endpoint identity supplied by the caller (already resolved/canonicalized upstream — the registry does not parse URLs or dial). It is validated only for basic canonical well-formedness and uniqueness.
type Identity ¶
type Identity string
Identity is the pinned, verified TLS/workload identity in a CANONICAL string representation chosen by the caller (e.g. a SPIFFE ID or a cert-key fingerprint). Identity comparison is EXACT over this canonical representation; the registry never interprets its structure.
type OwnerScope ¶
type OwnerScope string
OwnerScope is an ownership / tenant scope token. It is opaque to the registry.
type Registration ¶
type Registration struct {
ID ServerID
Endpoint Endpoint
PinnedIdentity Identity
Capability protocol.Capability
CredentialProfile CredentialProfile
OwnerScope OwnerScope
CreatedAt time.Time
UpdatedAt time.Time
}
Registration is the caller-supplied input to Register. The registry validates it and stamps Enabled=true, Verification=VerifyVerified, and the Revision.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns the live registry state. Writes are serialized by mu (a leaf lock never held across a call into another subsystem, so no ABBA is possible); reads go through an atomic snapshot pointer and take no lock.
func New ¶
func New(lim limits.CatalogLimits) *Registry
New returns an empty Registry bounded by lim.
func (*Registry) Register ¶
func (r *Registry) Register(in Registration) (ServerRecord, error)
Register validates in and adds a new enabled+verified server, returning a copy of the stored record. It fails on a malformed field, a duplicate id, an already-registered canonical endpoint, a non-Gateway capability, or when the server capacity is reached — leaving the current snapshot unchanged on any error.
func (*Registry) Repin ¶
func (r *Registry) Repin(id ServerID, newIdentity Identity, updatedAt time.Time) (ServerRecord, error)
Repin is the documented recovery path after an identity change: it re-pins an EXISTING server to a freshly VERIFIED identity (supplied by the caller — the registry does not perform the verification), clears the mismatch, and re-enables the server under its stable ServerID. It fails for an unknown id or a malformed identity, leaving the snapshot unchanged. This is the ONLY transition that clears VerifyIdentityMismatch, so a mismatched server is never permanently stuck: an operator re-verifies out of band and calls Repin.
func (*Registry) SetEnabled ¶
func (r *Registry) SetEnabled(id ServerID, enabled bool) (ServerRecord, error)
SetEnabled toggles the admin enable/disable flag. It refuses to re-enable a server whose identity mismatched: that transition is cleared only by a fresh registration (re-verification), never by an admin flag. An unknown id returns ReasonUnregisteredServer.
func (*Registry) VerifyIdentity ¶
func (r *Registry) VerifyIdentity(id ServerID, observed Identity) (Verification, ServerRecord, error)
VerifyIdentity compares a freshly VERIFIED identity (supplied by the caller — the registry does not perform the network verification) against the server's pin. On an EXACT match it returns (VerifyVerified, record, nil). On a mismatch it DISABLES the server, records VerifyIdentityMismatch in a new snapshot, and returns a ReasonServerIdentityMismatch error — a server-level transition that can never be downgraded to tool-schema drift (MCP-SERVER-003). An unknown id returns ReasonUnregisteredServer.
type ServerID ¶
type ServerID string
ServerID is the stable, opaque registry identity of a server. It is NOT a display name, hostname or URL — those are attributes, never identity. Two records with the same ServerID are the same server; everything else can change.
type ServerRecord ¶
type ServerRecord struct {
ID ServerID
Endpoint Endpoint // canonical endpoint identity
PinnedIdentity Identity // verified, pinned TLS/workload identity
Capability protocol.Capability // Gateway only in PR-2
CredentialProfile CredentialProfile // opaque reference only
OwnerScope OwnerScope // ownership / tenant scope
Enabled bool // false ⇒ not eligible for discovery ingestion
Verification Verification // explicit verification state
Revision uint64 // registry revision at which this record was last written
CreatedAt time.Time // caller-supplied metadata
UpdatedAt time.Time // caller-supplied metadata
}
ServerRecord is one immutable registered-server record. Callers receive copies and never mutate it; a state change produces a NEW record in a NEW snapshot.
func (ServerRecord) Usable ¶
func (r ServerRecord) Usable() bool
Usable reports whether the server is eligible for discovery ingestion: enabled AND with a verified (not mismatched) identity.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is an immutable point-in-time view of the registry. Its maps are never mutated after publication, so any number of readers may use a Snapshot concurrently with no lock while writers publish newer ones (copy-on-write).
func (*Snapshot) Get ¶
func (s *Snapshot) Get(id ServerID) (ServerRecord, bool)
Get returns a COPY of the record for id and whether it is present. Callers receive a value, never the stored pointer, so they cannot mutate the snapshot.
func (*Snapshot) Servers ¶
func (s *Snapshot) Servers() []ServerRecord
Servers returns copies of all records in deterministic ServerID order.
type Verification ¶
type Verification uint8
Verification is a server's explicit identity-verification state.
const ( // VerifyVerified — the pinned identity is the current trusted baseline. VerifyVerified Verification = iota // VerifyIdentityMismatch — a later verified identity did NOT match the pin; the // server is disabled until re-verified (MCP-SERVER-003). Terminal until a fresh // registration re-pins it. VerifyIdentityMismatch )
func (Verification) String ¶
func (v Verification) String() string
String returns the verification-state label.