tradingagents-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@tradingagents-mcp Run a deep analysis on Bitcoin (BTC) and share the research report."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TradingAgents MCP Server
将 TradingAgents 多智能体金融研究引擎,以标准 MCP 协议暴露给任意 LLM Host(Codex、Claude Desktop、Cursor 等)的薄适配层。
重要边界:本服务器只产出研究报告与非执行性决策。它不连接任何券商账户,不提交、修改或取消订单。研究结果仅供参考,不构成投资建议。
为什么需要它?
TradingAgents 本身是一个 Python 框架,需要通过编写代码或命令行方式驱动,LLM Host 无法直接调用它。TradingAgents MCP Server 解决了三个问题:
零代码接入:LLM Host 通过 MCP 协议即可启动研究任务、查询进度、读取完整报告,无需理解 TradingAgents 内部结构。
异步任务模型:完整金融研究耗时较长(数分钟到数十分钟),本服务器将每次分析建模为异步任务,不阻塞 MCP 调用。
开箱即用的研究管线:内置任务队列、SQLite 持久化、幂等控制、取消与确认式删除,服务重启后任务状态不会丢失。
Related MCP server: financial-research-agent
特性亮点
7 个 MCP 工具 + 1 个 MCP 资源:完整覆盖能力查询、任务启动、状态轮询、结果读取、任务列表、取消与删除。
异步任务状态机:
queued → running → succeeded / failed / cancelled,支持长时间研究任务。幂等创建:
idempotency_key保证同一分析请求重复提交只创建一次任务。持久化存储:任务元数据存于 SQLite,报告与中间产物存于磁盘,服务重启后可恢复。
确认式删除:成果永不自动清理;删除必须传入完全匹配的
run_id二次确认。凭证隔离:LLM API Key 等敏感配置只存在于服务端环境变量中,MCP 协议层不接触凭证。
架构概览
flowchart LR
A[LLM Host<br/>Codex / Claude Desktop] -->|MCP stdio| B[MCP Server<br/>tradingagents_mcp.server]
B --> C[(SQLite<br/>tasks.db)]
B --> D[TaskRuntime<br/>单 worker 串行队列]
D -->|子进程隔离| E[worker.py]
E --> F[TradingAgentsGraph<br/>propagate]
F --> G[final_state.json<br/>complete_report.md]
G --> B
B -->|MCP Resource| AMCP Server:处理工具与资源请求,维护任务队列。
SQLite:存储任务元数据与幂等映射,支持原子状态迁移。
TaskRuntime:单 worker 串行执行任务,子进程隔离保证上游异常不影响服务器进程。
worker.py:子进程内运行
TradingAgentsGraph.propagate(),产出final_state.json与complete_report.md。
快速开始
前置要求
Python 3.10+
已安装 TradingAgents:
pip install tradingagents(或从源码安装)已配置 LLM API Key(见下文「LLM 配置」)
安装
cd tradingagents-mcp
pip install -e .启动
# 方式一:直接启动
python -m tradingagents_mcp.server
# 方式二:使用启动脚本(自动探测 TradingAgents 源码位置)
./start_server.shLLM 配置
LLM 提供商配置沿用 TradingAgents 自身的环境变量,由上游 TradingAgentsGraph 读取。MCP 适配器不接触这些凭证。
变量 | 说明 | 示例 |
| LLM 提供商 |
|
| 深度思考模型名 |
|
| 快速思考模型名 |
|
| API 地址 |
|
| API Key(也可直接用 |
|
| 单次调用最大 token 数 |
|
| 采样温度 |
|
服务端配置环境变量:
变量 | 说明 | 默认值 |
| 数据目录(数据库、任务工作区) |
|
| 最大排队任务数 |
|
| 单任务超时(秒) |
|
| 上游图类导入路径(自定义安装布局时覆盖) |
|
提示:所有凭证均以环境变量方式注入服务端进程,MCP 工具参数中永远不会出现 API Key。
配置到 MCP Host
Codex / Claude Desktop
{
"mcpServers": {
"tradingagents": {
"command": "python",
"args": ["-m", "tradingagents_mcp.server"]
}
}
}工具与资源
工具 | 说明 | 只读 | 幂等 |
| 查询服务器能力与配置(不含凭证) | ✅ | ✅ |
| 启动分析任务 | ❌ | ✅( |
| 查询任务状态与时间戳 | ✅ | ✅ |
| 获取结果摘要(评级、置信度、报告 URI) | ✅ | ✅ |
| 分页列出任务,支持状态过滤 | ✅ | ✅ |
| 取消 queued / running 任务 | ❌ | ✅ |
| 永久删除任务(需 | ❌ | ✅ |
MCP 资源:
tradingagents://analyses/{run_id}/report— 完整的 Markdown 研究报告(仅succeeded任务可访问)
支持的资产与研究参数
参数 | 取值 | 说明 |
|
| 股票代码或加密货币符号 |
|
| 默认 |
|
| 分析日期,不可为未来日期 |
|
| 默认 |
|
| 默认 |
| 分析师类型列表 | 默认按 |
| 可选字符串 | 相同参数 + 相同 key 返回已有任务 |
使用示例
1. 查询能力
调用 get_capabilities返回支持的资产类型、研究深度、输出语言、队列限制等。
2. 启动分析
调用 start_analysis,参数:
- symbol: "AAPL"
- analysis_date: "2025-01-15"
- asset_type: "stock"
- depth: "shallow"
- language: "English"返回 run_id,例如 run_a1b2c3d4e5f67890。
3. 轮询状态
调用 get_analysis_status,参数:
- run_id: "run_a1b2c3d4e5f67890"任务状态流转:queued → running → succeeded / failed / cancelled。轮询直到终态。
4. 读取结果摘要
调用 get_analysis_result,参数:
- run_id: "run_a1b2c3d4e5f67890"返回评级、置信度与报告资源 URI。
5. 阅读完整报告
通过 MCP 资源读取:
tradingagents://analyses/run_a1b2c3d4e5f67890/report数据存储
所有数据存储在 TRADINGAGENTS_MCP_DATA_DIR(默认 ~/.tradingagents-mcp/):
~/.tradingagents-mcp/
├── tasks.db # SQLite 任务元数据数据库
└── runs/
├── run_abc123/ # 每个任务的独立工作区
│ ├── request.json
│ ├── final_state.json
│ ├── complete_report.md
│ ├── SUCCESS.json 或 error.json
│ └── worker_stderr.log
└── ...任务成果永不自动清理,只有显式调用
delete_analysis才会删除。服务重启后,中断的
running任务会自动重新入队。
安全与边界
不做交易:不连接券商,不提交、修改或取消任何订单。
凭证隔离:API Key 只存在于服务端环境变量,绝不通过 MCP 协议传输。
只读查询为主:除
start_analysis、cancel_analysis、delete_analysis外,其余工具均为只读。数据默认本地:报告与数据库存储在本地数据目录,不依赖外部 SaaS。
FAQ
Q:为什么不直接在 MCP Host 里调用 TradingAgents? A:TradingAgents 是 Python 框架,LLM Host 无法原生执行任意 Python。MCP 适配器将研究能力封装为标准化工具,且提供队列、持久化、幂等、取消等工程能力。
Q:如何配置 API Key?
A:在启动 MCP 服务器的进程环境中设置 TRADINGAGENTS_API_KEY(或 OPENAI_API_KEY / DEEPSEEK_API_KEY)等变量。服务器不会通过 MCP 工具暴露或接收凭证。
Q:研究报告可以删除吗?
A:可以,但必须显式调用 delete_analysis 并传入完全匹配的 run_id。成果不会自动清理,避免误删。
Q:分析结果会过期或被覆盖吗? A:不会。每个任务有独立工作区与持久化存储,幂等键保证同一请求只创建一次任务。
开发与测试
pip install pytest pytest-asyncio
pytest tests/使用 MCP Inspector 交互式调试:
npx @modelcontextprotocol/inspector python -m tradingagents_mcp.server许可证
MIT
Available Tools
7 toolscancel_analysisADestructiveIdempotent
Cancel a queued or running analysis task.
Cancellation stops the task and puts it in the 'cancelled' terminal state. The task and its partial results remain available for deletion. Cancellation of a succeeded or failed task has no effect.
Args: run_id: Task identifier to cancel.
Inputs: run_id (required). Returns: result
delete_analysisADestructiveIdempotent
Permanently delete an analysis task and all its data.
Per ADR-0009: tasks are never auto-cleaned. You must explicitly delete them with this tool. The confirm_run_id parameter must exactly match the task ID you want to delete — this prevents accidental deletion.
Only terminal tasks (succeeded, failed, cancelled) can be deleted. Deletion removes the task record, the research report, all logs, and the idempotency mapping. This action is irreversible.
Args: confirm_run_id: Must exactly match the run_id to confirm deletion.
Inputs: confirm_run_id (required). Returns: result
get_analysis_resultARead-onlyIdempotent
Get the result summary of a completed analysis task.
Only returns the structured summary with rating and resource reference. The full markdown report is accessed through the MCP resource URI returned in the result.
Args: run_id: Task identifier for a completed analysis.
Inputs: run_id (required). Returns: result
get_analysis_statusARead-onlyIdempotent
Get the current status of an analysis task.
Returns task metadata including status (queued, running, succeeded, failed, cancelled) and timestamps. Use this to poll for completion.
Args: run_id: Task identifier returned by start_analysis.
Inputs: run_id (required). Returns: result
get_capabilitiesARead-onlyIdempotent
Return the capabilities and configuration of this TradingAgents MCP server.
Describes what analyses are supported, default parameters, and server limits. All configuration listed here is non-sensitive — no credentials or API keys.
Inputs: no named parameters. Returns: result
list_analysesARead-onlyIdempotent
List analysis tasks with pagination.
Args: status: Optional filter by status (queued, running, succeeded, failed, cancelled). cursor: Pagination cursor from a previous list call. limit: Maximum number of tasks to return (default 20, max 100).
Inputs: limit, cursor, status. Returns: result
start_analysisAIdempotent
Start a new financial research analysis for a given symbol.
Creates an asynchronous analysis task. Use get_analysis_status to check progress and get_analysis_result to retrieve the final summary once the task succeeds. The full report is available as an MCP resource.
Args: symbol: Stock ticker or crypto symbol (e.g. 'AAPL', '600519.SH', 'BTC'). analysis_date: Date to analyze as YYYY-MM-DD. Must not be in the future. Defaults to today. asset_type: 'stock' or 'crypto'. Auto-detected if omitted. depth: 'shallow' (default, faster) or 'deep' (more thorough). language: Output language: 'English' (default) or '中文'. idempotency_key: Optional stable key. Same key + same params returns existing task.
Inputs: symbol (required), depth, language, asset_type, +2 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a distinct role in the analysis lifecycle: capabilities introspection, starting, checking status, retrieving results, listing, canceling, and deleting. There is no overlap or ambiguity between them.
All tool names follow a consistent verb_noun pattern (get_capabilities, start_analysis, get_analysis_status, etc.). The naming clearly reflects the action and resource, making the API predictable.
Seven tools is a well-scoped set for a task-management server. Each tool is necessary for the full lifecycle and no redundant tools exist.
The tool surface covers the complete analysis workflow: initiation, progress tracking, result retrieval, listing, cancellation, and deletion. Includes capabilities discovery and proper cleanup handling, with no obvious missing operations.
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that provides AI agents with financial tools including real-time quotes, backtesting, technical analysis, and multi-exchange data via a simple CLI interface.2MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes stock research tools (fundamentals, news, technicals, analyst ratings) to AI clients, enabling autonomous generation of structured investment briefs.-
- AlicenseAqualityCmaintenanceAn MCP server exposing a registry of paper-backed quantitative trading methods plus a deterministic, no-LLM decision helper for reproducible trading research.1371 PyPIMIT
- AlicenseAqualityDmaintenanceAn MCP server that exposes trading analytics — technical indicators, portfolio state, risk metrics, and backtest results — as tools an LLM agent can call.5MIT