feat(mcp): audit-log every tools/call (OWASP MCP08)
CD / Deploy via GitOps (push) Successful in 5s
CD / Lint / Test / Vet (push) Successful in 31s
CD / Build & Import (push) Successful in 14s

tools/call dispatched with no record, so repo_delete, pr_merge and
file_delete left no trail in gitea-mcp; only auth acceptance was logged.

One slog record per call: tool, caller, token fingerprint, target
(owner/repo/number/branch/path/tag), outcome, duration. Every other
argument is reduced to args_bytes so the audit line never copies file
content or issue bodies.

Closes #64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 20:34:59 +02:00
co-authored by Claude Opus 5.5
parent 59dabc9455
commit 724a997002
3 changed files with 172 additions and 0 deletions
+3
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"net/http"
"time"
"git.d-ma.be/mathias/gitea-mcp/internal/registry"
)
@@ -90,7 +91,9 @@ func (s *Server) handlePOST(w http.ResponseWriter, r *http.Request) {
NewErrorResponse(req.ID, -32602, "invalid params", nil))
return
}
start := time.Now()
out, err := s.opts.Registry.Dispatch(r.Context(), p.Name, p.Arguments)
logToolCall(r.Context(), p.Name, p.Arguments, start, err)
if err != nil {
code := -32000
if errors.Is(err, registry.ErrToolNotFound) {