Skip to content

fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links - #5104

Merged
Pratham-Mishra04 merged 3 commits into
maximhq:devfrom
MarcusPeng:07-11-fix_mcp_auth_temp_token_fragment_reminder
Jul 13, 2026
Merged

Pratham-Mishra04 merged 3 commits into
maximhq:devfrom
MarcusPeng:07-11-fix_mcp_auth_temp_token_fragment_reminder

Conversation

@MarcusPeng

Copy link
Copy Markdown
Contributor

Summary

When MCPEnableTempTokenAuth is on, per-user MCP auth flows (OAuth and headers) mint a one-time temp token embedded as a #t=<token> URL fragment on the auth link returned to the caller. Fragments never reach the server, so the token can't leak into access logs or get forwarded as a Referer header — but an AI agent relaying the link to a human frequently drops everything after the #, treating it as a non-essential anchor, which breaks the link.

Changes

  • Added schemas.MCPAuthURLHasTempTokenFragment and schemas.MCPAuthTempTokenReminder
  • Wired them into the inline-auth Message wherever it's built (per-user OAuth resolver, per-user headers resolver, bifrost-http's MCP server tool-call error path), only appending the reminder when the URL actually carries the #t= fragment
  • Added unit tests covering both resolvers and the fragment-detection helper

Type of change

  • Bug fix

Affected areas

  • Core (Go)
  • Transports (HTTP)

How to test

go test ./core/schemas/... ./core/mcp/credstore/... ./transports/bifrost-http/handlers/...

Breaking changes

  • Yes
  • No

Security considerations

None — the fragment was already never sent to the server; this only changes the accompanying human-readable message text.

MarcusPeng and others added 2 commits July 11, 2026 02:54
…inline-auth links

When MCPEnableTempTokenAuth is on, per-user MCP auth flows (OAuth and
headers) mint a one-time temp token embedded as a `#t=<token>` URL
fragment on the auth link returned to the caller. Fragments never reach
the server, so the token can't leak into access logs or get forwarded
as a Referer header — but an AI agent relaying the link to a human
frequently drops everything after the `#`, treating it as a
non-essential anchor, which breaks the link.

Adds schemas.MCPAuthURLHasTempTokenFragment and
schemas.MCPAuthTempTokenReminder, and uses them to conditionally append
a reminder to the inline-auth Message wherever it's built, only when
the URL actually carries the fragment (the mint is best-effort and
skipped for MCPAuthModeUser flows).

Affected packages:
- core: schemas.MCPAuthURLHasTempTokenFragment/MCPAuthTempTokenReminder,
  per-user OAuth and per-user headers credstore resolvers
- transports: bifrost-http's own MCP server tool-call error path

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jul 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 20bf855e-62d0-4ff1-9e81-ac27b11700fa

📥 Commits

Reviewing files that changed from the base of the PR and between e78c2d0 and d755477.

📒 Files selected for processing (1)
  • core/changelog.md

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • MCP authentication-required messages now conditionally include a reminder to keep the #t= temporary-token fragment when copying or sharing inline-auth links.
    • The reminder is shown only when the returned authorization URL contains a temp-token fragment, reducing unnecessary prompts.
  • Documentation

    • Added changelog entries documenting the #t= truncation warning behavior.
  • Tests

    • Added coverage for temp-token–aware authentication-required messaging across relevant MCP connection paths.

Walkthrough

Changes

The MCP auth flow now detects #t= fragments in authorization URLs and appends a temp-token handling reminder to per-user credential and HTTP tool authentication errors. Shared schema logic and tests cover fragment detection and message behavior.

MCP temp-token auth reminders

Layer / File(s) Summary
Auth URL reminder contract
core/schemas/mcp.go, core/schemas/mcp_test.go
Adds the shared reminder constant and MCPAuthURLHasTempTokenFragment helper, with cases covering matching, absent, alternate, and empty fragments.
Credential resolver messages
core/mcp/credstore/per_user_headers.go, core/mcp/credstore/per_user_headers_test.go, core/mcp/credstore/per_user_oauth.go, core/mcp/credstore/per_user_oauth_test.go
Per-user headers and OAuth authentication-required errors conditionally include the reminder, with provider-backed tests for URLs with and without #t= fragments.
HTTP tool auth message
transports/bifrost-http/handlers/mcpserver.go, transports/changelog.md, core/changelog.md
MCP tool authentication errors conditionally include the reminder, and changelog entries document the temp-token fragment behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant perUserOAuthResolver
  participant MCPAuthURLHasTempTokenFragment
  participant MCPToolHandler
  MCPClient->>perUserOAuthResolver: Request connection headers
  perUserOAuthResolver->>MCPAuthURLHasTempTokenFragment: Check authorize URL
  MCPAuthURLHasTempTokenFragment-->>perUserOAuthResolver: Fragment present or absent
  perUserOAuthResolver-->>MCPClient: MCPAuthRequiredError with conditional reminder
  MCPClient->>MCPToolHandler: Execute MCP tool
  MCPToolHandler->>MCPAuthURLHasTempTokenFragment: Check auth URL
  MCPAuthURLHasTempTokenFragment-->>MCPToolHandler: Fragment present or absent
  MCPToolHandler-->>MCPClient: Tool error with conditional reminder
Loading

Possibly related PRs

Suggested reviewers: akshaydeo, danpiths, roroghost17

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a warning about the #t= temp-token fragment on MCP inline-auth links.
Description check ✅ Passed The description follows the required template and covers the summary, changes, testing, affected areas, breaking changes, and security notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
core/schemas/mcp.go Adds the temp-token reminder text and the shared fragment-detection helper.
core/mcp/credstore/per_user_oauth.go Adds the reminder to OAuth auth-required messages when the authorize URL includes the temp-token fragment.
core/mcp/credstore/per_user_headers.go Adds the reminder to headers auth-required messages when the submission URL includes the temp-token fragment.
transports/bifrost-http/handlers/mcpserver.go Adds the same reminder to MCP server tool-call auth errors when the selected auth URL includes the temp-token fragment.
core/schemas/mcp_test.go Adds tests for temp-token fragment detection.
core/mcp/credstore/per_user_oauth_test.go Adds tests for OAuth resolver reminder behavior.
core/mcp/credstore/per_user_headers_test.go Adds tests for headers resolver reminder behavior.

Reviews (2): Last reviewed commit: "Merge branch 'dev' into 07-11-fix_mcp_au..." | Re-trigger Greptile

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
Signed-off-by: Marcus <MarcusPeng@users.noreply.github.com>
@Pratham-Mishra04
Pratham-Mishra04 merged commit 218d3a7 into maximhq:dev Jul 13, 2026
6 checks passed
tcx4c70 added a commit to tcx4c70/bifrost that referenced this pull request Jul 13, 2026
* origin/dev: (79 commits)
  chore: add `helm-update` Claude skill for syncing Helm chart with `config.schema.json` (maximhq#5144)
  fix: web search options to google search mapping in gemini api (maximhq#5139)
  feat: add `postgresql.external.port` string support and `bifrost.mcp.toolGroups[*].id` to Helm chart (maximhq#5143)
  fix: parse `SecretVar` JSON with `ref`/`env_var` fields even when `value` is absent (maximhq#5146)
  Revert "fix: less strict unmarshalling for secret var (maximhq#4723)" (maximhq#5145)
  fix: max reasoning effort in openai (maximhq#5130)
  chore: replace manual `helm registry login` steps with `step-security/docker-login-action` (maximhq#5132)
  fix: support GA transcription-type sessions in POST /v1/realtime/client_secrets (maximhq#5092)
  community: add Xquik to MCP library (maximhq#5069)
  fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links (maximhq#5104)
  chore: build fix in core (maximhq#5129)
  fix: never persist masked provider key previews (maximhq#5106)
  Filter out provider-level keys from selector in prompt manager (maximhq#5018)
  fix: show user popover when `userInfo` exists and include `preferred_username` as display name fallback (maximhq#5098)
  fix: use `AutoMigrate` and add `runner_id`/`created_by_user_id` columns to sidekiq table migration (maximhq#5085)
  dds new harness skill and updates based on merged PRs (maximhq#5126)
  dds new harness skill and updates based on merged PRs (maximhq#5123)
  Add Trendshift badge to README (maximhq#5124)
  fix: make tracing span lookup nil-safe to prevent panic on streaming errors (maximhq#4896)
  Revert "fix: synthesize per-query rerank usage for Bedrock and Vertex (maximhq#4322)" (maximhq#5122)
  ...
akshaydeo pushed a commit that referenced this pull request Jul 14, 2026
…inline-auth links (#5104)

* fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links

When MCPEnableTempTokenAuth is on, per-user MCP auth flows (OAuth and
headers) mint a one-time temp token embedded as a `#t=<token>` URL
fragment on the auth link returned to the caller. Fragments never reach
the server, so the token can't leak into access logs or get forwarded
as a Referer header — but an AI agent relaying the link to a human
frequently drops everything after the `#`, treating it as a
non-essential anchor, which breaks the link.

Adds schemas.MCPAuthURLHasTempTokenFragment and
schemas.MCPAuthTempTokenReminder, and uses them to conditionally append
a reminder to the inline-auth Message wherever it's built, only when
the URL actually carries the fragment (the mint is best-effort and
skipped for MCPAuthModeUser flows).

Affected packages:
- core: schemas.MCPAuthURLHasTempTokenFragment/MCPAuthTempTokenReminder,
  per-user OAuth and per-user headers credstore resolvers
- transports: bifrost-http's own MCP server tool-call error path

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix: include mcpserver.go temp-token reminder change (missed in prior push)

---------

Signed-off-by: Marcus <MarcusPeng@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…inline-auth links (maximhq#5104)

* fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links

When MCPEnableTempTokenAuth is on, per-user MCP auth flows (OAuth and
headers) mint a one-time temp token embedded as a `#t=<token>` URL
fragment on the auth link returned to the caller. Fragments never reach
the server, so the token can't leak into access logs or get forwarded
as a Referer header — but an AI agent relaying the link to a human
frequently drops everything after the `#`, treating it as a
non-essential anchor, which breaks the link.

Adds schemas.MCPAuthURLHasTempTokenFragment and
schemas.MCPAuthTempTokenReminder, and uses them to conditionally append
a reminder to the inline-auth Message wherever it's built, only when
the URL actually carries the fragment (the mint is best-effort and
skipped for MCPAuthModeUser flows).

Affected packages:
- core: schemas.MCPAuthURLHasTempTokenFragment/MCPAuthTempTokenReminder,
  per-user OAuth and per-user headers credstore resolvers
- transports: bifrost-http's own MCP server tool-call error path

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix: include mcpserver.go temp-token reminder change (missed in prior push)

---------

Signed-off-by: Marcus <MarcusPeng@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…inline-auth links (maximhq#5104)

* fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links

When MCPEnableTempTokenAuth is on, per-user MCP auth flows (OAuth and
headers) mint a one-time temp token embedded as a `#t=<token>` URL
fragment on the auth link returned to the caller. Fragments never reach
the server, so the token can't leak into access logs or get forwarded
as a Referer header — but an AI agent relaying the link to a human
frequently drops everything after the `#`, treating it as a
non-essential anchor, which breaks the link.

Adds schemas.MCPAuthURLHasTempTokenFragment and
schemas.MCPAuthTempTokenReminder, and uses them to conditionally append
a reminder to the inline-auth Message wherever it's built, only when
the URL actually carries the fragment (the mint is best-effort and
skipped for MCPAuthModeUser flows).

Affected packages:
- core: schemas.MCPAuthURLHasTempTokenFragment/MCPAuthTempTokenReminder,
  per-user OAuth and per-user headers credstore resolvers
- transports: bifrost-http's own MCP server tool-call error path

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix: include mcpserver.go temp-token reminder change (missed in prior push)

---------

Signed-off-by: Marcus <MarcusPeng@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

4 participants