Skip to content

fix(auth-transport): forward authenticated users, skip per-tool checks#2801

Open
vibegui wants to merge 1 commit intomainfrom
fix/auth-transport-forward-user
Open

fix(auth-transport): forward authenticated users, skip per-tool checks#2801
vibegui wants to merge 1 commit intomainfrom
fix/auth-transport-forward-user

Conversation

@vibegui
Copy link
Contributor

@vibegui vibegui commented Mar 22, 2026

Summary

  • Authenticated users (browser session or MCP OAuth) are forwarded directly to downstream MCP servers
  • Per-tool AccessControl checks are preserved only for API keys
  • Fixes "Access denied" when Claude Code CLI calls tools through Mesh connections

The Problem

AuthTransport.authorizeToolCall() ran per-tool permission checks for ALL callers, including authenticated users. For MCP OAuth sessions (Claude Code CLI), the org context wasn't properly resolved, causing AccessControl to deny access.

The Fix

If the caller has a user.id (authenticated via browser session or MCP OAuth), just forward the call — the downstream MCP server handles its own auth. Only run granular AccessControl checks for API keys, where fine-grained permissions are the expected model.

+    // Authenticated users are forwarded directly.
+    // Granular per-tool permission checks only apply to API keys.
+    if (ctx.auth.user?.id && !ctx.auth.apiKey?.id) {
+      return;
+    }

Test plan

  • Claude Code CLI can call tools on MCP connections without "Access denied"
  • Browser session tool calls continue to work
  • API keys with granular permissions still enforce per-tool checks
  • Unauthenticated requests still get "Authentication required" error

🤖 Generated with Claude Code


Summary by cubic

Authenticated users are now forwarded directly to downstream MCP servers; per-tool checks only run for API keys. Fixes "Access denied" for Claude Code CLI via MCP OAuth over Mesh.

  • Bug Fixes
    • Skip per-tool AccessControl when a user.id is present and no API key is used.
    • Keep granular per-tool checks for API keys using apiKey.userId.
    • Unauthenticated requests still return "Authentication required".

Written for commit 54d330b. Summary will update on new commits.

…ool checks

Authenticated users (browser session or MCP OAuth) are now forwarded
directly to downstream MCP servers without per-tool permission checks.
The downstream server handles its own authorization.

Granular per-tool AccessControl checks are preserved for API keys only,
where fine-grained permissions (e.g., { "conn_<id>": ["TOOL_A"] }) are
the expected access control model.

This fixes "Access denied" errors when Claude Code CLI (which uses MCP
OAuth) tries to call tools on connections. The user is already
authenticated — Mesh shouldn't second-guess which tools they can use
on connections they have access to.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Contributor

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 2.187.1-alpha.1
🎉 Patch 2.187.1
❤️ Minor 2.188.0
🚀 Major 3.0.0

Current version: 2.187.0

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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