Repository navigation
mcp-test-v1.0.1
Patch release. Closes #2 via #3: the auth chain now logs per-authenticator rejections with full diagnostic context, and the HTTP gateway emits an RFC 6750 §3 WWW-Authenticate challenge so MCP clients see a useful error alongside the 401.
No breaking changes. Drop-in upgrade from v1.0.0.
What changed
Auth chain logging
Before v1.0.1, Chain.Authenticate silently dropped errors from OIDCValidator.ValidateBearer and APIKeyStore.Authenticate and fell through to ErrNotAuthenticated. A 401 from a misconfigured deployment looked identical to a 401 from a malformed token: empty body, no log, no diagnostic surface. Operators had to modify the binary or run packet captures to find out why a token was rejected.
The chain now writes one slog line per rejection from each configured authenticator, with the underlying validator error and full request correlation:
{
"time": "2026-04-30T07:42:18Z",
"level": "WARN",
"msg": "auth: token rejected",
"method": "oidc",
"error": "audience mismatch: want \"prod\"",
"request_id": "req-abc-123",
"remote_addr": "10.0.0.7"
}request_id and remote_addr are pulled from the same context the audit middleware already populates, so a WARN line joins cleanly against the matching audit_events row.
Token redaction
The chain strips JWT-shaped substrings (xxx.yyy.zzz of base64url segments at least 8 characters each) from the validator error before logging. If a custom validator unwisely embeds the rejected bearer in its error message, the chain replaces the JWT with [redacted-jwt]. Defense in depth on top of the validators-don't-echo-tokens contract.
Rate-limited WARN
A scanner hitting the 401 path at line speed would otherwise produce one WARN per request, drowning operator logs and crowding out real signal. The chain rate-limits per remote_addr: the first failure within a 60-second window logs at WARN, subsequent failures in the same window log at DEBUG. Different sources are independent. Failures with no remote_addr (no correlation context available) always surface at WARN since there's no bucket to share.
WWW-Authenticate per RFC 6750 §3
MCPAuthGateway's 401 response now carries:
WWW-Authenticate: Bearer realm="mcp-test",
error="invalid_request",
error_description="missing or unsupported credential; supply X-API-Key or Authorization: Bearer <token>",
resource_metadata="<protected-resource-metadata-url>"
error and error_description quote escaping follows RFC 7235 §2.1 (\ and " escaped per the auth-param ABNF). MCP clients that follow the spec surface error_description to the user. The JSON body mirrors error_description for non-RFC-aware clients.
API note
Chain.WithLogger was renamed to SetLogger to match the receiver-mutation semantics. WithLogger is kept as a Deprecated: alias so existing source-level callers compile without changes. Prefer SetLogger going forward.
Operational notes
- Log volume. Expect more INFO/WARN entries during steady-state failure scenarios. The rate limiter caps unique-source bursts, but a deployment behind a single egress IP (or one that doesn't propagate
X-Forwarded-For) may see all failures attributed to the sameremote_addrand rate-limited together. If that's noisier than you want, lower slog level filtering on the auth-token-rejected line specifically, or setaudit.enabledand use theaudit_eventstable as the canonical record. - Backwards compatibility. Public API is unchanged:
auth.NewChain(allowAnonymous, apiKeys, oidc)works as before. The newSetLoggeris additive. - No config flags introduced. Logging behavior is on by default.
Installation
Container
docker pull ghcr.io/plexara/mcp-test:v1.0.1The image ships only the binary and LICENSE; mount your own config:
docker run --rm \
-v $(pwd)/mcp-test.yaml:/app/configs/mcp-test.yaml:ro \
-p 8080:8080 \
ghcr.io/plexara/mcp-test:v1.0.1Binary (macOS / Linux)
curl -L -o mcp-test.tar.gz \
https://github.com/plexara/mcp-test/releases/download/v1.0.1/mcp-test_1.0.1_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
tar -xzf mcp-test.tar.gz
./mcp-test --versionDocumentation
Full docs at https://mcp-test.plexara.io.
Verification
After upgrading, the changes are visible from a single curl:
curl -i http://localhost:8080/
# HTTP/1.1 401 Unauthorized
# WWW-Authenticate: Bearer realm="mcp-test", error="invalid_request",
# error_description="missing or unsupported credential...",
# resource_metadata="..."
# {"error":"unauthorized","error_description":"missing or unsupported credential"}For the chain logs, hit the same path with a bearer the OIDC validator rejects and check the binary's stderr for the auth: token rejected JSON line.
Open source by Plexara, the commercial MCP server with configurable enrichment built in.