"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(trading): forward account_number to Robinhood remote MCP calls
Nareshb64d73ea3218
diff --git a/agent/src/trading/connectors/robinhood/mcp.py b/agent/src/trading/connectors/robinhood/mcp.pyindex 7143f8f62..fd061233e 100644--- a/agent/src/trading/connectors/robinhood/mcp.py+++ b/agent/src/trading/connectors/robinhood/mcp.py@@ -37,4 +37,13 @@ def remote_arguments(operation: str, arguments: dict[str, Any]) -> dict[str, Anysymbol = arguments.get("symbol")symbols = arguments.get("symbols")return {"symbols": symbols or ([symbol] if symbol else [])}+ if operation in ("account", "positions", "orders"):+ # Robinhood's get_portfolio / get_equity_positions / get_equity_orders+ # MCP tools require account_number. The generic trading service passes+ # the CLI/agent-supplied account code in under the "account" key; map+ # it to the field name Robinhood's schema actually expects.+ account_number = arguments.get("account_number") or arguments.get("account")+ if account_number:+ return {"account_number": account_number}+ return {}return {}diff --git a/agent/src/trading/service.py b/agent/src/trading/service.pyindex 3cc7ef873..6c8ecd580 100644--- a/agent/src/trading/service.py+++ b/agent/src/trading/service.py@@ -72,7 +72,7 @@ def get_account(profile_id: str | None = None, **overrides: Any) -> dict[str, Anif profile.transport == "broker_sdk":module = _sdk_module(profile.connector)return _with_profile(profile, module.get_account_snapshot(module.build_config(profile.config, overrides)))- return _call_remote(profile, "account", {})+ return _call_remote(profile, "account", _account_arg(overrides))def get_positions(profile_id: str | None = None, **overrides: Any) -> dict[str, Any]:@@ -85,7 +85,7 @@ def get_positions(profile_id: str | None = None, **overrides: Any) -> dict[str,if profile.transport == "broker_sdk":module = _sdk_module(profile.connector)return _with_profile(profile, module.get_positions(module.build_config(profile.config, overrides)))- return _call_remote(profile, "positions", {})+ return _call_remote(profile, "positions", _account_arg(overrides))def get_open_orders(@@ -111,7 +111,7 @@ def get_open_orders(module.build_config(profile.config, overrides), include_executions=include_executions),)- return _call_remote(profile, "orders", {})+ return _call_remote(profile, "orders", _account_arg(overrides))def get_quote(@@ -462,6 +462,18 @@ def _remote_status(profile: TradingProfile) -> dict[str, Any]:}+def _account_arg(overrides: dict[str, Any]) -> dict[str, Any]:+ """Build the arguments dict a remote MCP account/positions/orders call needs.++ The CLI ``--account`` flag and the agent-facing tools both surface as an+ ``account`` key in ``overrides``. Remote connectors (e.g. Robinhood) expect+ ``account_number`` on the wire; this normalizes that once here instead of+ duplicating the mapping at each call site.+ """+ account = overrides.get("account") or overrides.get("account_number")+ return {"account_number": account} if account else {}++def _call_remote(profile: TradingProfile, operation: str, arguments: dict[str, Any]) -> dict[str, Any]:"""Call a known read operation on a remote MCP connector profile."""from src.config.loader import load_agent_config@@ -520,10 +532,12 @@ def _call_remote(profile: TradingProfile, operation: str, arguments: dict[str, A}adapter = MCPServerAdapter(server_name, server)- return _with_profile(- profile,- adapter.call_tool(remote_name, _remote_arguments(profile.connector, operation, arguments)),- )+ call_result = adapter.call_tool(remote_name, _remote_arguments(profile.connector, operation, arguments))+ account_number = arguments.get("account_number")+ if account_number:+ call_result = dict(call_result)+ call_result.setdefault("account_number", account_number)+ return _with_profile(profile, call_result)def _remote_tool_name(connector: str, operation: str) -> str | None: