Skip to content

feat(auth): log token-less request rejections - #140

Merged
hogan-yuan merged 1 commit into
mainfrom
feat/log-auth-rejections
Sep 2, 2026
Merged

feat(auth): log token-less request rejections#140
hogan-yuan merged 1 commit into
mainfrom
feat/log-auth-rejections

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Summary

mcp_auth_layer rejects a token-less request on AuthMode::Required (main/root/v2 endpoints) with a 401, before the request ever reaches a #[tool] method — so it never showed up in our own logs at all, only in client-observed error metrics.

Confirmed this blind spot by pulling a full week of production logs: a tool (business_segments) with real traffic and a nonzero client-observed error rate had zero matching entries in our own logs, consistent with rejections happening at this layer before any of our tool-level logging runs.

Logs the request path, restricted-endpoint version (if any), and User-Agent — no token to log in this branch, since the absence of one is exactly why the request was rejected.

Test plan

  • cargo build clean
  • cargo +nightly fmt --check clean
  • cargo clippy --all-features --all-targets -- -D warnings clean
  • cargo test — 229 passed, 0 failed (2 new tests: the 401+WWW-Authenticate response, and that the rejection is actually logged with path/user-agent)

mcp_auth_layer rejects a token-less request on AuthMode::Required
(main/root/v2 endpoints) with a 401, before the request ever reaches a
#[tool] method — so it never showed up in our own logs at all, only in
client-observed error metrics. Confirmed this blind spot pulling a full
week of production logs: a tool (business_segments) with real traffic
and a nonzero client-observed error rate had zero matching entries in
our own logs, consistent with rejections happening at this layer.

Logs the request path, restricted-endpoint version (if any), and
User-Agent — no token to log in this branch, since the absence of one
is exactly why the request was rejected.
@hogan-yuan
hogan-yuan merged commit a13f854 into main Sep 2, 2026
1 check passed
@hogan-yuan
hogan-yuan deleted the feat/log-auth-rejections branch September 2, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant