feat: allow api_key query parameter for ChatGPT UI
ChatGPT UI lacks custom header support for MCP servers. Added query parameter fallback (?api_key=) alongside Authorization header to authenticate requests. Updated tests to cover query param authentication.
This commit is contained in:
@@ -116,6 +116,18 @@ def test_list_tools_with_valid_key(client, mock_env):
|
||||
assert "input_schema" in tool
|
||||
|
||||
|
||||
def test_list_tools_with_query_param(client):
|
||||
"""Test /mcp/tools with API key in query parameter."""
|
||||
response = client.get(
|
||||
f"/mcp/tools?api_key={'a' * 64}"
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "tools" in data
|
||||
assert len(data["tools"]) > 0
|
||||
|
||||
|
||||
def test_list_tools_no_auth_when_disabled(client_no_auth):
|
||||
"""Test that /mcp/tools works without auth when disabled."""
|
||||
response = client_no_auth.get("/mcp/tools")
|
||||
|
||||
Reference in New Issue
Block a user