refactor(mcp): compose origin allowlist as middleware, remove duplication

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-05-04 20:58:08 +02:00
parent 36765b8360
commit ba5068648b
3 changed files with 23 additions and 28 deletions

View File

@@ -23,13 +23,12 @@ func main() {
// Tool registration happens in Phase 6+; for now, registry is empty.
mcpSrv := mcp.NewServer(mcp.ServerOptions{
Registry: reg,
OriginAllowlist: cfg.OriginAllowlist,
Sessions: mcp.NewSessionStore(),
Registry: reg,
Sessions: mcp.NewSessionStore(),
})
mux := http.NewServeMux()
mux.Handle("/mcp", mcpSrv)
mux.Handle("/mcp", mcp.OriginAllowlist(cfg.OriginAllowlist)(mcpSrv))
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))