"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(data): gildata token moves from the URL query string to the Authorization header
sambazhucbc537da7020
diff --git a/agent/backtest/loaders/gildata_loader.py b/agent/backtest/loaders/gildata_loader.pyindex 2e2dc137e..abbb86353 100644--- a/agent/backtest/loaders/gildata_loader.py+++ b/agent/backtest/loaders/gildata_loader.py@@ -3,8 +3,8 @@Gildata serves its market data over MCP streamable-HTTP: every tool call is oneJSON-RPC POST to a single endpoint whose token rides the URL query string::- POST https://api.gildata.com/mcp-servers/aidata-assistant-srv-rawapi- ?token=<GILDATA_TOKEN>&format=json+ POST https://api.gildata.com/mcp-servers/aidata-assistant-srv-rawapi?format=json+ Authorization: Bearer <GILDATA_TOKEN>{"jsonrpc": "2.0", "id": 1, "method": "tools/call","params": {"name": "StockDailyQuote", "arguments": {...}}}@@ -146,7 +146,10 @@ def _call_tool(tool: str, arguments: Dict[str, Any]) -> List[Dict[str, Any]]:raise RuntimeError(f"{_TOKEN_ENV} is not set")base = _base_url()- url = f"{base}{'&' if '?' in base else '?'}token={token}&format=json"+ # The token rides the Authorization header, never the URL: request+ # exceptions (DNS failure, timeout) embed the full URL in their message,+ # and a query-string token would leak into those logs (review of #1474).+ url = f"{base}{'&' if '?' in base else '?'}format=json"payload = {"jsonrpc": "2.0","id": 1,@@ -160,7 +163,10 @@ def _call_tool(tool: str, arguments: Dict[str, Any]) -> List[Dict[str, Any]]:json_body=payload,# MCP streamable-HTTP servers reject requests whose Accept header# does not name both content types (measured: 400 without it).- headers={"Accept": "application/json, text/event-stream"},+ headers={+ "Accept": "application/json, text/event-stream",+ "Authorization": f"Bearer {token}",+ },timeout=_TIMEOUT_S,)diff --git a/agent/tests/test_gildata_loader.py b/agent/tests/test_gildata_loader.pyindex 166e2aa50..e8642411a 100644--- a/agent/tests/test_gildata_loader.py+++ b/agent/tests/test_gildata_loader.py@@ -173,13 +173,16 @@ class TestFetch:out = DataLoader().fetch(["600519.SH"], "2024-01-01", "2024-01-31")assert set(out) == {"600519.SH"}assert len(out["600519.SH"]) == 2- # Token and structured-JSON flag ride the URL query string.+ # The token rides the Authorization header — never the URL, whose+ # full form request exceptions embed in their messages (review of+ # #1474: a query-string token would leak into error logs).url = mock_post.call_args[0][0]- assert "token=secret" in url+ assert "token=" not in urlassert "format=json" in url+ headers = mock_post.call_args.kwargs["headers"]+ assert headers["Authorization"] == "Bearer secret"# MCP streamable-HTTP requires the dual Accept header (measured:# the endpoint answers 400 without it).- headers = mock_post.call_args.kwargs["headers"]assert headers["Accept"] == "application/json, text/event-stream"# The JSON-RPC body routes to StockDailyQuote with qfq adjustment.body = mock_post.call_args.kwargs["json_body"]