Skip to content

test(mcp): cover user OAuth in prompt and resource operations - #37625

Closed
xiehuanyi wants to merge 3 commits into
BerriAI:mainfrom
xiehuanyi:bugfix/mcp-prompt-resource-oauth-auth
Closed

xiehuanyi wants to merge 3 commits into
BerriAI:mainfrom
xiehuanyi:bugfix/mcp-prompt-resource-oauth-auth

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Aug 20, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • OAuth coverage misses four prompt and resource operations

How it solves it:

  • Check stored credentials across five operations for two users

The current main branch already passes auth through the prompt and resource clients. This PR expands the existing stored-OAuth regression to cover prompt listing, resource listing, template listing, prompt retrieval, and resource reading. It checks the user identities sent to the injected token store and the bearer credentials transmitted by the real MCP client through an in-memory HTTP transport

Relevant issues

Refs #37497

Validation

1536 tests pass across the manager and endpoint test files. The repository pre-commit check, Ruff, the type-discipline budget, and the test-quality budget pass. Replacing credential propagation with None makes all five regression cases fail

Pre-Submission checklist

  • Meaningful regression coverage added
  • Affected tests pass locally
  • Current-head required CI checks complete
  • Current-head Greptile confidence is at least 4/5

Type

Test

Caveats

Low

  • Live OAuth provider and deployed-proxy verification remain untested

High

  • Optional OSV check reports existing braces 3.0.3 vulnerability

The dependency manifests match main. The scanner reports no fixed version for GHSA-vfj7-8cjw-p6xm. OSV is outside main's required status checks, and #44347 tracks the repository-wide exception

Tools already forwarded per-user OAuth context into MCP client
construction. Prompt and resource paths omitted it, so protected
prompts/list and resources/list returned 401 after tools/list succeeded.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 11:03
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR consistently propagates request-scoped authentication into MCP prompt and resource client construction, aligning those operations with existing tool handling.

  • Adds user_api_key_auth to all five prompt/resource manager paths.
  • Forwards authentication from aggregate prompt and resource handlers.
  • Adds regression coverage verifying identity-preserving propagation into _create_mcp_client.

Confidence Score: 5/5

The PR appears safe to merge because every reachable prompt and resource path now consistently forwards the request-scoped authentication context.

The changed call chain preserves the caller identity from the aggregate MCP handlers through all prompt and resource manager operations into client construction, with focused coverage for each affected operation and no accepted regression.

Important Files Changed

Filename Overview
litellm/proxy/_experimental/mcp_server/mcp_server_manager.py Adds optional request authentication to every prompt/resource manager operation and forwards it consistently into MCP client construction.
litellm/proxy/_experimental/mcp_server/server.py Threads the authenticated request context through all aggregate prompt and resource list/get/read call sites.
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py Adds focused regression coverage for all five manager paths and updates direct handler tests for the new argument.

Reviews (1): Last reviewed commit: "fix(mcp): pass user auth into prompt and..." | Re-trigger Greptile

Copilot AI left a comment

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.

Pull request overview

This PR fixes MCP OAuth auth-context propagation so prompt and resource operations reuse the same per-user credential path already used for tools

Changes:

  • Plumb user_api_key_auth through MCP prompt and resource manager methods into _create_mcp_client
  • Forward user_api_key_auth from server prompt/resource endpoints to the manager
  • Add regression tests ensuring all prompt/resource manager entrypoints pass the auth context

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
litellm/proxy/_experimental/mcp_server/mcp_server_manager.py Adds user_api_key_auth to prompt/resource manager APIs and forwards it to _create_mcp_client
litellm/proxy/_experimental/mcp_server/server.py Passes user_api_key_auth into prompt/resource manager calls from server routes
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py Extends endpoint tests and adds a regression test for auth propagation across manager paths

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing xiehuanyi:bugfix/mcp-prompt-resource-oauth-auth (e0473fa) with litellm_internal_staging (6d47468)

Open in CodSpeed

@yuneng-berri
yuneng-berri deleted the branch BerriAI:main September 13, 2026 04:43
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 15:01
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 23, 2026 15:01
@xiehuanyi xiehuanyi changed the title fix(mcp): pass user auth into prompt and resource clients test(mcp): cover user OAuth in prompt and resource operations Oct 2, 2026
@xiehuanyi xiehuanyi closed this Oct 6, 2026
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