Skip to content

Conversation

@Sameerlite
Copy link
Collaborator

@Sameerlite Sameerlite commented Nov 20, 2025

Title

feat: Add header passing support for MCP tools in Responses API

Relevant issues

Fixes LIT-1501

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

  • Extract headers from secret_fields.raw_headers and tools[].headers
  • Merge headers from both sources before passing to MCP server
  • Add extract_mcp_headers_from_request utility method
  • Fix tool name prefix handling in _execute_tool_calls
  • Add get_mcp_servers_from_ids method to MCPServerManager
  • Ensure raw_headers is properly converted to dict before use

#Testing:
Screenshot 2025-11-20 at 4 16 32 PM

- Extract headers from secret_fields.raw_headers and tools[].headers
- Merge headers from both sources before passing to MCP server
- Add extract_mcp_headers_from_request utility method
- Fix tool name prefix handling in _execute_tool_calls
- Add get_mcp_servers_from_ids method to MCPServerManager
- Ensure raw_headers is properly converted to dict before use
@vercel
Copy link

vercel bot commented Nov 20, 2025

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

Project Deployment Preview Comments Updated (UTC)
litellm Error Error Nov 20, 2025 11:18am

@Sameerlite Sameerlite marked this pull request as ready for review November 20, 2025 15:53
@Sameerlite Sameerlite changed the base branch from main to litellm_sameer_nov_3 November 20, 2025 16:00
)

# Extract MCP auth headers from the request to pass to MCP server
secret_fields = kwargs.get("secret_fields")
Copy link
Contributor

Choose a reason for hiding this comment

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

type this please

oauth2_headers,
raw_headers_from_request,
) = ResponsesAPIRequestUtils.extract_mcp_headers_from_request(
secret_fields=secret_fields,
Copy link
Contributor

Choose a reason for hiding this comment

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

does this cover the null case?

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.

3 participants