diff --git a/.gitignore b/.gitignore index 0913e80..c839cd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Binary st-pierre +# Nix build result +result + # Environment .env diff --git a/main.go b/main.go index 5520848..6431291 100644 --- a/main.go +++ b/main.go @@ -78,11 +78,16 @@ func main() { streamableServer := server.NewStreamableHTTPServer(mcpServer) - authHandler := authMiddleware(token, streamableServer) + mux := http.NewServeMux() + mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("ok")) + }) + mux.Handle("/mcp", authMiddleware(token, streamableServer)) httpServer := &http.Server{ Addr: ":" + port, - Handler: corsMiddleware(authHandler), + Handler: corsMiddleware(mux), } logger.Info("starting", zap.String("port", port)) @@ -160,7 +165,11 @@ func handleStoreKnowledge(sqlite *sqliteStore, qdrant *qdrantStore, logger *zap. note, ok := args["note"].(string) if !ok || note == "" { - return mcp.NewToolResultError("note is required and must be a non-empty string"), nil + if content, ok := args["content"].(string); ok && content != "" { + note = content + } else { + return mcp.NewToolResultError("note (or content) is required and must be a non-empty string"), nil + } } repos := parseStringSlice(args["repos"]) @@ -238,12 +247,6 @@ func handleSearchKnowledge(sqlite *sqliteStore, qdrant *qdrantStore) server.Tool func authMiddleware(token string, next http.Handler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/health" { - w.WriteHeader(http.StatusOK) - w.Write([]byte("ok")) - return - } - authHeader := strings.ToLower(r.Header.Get("Authorization")) if !strings.HasPrefix(authHeader, "bearer ") || strings.TrimPrefix(authHeader, "bearer ") != token { w.Header().Set("Content-Type", "application/json")