market-mcp

market-mcp

An MCP server providing real-time market data, technical analysis, prediction market odds, and strategy backtesting for crypto, equities, and prediction markets.

Category
访问服务器

README

market-mcp

An MCP server that gives an AI assistant real market data, technical analysis, prediction-market odds and an honest strategy backtester — plus a scheduled scanner that feeds a live dashboard and Telegram alerts.

Covers four things in one server:

Domain Source No key needed
Crypto Binance public spot API ✅
Global equities / ETFs / indices / FX Yahoo Finance ✅
Indonesian equities (IDX) Yahoo Finance .JK + bundled universe ✅
Prediction markets Polymarket Gamma + CLOB ✅

No API keys, no accounts, no paid tiers. Runtime dependencies are mcp and httpx — indicators and the backtester are pure Python, so there is no pandas/numpy wheel to fight with.


Install

git clone https://github.com/kumaraprayoga68-sketch/market-mcp
cd market-mcp
python -m venv .venv
.venv/Scripts/activate        # Linux/macOS: source .venv/bin/activate
pip install -e .

Then point your MCP client at it. For Claude Desktop, add this to claude_desktop_config.json (use the absolute path to the venv's Python):

{
  "mcpServers": {
    "market": {
      "command": "C:\\path\\to\\market-mcp\\.venv\\Scripts\\python.exe",
      "args": ["-m", "market_mcp.server"]
    }
  }
}

For an HTTP transport instead of stdio:

market-mcp --transport streamable-http --port 8000

The 20 tools

Prices

  • get_price — price, daily change, day range, 52-week position
  • get_prices — many symbols at once; unresolvable ones are reported, not fatal
  • search_symbol — company name → ticker
  • market_snapshot — US/Asia indices, VIX, crypto, gold, oil, USD/IDR

Analysis

  • technical_analysis — RSI, MACD, Bollinger, EMA 20/50/200, ATR, ADX, Supertrend, Stochastic + a composite rating
  • multi_timeframe_analysis — weekly → hourly, and whether they agree
  • candlestick_patterns — 13 patterns, each tagged with the trend it appeared in

Screeners

  • crypto_screener — Binance spot by volume and 24h change
  • crypto_top_movers — gainers/losers with a liquidity floor
  • stock_screener — scan the bundled IDX (277) or US (117) universe
  • technical_scan — scan for a setup (oversold, uptrend, squeeze, volume spike…), not just a price move
  • list_universes

Prediction markets

  • prediction_markets — most active markets
  • prediction_search — keyword search, question matches outrank description matches
  • prediction_market_detail — outcomes, prices, token ids
  • prediction_price_history — how the market's probability has moved

Backtesting

  • list_strategies — 9 strategies and their parameters
  • backtest_strategy — one strategy, one instrument, with costs
  • compare_strategies — rank all 9 against buy-and-hold
  • walk_forward_backtest — out-of-sample validation with an overfitting verdict

Scheduled scans, alerts and dashboard

Beyond the MCP server, the repo runs itself on a schedule:

GitHub Actions (every 4h)
  └─ scripts/run_scan.py
       ├─ snapshots/latest.json  ──►  Vercel dashboard (reads it straight from GitHub)
       └─ Telegram alert          ──►  only for setups that are new since the last run

snapshots/latest.json is committed back to the repo, so the dashboard picks up fresh data without a redeploy: the cron owns the data, Vercel only renders it.

Telegram alerts

Alerts fire only on findings absent from the previous snapshot. A scan that runs every four hours will keep matching the same oversold ticker for days, and an alert that fires every run is an alert you stop reading.

Set these in the repo under Settings → Secrets and variables → Actions:

Secret Where to get it
TELEGRAM_BOT_TOKEN @BotFather → your bot → API token
TELEGRAM_CHAT_ID message your bot, then open https://api.telegram.org/bot<TOKEN>/getUpdates and read result[].message.chat.id

Without them the job still runs and simply skips the alert. Never commit the token — it is a bearer credential for the whole bot.

Running the scan by hand

python scripts/run_scan.py --quick --no-alert

--quick shrinks the universes and skips backtests; --no-alert never sends Telegram. A full run takes a few minutes and produces roughly 80 KB of JSON.

Every section is independently guarded, so an outage at one venue degrades the snapshot rather than losing the run. Failures land in snapshot.errors and the dashboard shows them rather than pretending the data is complete.

Dashboard

Live: market-mcp-dashboard.vercel.app

dashboard/ is a Next.js app with no UI dependencies beyond React.

cd dashboard && npm install && npm run dev

It fetches snapshots/latest.json over HTTP with a 5-minute revalidate, so new scan data appears on its own. Only code changes need a redeploy:

cd dashboard && vercel deploy --prod

To get automatic deploys on every code push, connect the repository under Project Settings → Git and set Root Directory to dashboard. That last part matters and cannot be set from the CLI: without it Vercel builds from the repository root, finds no package.json, and the build fails.

Point the dashboard at a different data source with the SNAPSHOT_URL environment variable.


Two things this server is careful about

The backtester cannot see the future

A strategy sees bar i only after it closes, so the position it asks for is held during bar i+1. This is enforced by the engine, not by convention, and it is asserted in the test suite: an "oracle" strategy that reads the next bar returns ~5600% on the same data where the identical rule, lagged one bar, returns ~19%. If look-ahead ever leaked in, both numbers would be huge.

Costs are charged on position changes, so a long→short flip pays twice. Every result reports buy_and_hold_return_pct beside it, because beating a flat market is not an edge.

walk_forward_backtest is the tool that matters. It re-optimises parameters on data up to each fold and scores the fold that follows, then compares in-sample against out-of-sample and returns a verdict — robust, acceptable, fragile, likely_overfitted or overfitted. Most strategies that look great in a single backtest come back overfitted, which is the point.

The rating explains itself, and knows when oscillators lie

technical_analysis returns a composite score, but also every individual vote that produced it, so the reasoning can be inspected rather than trusted.

RSI pins near 100 for the whole of a real rally. A naive vote counter reads that as bearish, lets it cancel the trend indicators, and rates an unmistakable uptrend "neutral". When ADX shows a strong trend, this server drops oscillator votes that oppose the trend and says so in the vote's reason. ADX itself never votes on direction — it only scales confidence.


Output shape

Every tool returns the same envelope:

{ "ok": true, "data": { ... }, "error": null }
{ "ok": false, "data": null,
  "error": { "code": "rate_limited", "message": "...", "retryable": true } }

retryable distinguishes "the upstream is having a moment" from "you asked for something that does not exist", so a client knows whether trying again is worthwhile. Codes: bad_input, not_found, upstream_error, rate_limited, timeout, internal.


Layout

src/market_mcp/
├── server.py         MCP entry point
├── core/             error envelope, TTL cache, shared HTTP with retry
├── providers/        yahoo, binance, idx, polymarket — plain async functions
├── indicators.py     pure-Python TA
├── patterns.py       candlestick detection
├── analysis.py       indicator snapshot + composite rating
├── scanning.py       signal matching, shared by the MCP tool and the cron job
├── alerting.py       snapshot diffing and Telegram formatting
├── market_data.py    one candle loader across all venues
├── backtest/         engine, strategies, walk-forward
└── tools/            MCP tool definitions
scripts/run_scan.py   the scheduled job
dashboard/            Next.js dashboard for Vercel
snapshots/            latest.json + trimmed history, written by the cron
data/                 idx.txt (277), us.txt (117)
tests/                130 tests, no network required

Providers know nothing about MCP; tools know nothing about HTTP. Adding a venue means writing one provider module that returns the shared candle shape.


Tests

pytest

130 tests, all offline — they cover indicator known-answer cases, engine invariants (look-ahead, cost accounting, drawdown), symbol normalisation, the error envelope, cache de-duplication, alert de-duplication, and server wiring. CI runs them on Python 3.10, 3.12 and 3.14, plus a smoke job that starts the server and checks it serves all 20 tools.


Adding a strategy

Write a function that maps candles to positions (+1 long, 0 flat, -1 short), then register it:

def my_strategy(candles, period: int = 14) -> list[int]:
    r = ta.rsi(series(candles, "close"), period)
    return [0 if v is None else (1 if v < 25 else 0) for v in r]

Strategy(
    name="my_strategy",
    description="...",
    fn=my_strategy,
    defaults={"period": 14},
    grid={"period": [7, 14, 21]},   # searched by walk-forward
)

Warm-up bars must be 0 — a strategy is never allowed to act on an undefined indicator. test_every_strategy_produces_valid_signals enforces the contract for anything in the registry.


Limits

  • Yahoo caps intraday history (7 days of 1-minute bars, 60 days of sub-hourly).
  • Polymarket has no server-side text search, so prediction_search scans the most active markets rather than every market ever created.
  • IDX has no free bulk screener, so stock_screener quotes a curated universe file rather than the whole exchange.
  • Backtests model costs as flat fee + slippage. Real fills, funding, borrow and liquidity are not modelled.

Not affiliated with TradingView, Binance, Yahoo or Polymarket. Information only — not financial advice.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选