LCORE-1366: Fixed MCP "Authorization" header not using the authorization parameter#1203
LCORE-1366: Fixed MCP "Authorization" header not using the authorization parameter#1203jrobertboos wants to merge 2 commits intolightspeed-core:mainfrom
authorization parameter#1203Conversation
WalkthroughA new processing block extracts the Authorization header from request headers and relocates it into the tool definition under the "authorization" key before existing header handling occurs. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
authorization parameter
… in get_mcp_tools tests
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
tests/unit/utils/test_responses.py (2)
363-374:⚠️ Potential issue | 🟡 MinorMissing negative assertion for
"headers"key absence.The test asserts the new
"authorization"field but omits verifying that the"headers"key is absent. Since the server config carries only"Authorization": "kubernetes"(no other headers), the implementation should produce noheaderskey at all after the fix. The analogoustest_get_mcp_tools_without_authalready uses this pattern.🛡️ Proposed addition
assert len(tools_k8s) == 1 assert tools_k8s[0]["authorization"] == "Bearer user-k8s-token" + assert "headers" not in tools_k8s[0]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/utils/test_responses.py` around lines 363 - 374, The test test_get_mcp_tools_with_kubernetes_auth should also assert that the resulting tool dict does not include a "headers" key; update the test (which calls get_mcp_tools with a ModelContextProtocolServer named "k8s-server" and token="user-k8s-token") to add an assertion like ensuring "headers" not in tools_k8s[0] so the case where only kubernetes-style Authorization results in an "authorization" field and no "headers" key is explicitly validated.
443-458:⚠️ Potential issue | 🟡 MinorMissing negative assertion for
"headers"key absence.Same gap as the k8s test: the server config has only
"Authorization"mapped to a file path, so after the fix noheaderskey should remain. The test only checks the"authorization"value.🛡️ Proposed addition
assert len(tools) == 1 assert tools[0]["authorization"] == "static-secret-token" + assert "headers" not in tools[0]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/utils/test_responses.py` around lines 443 - 458, The test test_get_mcp_tools_with_static_headers is missing an assertion that the original "headers" key is removed from the returned tool dict; update the test (which constructs ModelContextProtocolServer and calls get_mcp_tools) to assert that "headers" is not present on tools[0] (e.g., use "headers" not in tools[0] or tools[0].get("headers") is None) in addition to the existing authorization value check so the post-fix shape is validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/unit/utils/test_responses.py`:
- Around line 363-374: The test test_get_mcp_tools_with_kubernetes_auth should
also assert that the resulting tool dict does not include a "headers" key;
update the test (which calls get_mcp_tools with a ModelContextProtocolServer
named "k8s-server" and token="user-k8s-token") to add an assertion like ensuring
"headers" not in tools_k8s[0] so the case where only kubernetes-style
Authorization results in an "authorization" field and no "headers" key is
explicitly validated.
- Around line 443-458: The test test_get_mcp_tools_with_static_headers is
missing an assertion that the original "headers" key is removed from the
returned tool dict; update the test (which constructs ModelContextProtocolServer
and calls get_mcp_tools) to assert that "headers" is not present on tools[0]
(e.g., use "headers" not in tools[0] or tools[0].get("headers") is None) in
addition to the existing authorization value check so the post-fix shape is
validated.
tisnik
left a comment
There was a problem hiding this comment.
LGTM, but please update documentation as well.
Description
Fixed the bug where
authorizationheader must be passed separately from other headers in responses API.Type of change
Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
Summary by CodeRabbit