Skip to content

chore(diagnostic): MCP_PRO_GRANT_HMAC_SECRET runtime visibility#3653

Merged
koala73 merged 1 commit into
mainfrom
fix/mcp-grant-hmac-diagnostic
May 10, 2026
Merged

chore(diagnostic): MCP_PRO_GRANT_HMAC_SECRET runtime visibility#3653
koala73 merged 1 commit into
mainfrom
fix/mcp-grant-hmac-diagnostic

Conversation

@koala73

@koala73 koala73 commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

Temporary diagnostic on top of merged PR #3646. Logs the names (not values) of every process.env key starting with MCP_ at the moment getGrantSecret() throws GrantConfigError.

Why

After #3646 merged + production deploy, every Pro user authorize click → "MCP authorization is temporarily unavailable" → mint endpoint returning CONFIGURATION_ERROR 500 → which fires only when process.env.MCP_PRO_GRANT_HMAC_SECRET is empty/unset at the apex function.

Vercel dashboard shows both MCP_PRO_GRANT_HMAC_SECRET and MCP_INTERNAL_HMAC_SECRET linked under Production+Preview as Sensitive, but vercel env ls production | grep MCP_ returns no match. Need to confirm whether the running function process actually sees the variable.

What this commit does

Adds a single console.warn at api/_mcp-grant-hmac.ts:84 when the secret is missing, before the throw:

[mcp-grant-hmac] DIAGNOSTIC missing-secret: process.env MCP_* keys = <list>

If <list> is <NONE> → link didn't actually apply.
If only MCP_INTERNAL_HMAC_SECRET → wrong key linked / typo.
If includes MCP_PRO_GRANT_HMAC_SECRET → linked but empty (separate bug).

Removal

This is temporary. Removed in the immediately-following commit once root cause is confirmed.

Test plan

  • Merge + production deploy
  • Trigger one failed Pro authorize click
  • Open Vercel Logs → filter for [mcp-grant-hmac] DIAGNOSTIC missing-secret
  • Read the listed keys to determine which of the three branches applies
  • Open follow-up PR to remove the diagnostic

TEMPORARY DIAGNOSTIC. Production reports "MCP authorization is
temporarily unavailable" on every Pro authorize click after PR #3646
merged. The mint endpoint is throwing GrantConfigError, which means
process.env.MCP_PRO_GRANT_HMAC_SECRET is empty/unset at the apex
function — but the dashboard's Shared tab shows the variable linked
to Production+Preview, and `vercel env ls production | grep MCP_`
returns no match.

Two unknowns to disambiguate:
  (a) Is the variable actually reaching the function process? Or
      is the Shared link not really applied?
  (b) If reaching, is the name correct (no typo / wrong key)?

This logs the NAMES (not values) of every process.env key starting
with `MCP_` next to the GrantConfigError throw so the next failed
authorize click in production shows conclusively:
  - <NONE>: link didn't apply / wrong project / scope mismatch
  - only MCP_INTERNAL_HMAC_SECRET: typo or partial link
  - includes MCP_PRO_GRANT_HMAC_SECRET: linked but empty (also
    surfaced as the existing GrantConfigError)

Removed in the immediately-following commit once root cause is
confirmed. Names only — no values.

After deploy, reproduce the failure once and search Vercel function
logs for the literal string `[mcp-grant-hmac] DIAGNOSTIC missing-secret`.
@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment May 10, 2026 6:41pm

Request Review

@greptile-apps

greptile-apps Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a single temporary console.warn to readGrantSecret() in api/_mcp-grant-hmac.ts that emits the names (never values) of all MCP_* env keys when MCP_PRO_GRANT_HMAC_SECRET is absent, to confirm whether the Vercel runtime actually receives the linked secret. The diagnostic is guarded by a try/catch so it cannot interfere with the existing GrantConfigError throw.

  • The new code logs only key names via Object.keys(env).filter(k => k.startsWith('MCP_')), so no secret values are written to logs.
  • The try/catch wrapper ensures the diagnostic can never suppress or delay the real configuration error on the path that callers depend on.

Confidence Score: 4/5

Safe to merge; the change is a single, well-contained diagnostic warn that cannot alter the error path or expose secret values.

The diff touches one small branch inside readGrantSecret(), logs only key names (not values), and is fully wrapped in a try/catch so it cannot interfere with the GrantConfigError throw that callers depend on. The only minor concern is that the log message labels the source as process.env while actually reflecting the env parameter, which could mislead someone reading the log if the function is called with a synthetic object. No functional regression risk.

No files require special attention beyond confirming the diagnostic is removed in the follow-up commit once root cause is confirmed.

Important Files Changed

Filename Overview
api/_mcp-grant-hmac.ts Adds a temporary console.warn diagnostic inside readGrantSecret() that logs the names (not values) of all MCP_* env keys when the HMAC secret is missing; wrapped in try/catch so it cannot suppress the real GrantConfigError.

Reviews (1): Last reviewed commit: "chore(diagnostic): log MCP_* env-key nam..." | Re-trigger Greptile

Comment thread api/_mcp-grant-hmac.ts
Comment on lines +92 to +96
console.warn(
`[mcp-grant-hmac] DIAGNOSTIC missing-secret: process.env MCP_* keys = ${
mcpKeys.length === 0 ? '<NONE>' : mcpKeys.join(', ')
}`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Log message says process.env but logs env parameter

The template string reads process.env MCP_* keys = … but the key list is built from the env parameter, which defaults to process.env in production but can be any object passed in tests or callers. If readGrantSecret is ever invoked with a synthetic env in a non-test context, the message will misattribute the source. Consider changing the label to something like runtime env MCP_* keys to avoid a misleading diagnostic trail.

@koala73
koala73 merged commit 1a387ae into main May 10, 2026
12 checks passed
@koala73
koala73 deleted the fix/mcp-grant-hmac-diagnostic branch June 25, 2026 14:43
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