Architecture
How the namespaces are wired onto one mux, and why adding one never touches main.go.
Namespaces self-register through internal/mcpx. Each package calls mcpx.Register from its init(); the mux mounts every registered namespace on the next start.
Request lifecycle
Every request passes global middleware — panic recovery, then logging — hits the stdlib mux, and is admitted by the auth that belongs to that route: X-API-Keyfor the MCP namespaces, Clerk for the dashboard’s key API, nothing for the liveness probe.
Admission is enforced per route, not globally — so a namespace can’t forget it, and /healthz never needs a credential. memory also resolves the same key to an api_key_id to scope every row — identity, not admission.
Self-registration
Each package calls mcpx.Register from its init(), so importing it is enough to enroll the namespace. mcpx.Handler then builds every registered server, failing fastif any can’t — rather than mounting a half-working server that only breaks on the first tool call.
Adding a namespace is a new package plus a blank import — main.go never enumerates them.
Layout
cmd/server/main.go # config, graceful shutdown
internal/
mcpx/ # registry, Handler(), Chain()
memory/ # per-user memories, hybrid RAG (pg + pgvector)
skills/ # skills_find agent + skills_download + web tools
gsc/ # Google Search Console (analytics, inspection, sitemaps)
producthunt/ # Product Hunt v2 GraphQL API
event/ # Kafka publish/consume + topic admin (Confluent Cloud)Adding a namespace
- 1Create the packageAdd
internal/<name>/register.gothat callsmcpx.Registerfrominit(). - 2Blank-import itAdd the package to
cmd/server/main.goimports. The mux picks it up on the next start.
net/http; a domain never reaches across another domain except through internal/mcpx.