mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Resolves issue where MCP trade tools couldn't access SIGNATURE and TODAY_DATE during concurrent API simulations, causing "SIGNATURE environment variable is not set" errors. Problem: - MCP services run as separate HTTP processes - Multiple simulations execute concurrently via ThreadPoolExecutor - Environment variables from executor process not accessible to MCP services Solution: - Add ContextInjector that implements ToolCallInterceptor - Automatically injects signature and today_date into buy/sell tool calls - Trade tools accept optional parameters, falling back to config/env - BaseAgent creates interceptor and updates today_date per session Changes: - agent/context_injector.py: New interceptor for context injection - agent/base_agent/base_agent.py: Create and use ContextInjector - agent_tools/tool_trade.py: Add optional signature/today_date parameters Benefits: - Supports concurrent multi-model simulations - Maintains backward compatibility with CLI mode - AI model unaware of injected parameters