TradingAgents-MCP: A 15-Agent AI Framework for Real-Time Stock Analysis

9月3日 Published inAI Agent Tools

TradingAgents-MCP is a sophisticated multi-agent trading analysis system built on the Model Context Protocol (MCP). By utilizing MCP tools to ingest live market data, the framework coordinates fifteen specialized agents that collaborate to analyze stocks, debate investment hypotheses, and generate data-driven trading decisions.

The system executes its analytical tasks in parallel, covering seven critical dimensions simultaneously: company overview, market dynamics, investor sentiment, recent news, fundamental data, shareholder structure, and product lines. This concurrent design significantly reduces the time required to process complex market information.

A built-in debate mechanism is used to refine the final output. Bull and bear researchers argue the merits of an investment case, while three risk analysts—representing aggressive, conservative, and neutral perspectives—debate potential downsides. Users can customize the number of debate rounds, allowing the system to deliver nuanced, layered recommendations.

The Streamlit-based frontend provides granular control over the workflow. Users can toggle specific agents on or off and adjust debate depth in real time. Because the system handles natural language queries, there is no need to manually specify markets or dates; it automatically pulls current data for US equities, Chinese A-shares, and Hong Kong listings.

Key Features:

  • Multi-Agent Team: Fifteen specialized roles—including analysts, researchers, managers, and risk experts—each manage a specific segment of the analysis.
  • Parallel Processing: Six analysts operate simultaneously to minimize total runtime.
  • MCP Integration: External data sources provide a continuous feed of real-time market information.
  • Seven-Angle Analysis: Comprehensive coverage includes company snapshots, market trends, sentiment signals, breaking news, financial health, ownership maps, and product outlooks.
  • Structured Debate: Bull and bear researchers exchange arguments while three risk profiles contest exposure levels. User-defined round counts dictate the depth of the discussion.
  • Agent Control: The interface allows users to disable specific agents to streamline the process or focus on specific data points.
  • Multi-Market Support: Full compatibility with US stocks, Chinese A-shares, and Hong Kong equities.
  • Natural Language Queries: Simple prompts like "Analyze Tesla" are sufficient to trigger a full report.
  • Real-Time Decisions: Final outputs are synthesized from fresh data and collaborative agent reasoning.
  • Web Interface: A Streamlit UI allows users to monitor the analysis as it unfolds and browse historical reports.

Agent Roster

┌─────────────────────────────────────────────────────────┐
│                    TradingAgents-MCPmode                │
├─────────────────────────────────────────────────────────┤
│  📊 Analysts (Parallel Execution)                       │
│  ├── CompanyOverviewAnalyst                             │
│  ├── MarketAnalyst                                      │
│  ├── SentimentAnalyst                                   │
│  ├── NewsAnalyst                                        │
│  ├── FundamentalsAnalyst                                │
│  ├── ShareholderAnalyst                                 │
│  └── ProductAnalyst                                     │
├─────────────────────────────────────────────────────────┤
│  🔬 Researchers                                         │
│  ├── BullResearcher                                     │
│  └── BearResearcher                                     │
├─────────────────────────────────────────────────────────┤
│  👔 Managers                                            │
│  ├── ResearchManager                                    │
│  └── Trader                                             │
├─────────────────────────────────────────────────────────┤
│  ⚠️ Risk Management                                      │
│  ├── AggressiveRiskAnalyst                              │
│  ├── SafeRiskAnalyst                                    │
│  ├── NeutralRiskAnalyst                                 │
│  └── RiskManager                                        │
└─────────────────────────────────────────────────────────┘

Five-Stage Workflow

1. User Input
The user enters a natural language query, such as "Analyze Apple stock."

2. Company Overview
The CompanyOverviewAnalyst retrieves foundational details, including the company name, ticker, exchange, and sector, to produce an initial summary report.

3. Parallel Analyst Phase
Six analysts activate simultaneously. Each evaluates the user query and the initial summary to produce a specialized report. This parallel execution ensures you receive six distinct perspectives in the time it would take to generate one.

4. Researcher Debate and Management Decision
The BullResearcher constructs a positive investment case by reviewing all seven previous reports. It generates a series of arguments and a debate history. The BearResearcher then responds, analyzing the same data and the bull's arguments to provide counterpoints. This debate loop can be repeated for increased depth.

Following the debate, the ResearchManager synthesizes the findings into an investment plan, which the Trader then refines into a specific trading blueprint.

5. Risk Management Phase
The AggressiveRiskAnalyst initiates the review of all prior outputs, establishing a risk perspective and a debate log. The SafeRiskAnalyst follows by adding a conservative interpretation, and the NeutralRiskAnalyst completes the cycle. Finally, the RiskManager evaluates the entire debate log to issue the final trading decision.

Installation

Requirements: Python 3.8 or higher. Compatible with Windows, macOS, and Linux.

Step 1: Clone the Repository

git clone https://github.com/guangxiangdebizi/TradingAgents-MCPmode.git
cd TradingAgents-MCPmode

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Configure the Environment

cp env.example .env

Edit the .env file to include your API keys and set your preferred workflow parameters.

Step 4: Configure MCP Tools

Edit mcp_config.json to point to your MCP server. This step is essential for connecting the system to live market data.

Usage

Web Interface (Recommended)

streamlit run web_app.py

Access the UI at http://localhost:8501. The interface is organized into several sections:

  • Home: System overview and quick navigation links.
  • System Config: Modify .env and MCP settings directly from the browser.
  • Live Analysis: Enter queries and monitor the analysis progress in real time.
  • Agent Control: Enable or disable specific agents organized by team; disabled agents will be skipped during execution.
  • Debate Settings: Use sliders to set the number of bull-bear and risk debate rounds. The UI will estimate the expected speech count based on these settings.
  • Agent Pages: Review the detailed output generated by each individual agent.
  • History: Manage previous sessions and export reports to Markdown, PDF, or DOCX formats.

Command Line

Single-shot analysis:

python main.py -c "Analyze Apple stock"

Interactive mode:

python main.py

Follow the prompts to enter queries like "Analyze Tesla" or "Analyze 600036 China Merchants Bank."

Example Run: Analyzing Tesla

  1. The CompanyOverviewAnalyst identifies Tesla Inc. (TSLA) on the NASDAQ within the EV sector.
  2. Six analysts fire in parallel to generate specialized reports based on this profile.
  3. The BullResearcher reviews the reports to build a bullish thesis for the stock.
  4. The RiskManager evaluates the cumulative findings and debates to issue a final risk-adjusted decision.

Configuration Details

.env File

Section Key Variables
LLM Config OPENAI_API_KEY, OPENAI_BASE_URL, MODEL_NAME
Workflow MAX_DEBATE_ROUNDS, MAX_RISK_DEBATE_ROUNDS, DEBUG_MODE, VERBOSE_LOGGING
Agent MCP Permissions Toggle MCP access per agent. Analysts typically require live data, while researchers and managers may not.
Concurrency MAX_CONCURRENT_ANALYSIS sets the limit for parallel analyst tasks.

For initial testing, start with a single debate round and increase the count for more exhaustive analysis.

mcp_config.json File

Two formats are supported.

Standard Format (HTTP Streaming):

{
  "servers": {
    "finance-mcp": {
      "transport": "streamable_http",
      "url": "http://106.14.205.176:8080/mcp",
      "headers": {
        "X-Tushare-Token": "Your-Tushare-APIKEY-Here"
      }
    }
  }
}

Legacy Format (SSE):

{
  "servers": {
    "finance-mcp": {
      "transport": "sse",
      "url": "http://106.14.205.176:3101/sse"
    }
  }
}

Ensure the Tushare token placeholder is replaced with a valid key. The MCP client must be restarted or hot-reloaded after making changes.

TradingAgents-MCP effectively places a professional trading desk within your terminal, combining parallel analysis, structured debate, and real-time data under an accessible web UI. It is open-source and ready for immediate deployment.