Skip to main content
Glama
tradingview-mcp

tradingview-mcp

by harshil1502

tradingview-mcp

tradingview-mcp/  v0.1   ──────────────────────────────────────────────────

Claude Code(またはMCP互換クライアント)から、ローカルで実行中のTradingView Desktopアプリケーションを操作(チャート状態の読み取り、シンボルや時間足の変更、OHLCVバーの取得、スクリーンショットの撮影)するための、シンプルで型安全なMCPサーバーです。

[!IMPORTANT] 本プロジェクトはTradingView Inc.と提携、推奨、または関連するものではありません。 これは、Slack、VS Code、Discordなど、あらゆるElectronアプリに組み込まれている標準のデバッグインターフェースであるChrome DevTools Protocolを介して、ローカルで実行中のTradingView Desktopアプリケーションと対話するための個人用ブリッジです。

[!IMPORTANT] 有効なTradingViewサブスクリプションが必要です。 本ツールは、TradingViewのペイウォールやアクセス制御を回避、スクレイピング、または迂回するものではありません。すべては、お客様がすでにログインし、料金を支払っているTradingView Desktopインスタンスに対して、お客様のPC上で実行されます。

[!NOTE] すべての処理はローカルで行われます。 本ツールによってTradingViewのデータが送信、保存、または再配布されることはありません。チャートも、データも、すべてお客様のPC内に留まります。

[!CAUTION] TradingViewの内部ページAPIは非公開です。Desktopのリリースごとに変更される可能性があります。安定性を求める場合はTradingView Desktopのバージョンを固定し、アップグレード前にバージョン互換性の注記を確認してください。


機能

TradingView Desktopのチャートを、適切に定義された一連のMCPツールでラップします。ツールはZodスキーマでエンドツーエンドの型定義が行われており、境界で検証され、問題が発生した際には有用なエラーメッセージを表示します。

                  ┌───────────────┐
                  │ Claude Code   │
                  │ (or any MCP   │
                  │  client)      │
                  └───────┬───────┘
                          │ stdio (MCP)
                          ▼
                  ┌───────────────┐
                  │tradingview-mcp│
                  └───────┬───────┘
                          │ Chrome DevTools Protocol
                          ▼
                  ┌───────────────┐
                  │ TradingView   │
                  │ Desktop       │
                  │ (--remote-    │
                  │  debugging-   │
                  │  port=9222)   │
                  └───────────────┘

Related MCP server: TradingView MCP Jackson

なぜ別のTradingView統合ツールなのか?

既存のTradingView自動化プロジェクトは存在しますが、本プロジェクトは意図的にスコープを絞っています。

  • 78個ではなく12個のツール。 すべてのツールが文書化され、型定義され、テストされています。

  • 厳格なTypeScript。 any型や暗黙の戻り値は使用せず、noUncheckedIndexedAccessを有効にしています。

  • 1ファイル1責務。 接続、ページ、ツール、サーバーが別々のレイヤーになっており、バージョンによる変更が発生しても1箇所を修正するだけで済みます。

  • 型付きエラー。 ConnectionError、ToolExecutionError、ChartStateErrorなど、対処可能なメッセージを伴うエラーを定義しています。

  • tradingview-mcp doctor。 セットアップの何が問題かを正確に診断するコマンドです。

午後の一時で読み切れるほど小さく予測可能なツールを求めているなら、これを使ってください。TradingViewのあらゆる機能を網羅したい場合は、他の多機能な代替ツールを使用してください。


インストール

Node.js 20以上が必要です。

npm install -g tradingview-mcp
# or, in a project:
npm install tradingview-mcp

開発用:

git clone https://github.com/harshil1502/tradingview-mcp.git
cd tradingview-mcp
npm install
npm run build

セットアップ — 3つのステップ

1. 実行中のTradingView Desktopをすべて終了する

そうしないと、デバッグポートを有効にできません。

2. デバッグポートを有効にしてTradingView Desktopを起動する

macOS:

open -a "TradingView" --args --remote-debugging-port=9222

Windows:

& "C:\Users\<you>\AppData\Local\Programs\TradingView\TradingView.exe" --remote-debugging-port=9222

Linux:

tradingview --remote-debugging-port=9222

[!NOTE] --remote-debugging-portフラグは標準的なChromiumデバッグフラグです。これはオプトインであり、デフォルトでは無効になっています。明示的に指定しない限り、何も起こりません。

3. 接続を確認する

tradingview-mcp doctor

すべてが正しく設定されていれば、以下のような表示が出ます:

tradingview-mcp · doctor
─────────────────────────────────────────────
[ok]  CDP endpoint reachable on localhost:9222
[ok]  TradingView page found (NASDAQ:AAPL · 1h)
[ok]  tvWidget detected — chart state readable
─────────────────────────────────────────────
ready.

Claude Codeでの使用

Claude CodeのMCP設定(~/.claude/mcp.jsonまたはプロジェクトの.mcp.json)に以下を追加します:

{
  "mcpServers": {
    "tradingview": {
      "command": "tradingview-mcp",
      "env": {
        "TV_MCP_PORT": "9222"
      }
    }
  }
}

Claude Codeを再起動すると、以下のツールが利用可能になります。


ツール

ツール

説明

chart_get_state

現在のシンボル、時間足、表示中のインジケーター、最終価格を読み取る

chart_set_symbol

アクティブなシンボルを変更する (例: NASDAQ:AAPL, NSE:RELIANCE)

chart_set_timeframe

時間足(解像度)を変更する (1m, 5m, 1h, 1dなど)

chart_get_ohlcv

アクティブなチャートから最新のOHLCVバーを最大5,000件取得する

今後さらにツールを追加予定です。docs/roadmap.mdを参照してください。

セッション例

You:    What's the chart showing?
Claude: [calls chart_get_state]
        Showing NASDAQ:AAPL on 1h timeframe with EMA20, EMA50.
        Last price 187.42.

You:    Switch to BTCUSDT 4h and pull the last 200 bars.
Claude: [calls chart_set_symbol, chart_set_timeframe, chart_get_ohlcv]
        Done. Range: 187 days. Open at start: 62,440.
        Close at end: 67,830. +8.6%.

設定

環境変数

デフォルト

説明

TV_MCP_HOST

localhost

CDPホスト

TV_MCP_PORT

9222

CDPデバッグポート

TV_MCP_TARGET

(自動検出)

明示的なCDPターゲットID — 複数のTradingViewウィンドウを開いている場合にのみ必要


開発

npm install
npm run build         # tsc to dist/
npm run dev           # tsc --watch
npm test              # vitest run
npm run test:coverage # with v8 coverage report
npm run typecheck     # tsc --noEmit

コードベースは4つのレイヤーで構成されています:

src/
├── index.ts              entry — reads env, starts stdio server
├── server.ts             MCP server, tool registration, request handlers
├── errors.ts             typed error classes
├── types.ts              shared types + Zod schemas
├── connection/
│   ├── cdp.ts            CDP client wrapper (chrome-remote-interface)
│   └── tradingview.ts    TradingView-page interactions (all evaluated JS lives here)
└── tools/
    ├── index.ts          tool registry
    └── chart.ts          chart_* tools

ツールを追加するには:

  1. src/tools/配下に新しいファイルを作成する(または既存のファイルを拡張する)。

  2. <name>Inputおよび<name>OutputのZodスキーマとハンドラー関数をエクスポートする。

  3. src/tools/index.tsのTOOLSにエントリを追加する。

  4. tests/配下にテストを追加する。

これだけで、自動登録、自動検証、自動イントロスペクションが行われます。


バージョン互換性

TradingView Desktop

tradingview-mcp

ステータス

2026.x.x

0.1.x

テスト済み

TradingViewがアップデートされ、ツールが動作しなくなった場合は、まずconnection/tradingview.tsを確認してください。このファイルがTradingViewの内部APIを把握している唯一の場所です。


免責事項

本ソフトウェアは「現状のまま」提供され、いかなる種類の保証もありません。本ソフトウェアを実行することにより、お客様は以下を承諾したものとみなされます:

  • お客様自身の有料TradingView Desktopインスタンスを使用して、お客様自身のデータに対して操作を行っていること。

  • Chrome DevToolsデバッグポートをお客様自身で有効にしたこと。

  • TradingViewの内部APIは非公開であり、変更される可能性があること。

  • 本ソフトウェアは、AIエージェントが行う取引判断の正確性を保証するものではないこと。実際の資金を扱う前に、必ずデモ口座でテストしてください。


ライセンス

MIT © 2026 Harshil Patel


謝辞

これは、小さく、型定義がしっかりしており、読みやすいことを目標にゼロから構築された新しい実装です。この分野で同様のツールに取り組んできた方々に感謝いたします。

Available Tools

11 tools
chart_get_ohlcvB

Fetch recent OHLCV bars from the active chart.

Inputs: count.

chart_get_stateA

Read the current chart state: symbol, timeframe, visible studies, and last price.

Inputs: no named parameters.

chart_set_symbolB

Change the active chart symbol (e.g. "NASDAQ:AAPL").

Inputs: symbol (required).

chart_set_timeframeB

Change the active chart timeframe / resolution.

Inputs: timeframe (required).

pine_compileB

Trigger a Pine compile and return diagnostics (errors, warnings).

Inputs: no named parameters.

pine_get_sourceA

Read the current Pine Editor source code. Pine Editor must be open.

Inputs: no named parameters.

pine_saveA

Save the current Pine script (commits + reloads the indicator on the chart).

Inputs: no named parameters.

pine_set_sourceB

Replace the Pine Editor source code with new content.

Inputs: code (required).

quote_getA

Get a real-time quote snapshot for the active symbol (last price, day OHLC, volume).

Inputs: no named parameters.

screenshot_chartA

Capture the chart pane as a base64-encoded PNG.

Inputs: no named parameters.

screenshot_fullA

Capture the full TradingView viewport as a base64-encoded PNG.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose. The chart_* tools handle different aspects of chart interaction, pine_* tools manage Pine script editing and compilation, screenshot_* tools capture images, and quote_get fetches real-time quotes. No overlapping functionality.

    Naming Consistency5/5

    Tool names follow a consistent pattern: <domain>_<verb>_<noun> (e.g., chart_get_ohlcv, pine_set_source, screenshot_chart). All use lowercase with underscores, and the verb-noun structure is uniform across domains.

    Tool Count5/5

    With 11 tools, the server is well-scoped for a TradingView MCP. It covers chart manipulation, Pine scripting, quotes, and screenshots without being bloated or too sparse.

    Completeness4/5

    The tool set covers core workflows like symbol/timeframe changes, data retrieval, Pine script management, and screenshots. A minor gap is the lack of tools to add or remove studies (only visible studies are read), but this does not severely hinder typical use cases.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      A
      maintenance
      MCP server that lets AI agents directly control and interact with the TradingView desktop app via 88 chart-control tools, enabling automated chart reading, Pine Script compilation, strategy optimization, and replay control.
      113
      44 npm
      61
      MIT