fix: Remove authorization from provider data (#4161)

# What does this PR do?
- Remove backward compatibility for authorization in mcp_headers
- Enforce authorization must use dedicated parameter
- Add validation error if Authorization found in provider_data headers
- Update test_mcp.py to use authorization parameter
- Update test_mcp_json_schema.py to use authorization parameter
- Update test_tools_with_schemas.py to use authorization parameter
- Update documentation to show the change in the authorization approach

Breaking Change:
- Authorization can no longer be passed via mcp_headers in provider_data
- Users must use the dedicated 'authorization' parameter instead
- Clear error message guides users to the new approach"

## Test Plan
CI

---------

Co-authored-by: Omar Abdelwahab <omara@fb.com>
Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
(cherry picked from commit fe91d331ef)

# Conflicts:
#	src/llama_stack/providers/remote/tool_runtime/model_context_protocol/model_context_protocol.py
#	tests/integration/inference/test_tools_with_schemas.py
#	tests/integration/tool_runtime/test_mcp.py
#	tests/integration/tool_runtime/test_mcp_json_schema.py
This commit is contained in:
Omar Abdelwahab 2025-11-17 12:16:35 -08:00 committed by Mergify
parent 49a290e53e
commit 9d54a854d9
5 changed files with 178 additions and 28 deletions

View file

@ -9,8 +9,6 @@ Integration tests for inference/chat completion with JSON Schema-based tools.
Tests that tools pass through correctly to various LLM providers.
"""
import json
import pytest
from llama_stack import LlamaStackAsLibraryClient
@ -193,15 +191,19 @@ class TestMCPToolsInChatCompletion:
mcp_endpoint=dict(uri=uri),
)
<<<<<<< HEAD
provider_data = {"mcp_headers": {uri: {"Authorization": f"Bearer {AUTH_TOKEN}"}}}
auth_headers = {
"X-LlamaStack-Provider-Data": json.dumps(provider_data),
}
=======
# Use the dedicated authorization parameter
>>>>>>> fe91d331 (fix: Remove authorization from provider data (#4161))
# Get the tools from MCP
tools_response = llama_stack_client.tool_runtime.list_tools(
tool_group_id=test_toolgroup_id,
extra_headers=auth_headers,
authorization=AUTH_TOKEN,
)
# Convert to OpenAI format for inference