debug: add request logging to diagnose claude.ai connector auth
Logs method, path, origin, has_auth, user_agent per request so we can see exactly what claude.ai sends. Temporary; remove once root cause found. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,11 +57,25 @@ func main() {
|
|||||||
Sessions: mcp.NewSessionStore(),
|
Sessions: mcp.NewSessionStore(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
logReq := func(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
hasAuth := r.Header.Get("Authorization") != ""
|
||||||
|
logger.Info("request",
|
||||||
|
"method", r.Method,
|
||||||
|
"path", r.URL.Path,
|
||||||
|
"origin", r.Header.Get("Origin"),
|
||||||
|
"has_auth", hasAuth,
|
||||||
|
"user_agent", r.Header.Get("User-Agent"),
|
||||||
|
)
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("/mcp", mcp.OriginAllowlist(cfg.OriginAllowlist)(
|
mux.Handle("/mcp", logReq(mcp.OriginAllowlist(cfg.OriginAllowlist)(
|
||||||
auth.BearerMiddleware(cfg.GiteaBaseURL,
|
auth.BearerMiddleware(cfg.GiteaBaseURL,
|
||||||
auth.CallerMiddleware(mcpSrv),
|
auth.CallerMiddleware(mcpSrv),
|
||||||
),
|
)),
|
||||||
))
|
))
|
||||||
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
|
mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|||||||
Reference in New Issue
Block a user