Skip to content

fix(mcp): verify tokens against /v1/auth/verify, not /v1/accounts - #36

Merged
mikipalet merged 1 commit into
developfrom
fix/mcp-cheap-token-verification
Aug 5, 2026
Merged

fix(mcp): verify tokens against /v1/auth/verify, not /v1/accounts#36
mikipalet merged 1 commit into
developfrom
fix/mcp-cheap-token-verification

Conversation

@mikipalet

Copy link
Copy Markdown
Member

Why

Every MCP request verifies its bearer with a live call to the Zernio API, and that call was GET /v1/accounts — a full account listing (team resolution, ads status, counts) run to answer a yes/no question, 375k times in 3 days.

During the 2026-08-03 API degradation /v1/accounts ran at p90 32s (29% of calls over 5s). On the code shipping that day every timeout became invalid_token telling the user to clear their credentials and re-register. One customer re-ran the full OAuth flow five times in 22 minutes against tokens that were never bad, then fell back to a static API key.

1db14d3 already stopped mis-labelling those as invalid tokens. This removes the cause.

What

  • Verify against GET /v1/auth/verify (zernio-dev/Schedule-Posts-API@2bfd6a9d0), which authenticates and returns nothing else
  • Timeout 5s → 10s: a slow answer is still an answer, only an exception costs the caller its verdict
  • MCP_VERIFY_URL override, so a bad endpoint is an env-var flip on Railway rather than a redeploy
  • Test that verification targets the auth-only endpoint

Follow-ups

  • Confirm /v1/auth/verify returns 200 for a live credential before merging (it is deployed and 401s correctly for an invalid one).

🤖 Generated with Claude Code

Why: every MCP request verifies its bearer with a live call to the Zernio API,
and that call was /v1/accounts — a full account listing (team resolution, ads
status, counts) run to answer a yes/no question, 375k times in 3 days. During
the 2026-08-03 API degradation 29% of those calls crossed the 5s timeout, and
on the code shipping at the time every one of them reached a user as "your
token is invalid, clear it and re-register". One customer re-ran the whole
OAuth flow five times in 22 minutes against credentials that were never bad.

What:
- point verification at GET /v1/auth/verify, which authenticates and returns
- raise the timeout to 10s: a slow answer is still an answer
- allow MCP_VERIFY_URL to override, so a bad endpoint is an env-var flip
- test that verification targets the auth-only endpoint

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mikipalet
mikipalet force-pushed the fix/mcp-cheap-token-verification branch from 37f12f2 to ffbdae2 Compare August 5, 2026 15:21
@mikipalet
mikipalet merged commit 5c09057 into develop Aug 5, 2026
4 checks passed
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