"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(deps): require mcp>=1.30 so the HTTP transport reclaims sessions
Haozhe Wufbe8091ac1e8
diff --git a/agent/tests/test_mcp_oauth_schema.py b/agent/tests/test_mcp_oauth_schema.pyindex 0624af116..2612dc246 100644--- a/agent/tests/test_mcp_oauth_schema.py+++ b/agent/tests/test_mcp_oauth_schema.py@@ -296,17 +296,23 @@ def test_ibkr_oauth_registration_uses_browser_headers(tmp_path) -> None:},request=request,)+ # Mirrors IBKR's live documents, fetched 2026-10-21: the protected+ # resource names https://api.ibkr.com, the issuer every well-known+ # path reports (until 2026-09 it named https://api.ibkr.com/oauth2,+ # which mcp>=1.30's RFC 8414 issuer check refuses).if url == f"{cfg.url}/.well-known/oauth-protected-resource":return httpx.Response(200,json={"resource": cfg.url,- "authorization_servers": ["https://api.ibkr.com/oauth2"],- "scopes_supported": ["mcp.read"],+ "authorization_servers": ["https://api.ibkr.com"],+ "scopes_supported": ["mcp.read", "mcp.write", "mcp.orders.submit"],+ "bearer_methods_supported": ["header"],},request=request,)if url in {+ "https://api.ibkr.com/.well-known/oauth-authorization-server","https://api.ibkr.com/.well-known/oauth-authorization-server/oauth2","https://api.ibkr.com/oauth2/.well-known/oauth-authorization-server",}:@@ -508,21 +514,15 @@ def test_stdio_path_unchanged() -> None:assert isinstance(transport, StdioTransport)-def test_mcp_version_is_capped_below_the_strict_issuer_check() -> None:- """The IBKR OAuth path depends on this cap; a silent bump breaks the broker.+def test_mcp_floor_includes_the_session_reclamation_fix() -> None:+ """``--transport http`` needs mcp>=1.30 (CVE-2026-59951).- mcp 1.30.0 enforces RFC 8414 section 3.3 — an authorization server's- metadata `issuer` must equal the issuer used to build the well-known URL.- IBKR's official MCP server advertises the authorization server- ``https://api.ibkr.com/oauth2`` while its metadata (both well-known paths,- verified live 2026-09-08) reports ``"issuer": "https://api.ibkr.com"``, so- discovery raises ``OAuthFlowError`` before any token is requested and no- IBKR connection can be established.-- ``test_ibkr_oauth_registration_uses_browser_headers`` above is the same- finding at the fixture level, and its fixture mirrors the live document —- so making it pass by editing the fixture would hide a broken broker- behind a green suite. This test guards the actual remedy instead.+ Before 1.30 a stateful Streamable HTTP server never reclaimed sessions:+ no expiry, a DELETEd session stayed registered and there was no cap, so+ ordinary short requests grew server memory without bound. 0.1.15-0.1.17+ capped mcp below 1.30 because 1.30's RFC 8414 issuer check refused IBKR's+ metadata; IBKR's protected-resource document now names the same issuer+ (fixture above), so the requirement is a floor again."""import tomllibfrom pathlib import Path@@ -533,15 +533,9 @@ def test_mcp_version_is_capped_below_the_strict_issuer_check() -> None:dependencies = tomllib.loads(pyproject.read_text(encoding="utf-8"))["project"]["dependencies"]- caps = [- Requirement(entry)- for entry in dependencies- if Requirement(entry).name == "mcp"- ]- assert caps, "the mcp cap is gone from pyproject dependencies"- assert not caps[0].specifier.contains("1.30.0"), (- f"mcp 1.30.0 satisfies {caps[0]}; IBKR OAuth discovery fails on it"- )- assert caps[0].specifier.contains("1.29.1"), (- f"{caps[0]} excludes the last working version"+ pins = [Requirement(entry) for entry in dependencies if Requirement(entry).name == "mcp"]+ assert pins, "the mcp requirement is gone from pyproject dependencies"+ assert not pins[0].specifier.contains("1.29.1"), (+ f"{pins[0]} admits mcp 1.29.1, which never reclaims HTTP sessions")+ assert pins[0].specifier.contains("1.30.0"), f"{pins[0]} excludes the fixed release"diff --git a/pyproject.toml b/pyproject.tomlindex 8a1acdd64..5b308de64 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -60,15 +60,17 @@ dependencies = [# session snapshot shape; tests construct it the 2.x way. Cap until the# adaptation lands."fastmcp>=2.14.0,<4.0.0",- # mcp 1.30.0 enforces RFC 8414 section 3.3 strictly: the `issuer` in an- # authorization server's metadata must equal the issuer used to build the- # well-known URL. IBKR's official MCP server advertises the authorization- # server https://api.ibkr.com/oauth2 while its metadata (verified live on- # 2026-09-08 at both well-known paths) says `"issuer": "https://api.ibkr.com"`,- # so discovery raises OAuthFlowError and the IBKR OAuth connection cannot be- # established at all. The cap is on the real broker path, not on the test- # that caught it — pulled in transitively through fastmcp.- "mcp<1.30",+ # 1.30.0 reclaims Streamable HTTP sessions (idle timeout 1800 s, at most+ # 10,000 sessions, ended sessions dropped), which `--transport http` needs:+ # CVE-2026-59951 / GHSA-84m7-p3x7-pcfv. It also enforces RFC 8414 section+ # 3.3 (metadata `issuer` must equal the advertised authorization server),+ # which is why 0.1.15-0.1.17 capped it below 1.30: IBKR advertised+ # https://api.ibkr.com/oauth2 with `"issuer": "https://api.ibkr.com"`.+ # Verified live 2026-10-21: IBKR's protected-resource metadata now names+ # https://api.ibkr.com, matching the issuer at all three well-known paths,+ # and Robinhood's issuer equals its advertised server. Pulled in+ # transitively through fastmcp, which allows mcp<2.0.+ "mcp>=1.30.0","ddgs>=6.0.0","jinja2>=3.1.0","matplotlib>=3.7.0",diff --git a/requirements-lock.txt b/requirements-lock.txtindex e998bcfe0..d8998fd9a 100644--- a/requirements-lock.txt+++ b/requirements-lock.txt@@ -2079,9 +2079,9 @@ matplotlib==3.11.2 \--hash=sha256:f2ac30cf5eb5dff1b584627ae0b0e1186551a4f69ae3c75073911da497a29170 \--hash=sha256:fea03cf56568cc1cba08b470be6a0559e71c3a5b688d54b7179bb35ba23d0821# via -r agent/requirements.txt-mcp==1.28.1 \- --hash=sha256:2726bca5e7193f61c5dde8b12500a6de2d9acf6d1a1c0be9e8c2e706437991df \- --hash=sha256:d51e36a5f5644faea4f85ea649bfffa6bc6c26770d42798ad6a3de3d2ba69683+mcp==1.30.0 \+ --hash=sha256:445414625fce5c295faa505bb11bacece661ab6f4028d57c935db57820b7a3e4 \+ --hash=sha256:666edb5009503e1047c9d60346a756f94b261f05cc2625f23d41c728ffc484d0# via fastmcp-slimmdurl==0.1.2 \--hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \