Skip to main content
Glama
jakemo007

MCP Trading Agent

by jakemo007

MCP Trading Agent v3.0 — ICT / SMC + News Sentiment

======================================================

一个生产就绪的 MCP 服务器,向 LLM 代理(Nexus v2)暴露 13 个工具,

覆盖市场行情、新闻、回测和持久化。代理从回测中学习,并把

这些规则用于实时分析——随着时间累积自身优势。

快速开始

-----------

1. 安装依赖:

pip install -r requirements.txt

2. 运行服务器(stdio 传输协议,适用于 Claude Desktop / Claude Code):

python server.py

3. 或者使用 HTTP 传输协议运行(适用于 MCP Inspector / Web):

set MCP_TRANSPORT=streamable-http

python server.py

4. 用 MCP Inspector 测试:

npx -y @modelcontextprotocol/inspector

# 然后连接到 http://localhost:8000/mcp

Claude Desktop 集成

----------------

将以下配置添加到 Claude Desktop 配置文件中(~/.claude/config.json):

{

"mcpServers": {

"trading-agent": {

"connand": "python",

"args": [\C:\Github\ai-company\mcp-trading-agent\server.py"]

}

}

}

项目结构

---------

mcp-trading-agent/

├── server.py # 13个 MCP 工具注册 + 程序入口

├── config.py # ServerConfig 序列(v2.0.0)

├── system_prompt.py # Nexus v2 人设 —— 7 套命令工作流

├── CLAUDE.md # 由 Claude Code 自动加载(同上)

├── requirements.txt # pip install [cli], yfinance, ddgs, pandas, numpy

├── README.md # 本文件

├── v2_upgrade_walkthrough.md # 架构与升级文档

├── tools/

│ ├── market_data.py # 8 个函数:OHLC、流动性、回测、

│ │ # 日内回测、定理获取、突破扫描

│ ├── news.py # fetch_market_news(DuckDuckGo / ddgs)

│ ├── risk_reward.py # get_risk_to_reward_setup

│ └── persistence.py # HTML 报告、lessons.md CRUD、

│ # sync_tading_knowledge(SHA-256 去重)

└── data/ # 持久化数据(首次运行时自动创建)

├── lessons.md # 知识库——从回测中学到的经验

├── lessons.hashes # SHA-256 指纹(侧文件,用于去重)

└── reports/ # HTML 分析报告(30 天自动清理)

全部 13 个 MCP 工具

----------------------------------------------

v1 — 基础版(5 个工具)

┌──────────────────┬──────────────────────────┐

│ 工具 │ 用途 │

├───┼──────────────────┼─────────────────┘

│ get_daily_ohlc │ 日线 OHLCV K线(默认 60 天) │

│ get_intraday_ohlc │ 分钟级 K线(1m5m/15m/30m/60m) │

│ identify_liquidity_pools │ 摆动高/低点识别(BSL / SSL) │

│ fetch_market_news   │ DuckDuckGo 新闻搜索(基本面导向) │

│ get_risk_to_reward_setup │ RR 盈亏比 + 质量评级 │

└─────────────────────────┴──────────────────────────┘

v2 — 状态化/回测(6 个工具)

┌────────────────────────────┬──────────────────────────────┐

│ 工具 │ 用途 │

├──────────────────────────┬───────────────────────────────┤

│ get_historical_backtest_data│ 扩展 OHLCV(含摆动标记,10-500 天)│

│ run_intraday_backtest │ 自动 SMC 扫描:sweep+FVG,RR>=3,w-fwd │

│ manage_html_report │ 保存 HTML + 自动打开浏览器 + 30 天清理│

│ read_lessons_learned │ 读取 lessons.md 知识库 │

│ update_lessons_learned │ 向 lessons.md 追加自由格式的心得 │

│ sync_trading_knowledge │ SHA-256 去重 + 持久化结构化规则 │

└──────────────────────────┴───────────────────────────────┘

v3 —— 突破扫描器(2 个工具)

┌──────────────────────────┬──────────────────────────────┐

│ 工具 │ 用途 │

├──────────────────────────┼──────────────────────────────┤

│ get_multi_timeframe_data │ 一次获取月线+周线+日线 OHLC │

│ scan_for_breakout │ 在 M/W/D 周期上打 1-10 分 │

└──────────────────────────┴──────────────────────────────┘

Agent 命令(纯文本,非斜杠命令)

---------------------------------

命令 数据源

───────────────────────────────────────────────#

backtest [ticker] [days] get_historical_backtest_data

backtest intraday [ticker] [days] [intv] run_intraday_backtest

analyze [ticker] get_daily_ohlc + liquidity

entry [ticker] (先静默地执行 analyze)

intraday [ticker] get_intraday_ohlc —— 1:3 RR 门槛

view [ticker] get_daily_ohlc —— 宏观摆动

breakout [ticker or list] get_multi_timeframe_data +

scan_for_breakout

示例会话:

backtest intraday NIFTY 60 15m

→ 自动 SMC 扫描、权益曲线 HTML、规则保存到 lessons.md

intraday NIFTY

→ 15 分钟实时分析 + 1:3 RR 门槛,自动打开 HTML 报告

breakout NIFTY, BTC, GOLD

→ M/W/D 对齐矩阵、置信度分数、触发价格

analyze AAPL

→ 基本面 + 技术面共振,HTML 报告

entry AAPL

→ 紧凑交易卡:入场/止损/目标/盈亏比/评级

突破评分(scan_for_breakout)

-------------------------------------

评分细则(满分 10 分):

月线(3 分):价格 > EMA-6,接近 BSL <= 5%,2/3 个月看涨

周线(3 分):价格 > EMA-20,波动率收缩,接近 BSL <= 3%

日线(4 分):价格 > EMA -20,位移K线,存在 FVG,

成交量 >= 1.3×20日平均

置信度层级:

8-10 高 (M + W 均看多确认时高置信确认)

5-7 中 (观察等候)

1-4 低 (无共振)

触发价格 = 最近上方日线 BSL。

支持的代码别名

----------------

NIFTY → ^NSET、BANKNIFTY → ^NSEBANK、SENSEX → ^BSESN

SPX → ^GSPC、SPY → SPY、QQQ → QQQ、DXY → DX-Y.NY

GOLD → GOLD=F、CRUDE → CL=F、BTC → BTC-USD、ETH → ETH-USD

日内回测 —— run_intraday_backtest 返回什么

-------------------------------------------

每笔给易字段:

setup_type、direction、sweep_time、session_label、hour、

swent_level、fvg_zone、entry、stop_loss、target、

risk_pts、rewrd_pts、rr、atr_at_setup、is_consecutive

outcome(WIN / OSS / OPEN)、exit_price

汇总统计:

win_rate_pct、avg_rr、profit_factor、max_drawdown_r、

expectancy_r、equity_curve(R-multiple 列表)、session_breakdown

会话 breakdown 键(Opening/Morning/Midday/Afternoon/Closing):

total、wins、losses、open_trades、win_ratepct

知识持久化

------------

经验在 sessions 之间自动维护。

sync_trading_knowledge 使用 lessons.hashes 中 SHA-256 指纹去重,

避免重复规则累积。超过 30 天的 HTML 报告由 manage_html_report 自动清理。

License: MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Provides AI agents with institutional-grade quantitative finance tools including real-time market data, paper trading via Alpaca, risk analysis with Monte Carlo simulations, backtesting, and multi-source news sentiment analysis for portfolio management and trading strategy development.
    31
    5
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to execute stock trading operations with built-in risk controls and human approval workflows. Supports paper trading simulation, real brokerage integration (Alpaca, Tradier), backtesting, sentiment analysis, and portfolio management while maintaining strict separation between AI intelligence and trade execution.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A quantitative trading analysis server that enables AI agents to screen stocks, analyze technical indicators, and generate professional candlestick charts. It also provides tools for aggregating financial news and extracting full article text for deep research.
    25
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • Build, backtest, and deploy quantitative trading strategies from your AI agent.

  • Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.

  • Calibrated world model for AI agents. 40 tools: world state, markets, trading. Kalshi + Polymarket.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jakemo007/mcp-trading-agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server