Skip to main content
Glama
tradingview-mcp

tradingview-mcp

by Aloysiusjs

tradingview-mcp

A Model Context Protocol (MCP) server that gives Claude — or any MCP-compatible client — market data from TradingView, with automatic fallback to a licensed provider when TradingView fails.

Features

  • 5 tools: symbol search, live quotes, OHLCV history, technical indicators, backend health check

  • Global coverage — equities, crypto, and forex across NASDAQ, NYSE, HKEX, SGX, Binance, and more, addressed by ticker or company name

  • Automatic fallback to Twelve Data / Finnhub when TradingView's undocumented endpoints fail or rate-limit

  • Freshness labeling on every result — never presents a delayed price as live

  • Hardened input validation — bounded array sizes, whitelisted indicator names, sanitized third-party text (see Security)

Related MCP server: tradingview-mcp

Read this first

TradingView has no public market-data API. What they publish is the Charting Library (you supply your own datafeed) and embeddable widgets — there is no documented endpoint you can key into.

This server therefore talks to two undocumented TradingView endpoints that their own web app uses:

Backend

What it serves

Stability

scanner.tradingview.com

quotes, precomputed indicators, technical ratings

HTTP POST, fairly stable

data.tradingview.com (WebSocket)

OHLCV candle history

undocumented wire protocol, more fragile

symbol-search.tradingview.com

symbol resolution

stable

That means:

  • It is against TradingView's Terms of Service to redistribute this data. Treat this as a personal analysis tool. Do not resell, republish, or build a product on it.

  • It will break without warning when TradingView changes their wire format. Run npm run health when something stops working — it tells you which backend died.

  • Unauthenticated data is delayed for most equities. See below.

Data freshness — the part that matters

Every quote carries a freshness field, because "live" is not what you get by default:

Asset class

Observed update_mode

Reality

Crypto (BINANCE, COINBASE…)

streaming

real-time

Forex (FX, OANDA…)

streaming

real-time

US equities (NASDAQ, NYSE)

delayed_streaming_900

15 minutes behind

HK equities (HKEX)

delayed_streaming_900

15 minutes behind

SG equities, indices (SGX, SP)

delayed_streaming_600

10 minutes behind

Real-time equity quotes require a paid TradingView subscription and exchange data agreements, which this unauthenticated path cannot access. Never present a delayed price as live — the server tells the model this in its instructions, and every tool result repeats it per symbol.

Install

Requires Node.js 20 or newer.

git clone https://github.com/Aloysiusjs/tradingview-mcp.git
cd tradingview-mcp
npm install

Verify all backends are reachable:

npm run health

(Optional) To enable the licensed-provider fallback, get a free API key from Twelve Data and/or Finnhub. .env.example documents the variable names, but note the server reads them as regular process environment variables — there's no dotenv loader, so a .env file by itself does nothing. Either export the variable in your shell before running the server, or set it in the env block of your MCP client config (shown below).

Register with your MCP client

Every MCP client reads the same two things: the command to run (node) and the absolute path to src/index.js inside wherever you cloned this repo. Get that path by running pwd (macOS/Linux) or cd with no arguments (Windows) inside the tradingview-mcp folder.

Claude Code

claude mcp add tradingview --scope user -- node /absolute/path/to/tradingview-mcp/src/index.js

On Windows, use forward slashes in the path:

claude mcp add tradingview --scope user -- node "C:/path/to/tradingview-mcp/src/index.js"

Claude Desktop, Cursor, VS Code, and other JSON-config clients

Add this block to the client's MCP config file — for Claude Desktop that's claude_desktop_config.json (~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows); Cursor (.cursor/mcp.json) and VS Code (mcp.json in settings) use the same shape under their own filenames:

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["/absolute/path/to/tradingview-mcp/src/index.js"],
      "env": {
        "TWELVEDATA_API_KEY": ""
      }
    }
  }
}

Restart your MCP client after registering. Run tv_health (or npm run health from the repo) to confirm the server can reach TradingView.

Tools

Tool

Role

Fallback?

tv_search_symbol

Resolve a ticker, company name, or ISIN to a qualified EXCHANGE:SYMBOL

n/a (TradingView-only)

tv_quote

Price, change, volume for up to 50 instruments

Yes — Twelve Data / Finnhub

tv_history

OHLCV candles for one instrument

Yes — Twelve Data

tv_indicators

Precomputed indicators + Strong Buy…Strong Sell rating

No — TradingView-only

tv_health

Probe every backend and report status

n/a

tv_search_symbol

Resolve a ticker, company name, or ISIN to fully-qualified EXCHANGE:SYMBOL tickers.

tv_search_symbol { "query": "Tencent", "limit": 3 }
-> HKEX:700 | Tencent Holdings Ltd

tv_quote

Price, change, volume, market cap, P/E for up to 50 instruments in one call. Accepts bare tickers (AAPL) or qualified ones (BINANCE:BTCUSDT, HKEX:700, FX:EURUSD).

tv_quote { "symbols": ["AAPL", "BINANCE:BTCUSDT", "HKEX:700"] }
-> NASDAQ:AAPL   309.90  -0.14%  delayed by ~15 min
   BINANCE:BTCUSDT 78819.33 +0.40%  real-time
   HKEX:700       445.40  +0.77%  delayed by ~15 min

tv_history

OHLCV candles, oldest first, with epoch-seconds and ISO (UTC) timestamps.

tv_history { "symbol": "AAPL", "interval": "1D", "bars": 200 }

Intervals: 1m 3m 5m 15m 30m 45m 1h 2h 4h 1D 1W 1M.

Note: daily candles are stamped at the session open in UTC (a US daily bar reads 13:30:00Z), not midnight. The most recent candle may still be forming.

tv_indicators

TradingView's precomputed indicator values plus its Strong Buy…Strong Sell technical rating, at any supported timeframe. TradingView-only — the fallback provider does not compute indicators.

tv_indicators { "symbols": ["AAPL", "NVDA"], "interval": "1D" }
-> NASDAQ:AAPL  RSI 47.8  SMA50 310.88  rating Neutral
   NASDAQ:NVDA  RSI 49.6  SMA50 207.81  rating Buy

Supported: RSI RSI7 MACD.macd MACD.signal Stoch.K Stoch.D Stoch.RSI.K SMA5…SMA200 EMA5…EMA200 ADX ADX+DI ADX-DI ATR CCI20 Mom AO UO ROC W.R BB.upper BB.lower BBPower VWMA HullMA9 Ichimoku.BLine P.SAR Pivot.M.Classic.S1 Pivot.M.Classic.R1 Recommend.All Recommend.MA Recommend.Other

An unrecognised indicator name is rejected rather than passed through, because TradingView silently returns null for typos — which is indistinguishable from "no data".

tv_health

Probes every backend and reports which are answering, with latencies. Run this first when something misbehaves.

The fallback layer

When a TradingView endpoint fails or rate-limits, tv_quote and tv_history retry against a documented provider with real terms of service. Configure via environment variables:

Env var

Provider

Covers

TWELVEDATA_API_KEY

Twelve Data

quotes + OHLC history

FINNHUB_API_KEY

Finnhub

quotes only (candles are paid there)

Both have free tiers. Without a key the server still works — you just lose the safety net, and TradingView failures surface as errors.

Results always name their origin in a source field (tradingview:scanner, tradingview:ws, twelvedata, finnhub) so you can tell where a number came from.

Layout

src/
  index.js         MCP server, tool definitions
  scanner.js       scanner.tradingview.com client, column catalog, freshness decoding
  ws-history.js    TradingView chart WebSocket protocol -> OHLCV
  symbols.js       symbol search and EXCHANGE:SYMBOL resolution (cached)
  fallback.js      Twelve Data / Finnhub adapters
  intervals.js     one interval vocabulary, translated per backend
  http.js          shared fetch: browser headers, timeout, retry
  health-check.js  npm run health
tests/
  smoke.mjs               drives all five tools through a real MCP client
  fallback.mjs            provider adapters and misconfiguration messages
  failover.mjs            simulated TradingView outage -> provider takeover
  security-regression.mjs pins fixes from the pentest pass (see Security below)

Tests

npm test

Runs smoke.mjs, fallback.mjs, failover.mjs, and security-regression.mjs in sequence. smoke.mjs hits the live endpoints, so it needs a network connection and will show current prices.

Security

Trust boundary. This is a stdio MCP server: it has no network listener (confirmed - the only transport wired up is StdioServerTransport, and the only WebSocket use is an outbound client to data.tradingview.com). There is no login, session, or API-key gate on the server itself, and none is meaningful here: whatever process can write to this server's stdin already has the same privileges any caller would have, since there's no privilege differentiation between callers. The actual security boundary is "who can spawn this process" - i.e. your MCP host / IDE integration - not an authentication layer inside this repo.

Treat tool output as data, never as instructions. tv_search_symbol and tv_quote return free-text fields (description, name, exchange) sourced from TradingView's third-party symbol database. This server strips HTML tags, control characters, and zero-width/bidi-override Unicode from those fields and caps them at 200 characters (src/symbols.js), but that only shrinks the payload - it does not make the content trustworthy. Any agent consuming this server's output should treat every returned field as untrusted data, the same way it would treat the body of a fetched web page, and never follow instruction-like phrasing found inside a company name or instrument description.

Input validation. All tool arguments are bounded with zod: array lengths (symbols, indicators), numeric ranges (bars), string length (search query), and an enum (interval). The market scanner slug is restricted to [a-z0-9_-] because it is interpolated into a URL path (scanner.tradingview.com/${market}/scan) - this rejects path traversal, query/fragment injection, and CRLF, even though (verified by testing) the hardcoded hostname made none of those exploitable as SSRF in the first place.

No shell/eval/filesystem access. Nothing in src/ calls a shell, eval, Function, or the filesystem - grep for child_process|exec\(|eval\(|new Function|readFile|writeFile to confirm after future changes.

Fallback API keys (TWELVEDATA_API_KEY, FINNHUB_API_KEY) are only ever read from environment variables, only ever sent as outbound query parameters to their respective providers, and are never included in error messages, logs, or tool output - error paths only surface HTTP <status>: <truncated body>, never the request URL or key.

This has been through one adversarial review pass (command/code injection, SSRF via the market parameter, prompt-injection surface, credential leakage on fallback failure, input validation bypass, error-message hygiene, and the stdio trust boundary itself). See tests/security-regression.mjs for the checks that came out of it.

Limitations

  • Delayed equity data (see above) — this is a hard limit of unauthenticated access.

  • No order book, no tick-by-tick trades, no options chains.

  • No screening/filtering tool; the scanner client supports filter and sort payloads if you want to add one.

  • Indicators have no fallback — if TradingView's scanner is down, tv_indicators fails rather than computing them locally from candles.

  • This places no trades and touches no brokerage account. It is read-only market data.

Contributing

Issues and pull requests are welcome — see CONTRIBUTING.md for the test checklist and scope notes before opening one.

License

MIT — see the LICENSE file. Note the Terms of Service caveat above: the license covers this code, not TradingView's data.

Available Tools

5 tools
tv_healthCheck backend healthA

Probe each backend and report which are answering. Use this when a tool starts failing - these TradingView endpoints are undocumented and change without notice.

Inputs: no named parameters.

tv_historyGet OHLCV candlesA

Historical open/high/low/close/volume candles for one instrument. Served from TradingView's chart feed, falling back to the licensed provider. Returns candles oldest-first with both epoch seconds and ISO timestamps (UTC).

Inputs: symbol (required), bars, interval, adjustment.

tv_indicatorsGet indicators and technical ratingA

TradingView's precomputed indicator values and its Strong Buy..Strong Sell technical rating, at a chosen timeframe. This is TradingView-only - the licensed fallback does not compute indicators. Available indicators: RSI, RSI7, MACD.macd, MACD.signal, Stoch.K, Stoch.D, Stoch.RSI.K, SMA5, SMA10, SMA20, SMA30, SMA50, SMA100, SMA200, EMA5, EMA10, EMA20, EMA30, EMA50, EMA100, EMA200, ADX, ADX+DI, ADX-DI, ATR, CCI20, Mom, AO, UO, ROC, W.R, BB.upper, BB.lower, BBPower, VWMA, HullMA9, Ichimoku.BLine, P.SAR, Pivot.M.Classic.S1, Pivot.M.Classic.R1, Recommend.All, Recommend.MA, Recommend.Other

Inputs: symbols (required), market, interval, indicators.

tv_quoteGet quotesA

Current price, change, and volume for one or more instruments. Accepts bare tickers (AAPL) or qualified ones (NASDAQ:AAPL, BINANCE:BTCUSDT, HKEX:700). Tries TradingView first, then the configured licensed provider. Check the freshness field before calling a price live.

Inputs: symbols (required), market.

tv_search_symbolSearch TradingView symbolsA

Resolve a ticker, company name, or ISIN to fully-qualified TradingView tickers (EXCHANGE:SYMBOL). Use this first when the exchange is ambiguous, or when a symbol lookup failed elsewhere.

Inputs: query (required), limit, exchange.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool covers a clearly separate part of the market-data workflow: symbol resolution, live quotes, historical candles, technical indicators, and backend health. There is no meaningful overlap or ambiguity between them.

    Naming Consistency4/5

    All tools share the consistent 'tv_' prefix and lowercase snake_case style, making the naming predictable. tv_search_symbol is the only verb-led name while the rest are noun-resource names, a minor deviation.

    Tool Count5/5

    Five tools is well-scoped for a TradingView market-data server: each tool serves a distinct data need without redundancy. The count is neither too thin nor bloated.

    Completeness5/5

    The tool surface covers the full market-data lifecycle: find a symbol, fetch a live quote, retrieve historical candles, compute indicators, and verify backend health. There are no obvious dead ends or missing core operations.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      C
      maintenance
      An MCP server providing Model-usable tools to fetch real-time quotes, historical price charts, fundamental datasets, SEC filings, economic/earnings calendars, option chains, and corporate bond data from TradingView.
      21
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to control a local TradingView Desktop instance, providing tools to read chart state, change symbols and timeframes, and fetch OHLCV data.
      93 npm
      134
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      TradingView MCP server — real-time market data, technical indicators, screeners, and backtesting for Claude, ChatGPT, Cursor, Copilot, and any MCP client. Stocks, crypto, forex & futures across global exchanges.
      44
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes TradingView data including quotes, technical ratings, historical OHLCV, and market screening through an MCP server using unofficial libraries.
      -