Security

TradingView MCP debug port: what it opens, when to close

2026-07-30·10 min read

You install TradingView MCP, run tv_health_check, and AI starts reading your charts, writing Pine, sweeping the morning open — it just works. The step every tutorial glosses over is actually the real gate on this tool: during install, it asks you to quit the TradingView desktop app and relaunch it with --remote-debugging-port=9222. That's the pivotal move the docs never really open up.

Nobody tells you up front: that port is Chrome DevTools Protocol's debug interface — it is not a dedicated channel for MCP. Once it's open on your machine, the things that can connect to it are not limited to the MCP server you just installed.

This piece isn't a review of the TradingView MCP project itself — its own README says what needs saying, and there's no reason for us to rewrite someone else's self-disclosure. We're doing two things only: turning the sentences the author deliberately buried inside Warning and Caution blocks into language you'll actually use to make a decision, and turning "when should the debug port be closed" into a checklist you can act on.

Bottom line up front
The debug port is for debugging. It is not designed to be left open as a permanent automation channel. Research, strategy writing, morning-open scans — fine, keep it open. The moment you wire it into anything that moves money (signal → execution → order), you have to keep the permissions the AI side holds strictly separate from the permissions the execution side holds. This post explains why, and how to draw that line.
9222
Chromium's default debug port, and the number MCP's install script uses
78
MCP tools available — chart reading, Pine editing, alert creation
0
Written SLA — tradesdontlie's own README: "any TradingView update can break it"

What --remote-debugging-port=9222 Actually Opens

TradingView Desktop is an Electron app — under the hood it's Chromium wrapped in a shell. Every debug mechanism Chromium ships with is inherited, including "Chrome DevTools Protocol" (CDP hereafter). CDP is the protocol Google designed for Chrome DevTools, letting external programs drive the browser through JSON messages: read the DOM, inject JavaScript, take screenshots, listen to network events.

By default, CDP is off. To use it, you have to pass a flag at launch telling Chromium "please listen for CDP connections on this port." The tradesdontlie README puts it plainly:

tradesdontlie README, verbatim
"The debug port is disabled by default and must be explicitly enabled by you using a standard Chromium flag (--remote-debugging-port=9222). Nothing happens without that deliberate step."

"Nothing happens without that deliberate step" — that sentence is describing something you have to actively do to turn it on. It also describes the flip side: once you've done it, the port stays open until you quit TradingView and relaunch it the normal way.

So that port isn't an MCP-specific channel. It's Chromium's standard debug interface. VS Code, Slack, Discord — every Electron app has the same mechanism baked in. They just don't enable it by default, and normally you have no reason to either.

Who Else On Your Machine Can Connect To It While It's Open

By default CDP binds to 127.0.0.1:9222, the loopback interface. That means two things.

Good news: attackers on the network can't reach the port — unless you've separately forwarded it out, or you have some other service exposing localhost to the LAN or WAN. That's the technical basis for tradesdontlie repeatedly stressing "All data stays on your machine."

But here's the catch: "local" is not a security boundary. Any process running as your user can connect to 127.0.0.1:9222 — no password, no token, no CORS protection. CDP assumes from the start that "anyone who can reach this port has the right to debug," because its original purpose was for developers to open it themselves and debug their own app.

Type of thing that can hit localhost:9222Why it canWhen this happens in practice
Commands you run in your own terminalRuns as your userYou run the tv CLI, or any curl localhost:9222/json/list
npm / pip / homebrew packages you installSame user identity as your terminalAny postinstall script, build tool, or dev server anywhere in your dependency graph
Your editor extensions (VS Code, Cursor)Runs as your userAny third-party extension installed in your IDE
A webpage open in your browserCan fetch("http://localhost:9222/json/list"), if the server's CORS response allows itTrue under some configurations; CDP's GET endpoints often return Access-Control-Allow-Origin: * style headers, so don't assume safety without testing
Other MCP servers you or someone else installedAs long as it runs on the same machineThe next AI tool you install, or even a second tv CLI instance

Common process sources that end up on the same machine as you. This table is for thinking through the attack surface, not for scaring you — in most people's threat model, all of these processes are trusted. Verified July 2026.

If your threat model is "I trust everything running on this box," leaving the debug port open is fine. That is genuinely most solo developers' day-to-day reality. But it has to be something you've verified for yourself — the tool cannot guarantee it for you.

What You Can Do Through That Connection Is Much More Than "Help AI Look At Charts"

tradesdontlie's MCP server wraps CDP calls in 78 tools. Those wrappers are useful, but an external observer isn't constrained by them — CDP itself offers more than those 78 tools expose. Any program that connects to localhost:9222 can:

  • Execute arbitrary JavaScript: via Runtime.evaluate — this is an official CDP method whose whole point is to evaluate any expression against the page's global object. That means it can read anything on your TradingView page: watchlists, layouts, alerts, the current symbol, the Pine Script you were half-way through editing.
  • Take screenshots and recordings: your chart state, open layouts, which symbol you're looking at — quietly extractable.
  • Manipulate UI state: switch symbols, switch timeframes, click buttons, close tabs — CDP has Input.dispatchMouseEvent and dispatchKeyEvent, which can simulate user input.
  • Modify Pine Script source: MCP's pine_set_source underneath is just pasting a string into the editor. Any program with a CDP connection can do the same.
  • Create, modify, and delete alerts: MCP exposes alert_create and alert_delete — again, wrappers on top of CDP.

The fifth point deserves its own beat. Alerts are the entry point for your signals into downstream automation — you build an alert in TradingView, the alert fires, a webhook hits your execution service, and the execution service places the order. If a program that can reach CDP can build alerts for you, it gets a shot at injecting signals into your existing execution flow. The alert it injects doesn't need to have anything to do with your strategy's logic; as long as its payload matches whatever your webhook is parsing on the other end, downstream treats it as a legitimate signal.

This is inference, not a publicly logged attack
This is an inference drawn from what CDP can do plus the common shape of webhook execution flows — we haven't seen an incident logged in a public database following this exact path. But the attack path is technically viable and cheap. Read it as a well-supported inference, not as an official advisory or a documented event.

"It Doesn't Place Real Trades" — How To Read That Sentence

tradesdontlie's README, under "What This Tool Does Not Do": "Execute real trades (chart interaction only)". That sentence correctly describes the MCP tool itself — its wrappers really don't contain any real trading API wrappers, only replay_trade (simulated orders in replay mode).

But the sentence only speaks to the boundary of what the MCP tool wraps. It doesn't speak to:

What "doesn't place real trades" doesn't coverWhy it still matters
Downstream orders triggered by alert → webhookAny program that reaches CDP can create alerts; the execution end has no way to tell whether an alert was created by you or by someone else
Access to your TradingView account's own dataWatchlists, saved layouts, Pine Script source, bar-replay history — all readable through CDP
Modifications to your strategy codepine_set_source can write to any file's contents; if that file later gets manually compiled or pushed into another system you run, the modified code travels downstream
Other Electron apps you might be signed into at the same timeOnce you develop the habit of "always run with --remote-debugging-port," the attack surface on Slack, Discord, or VS Code is bigger than on TradingView — that's not this tool's fault, it's the habit's fault

The MCP server's self-imposed limits don't equal the boundary of the debug port on the whole machine. Verified July 2026.

What "Undocumented TradingView APIs" Really Means

The README's Caution block: "This tool accesses undocumented internal TradingView APIs via the Electron debug interface. These can change or break without notice in any TradingView update."

Translated into language you'll use to make decisions: TradingView has made no commitment that these interfaces will remain stable. Today pine_smart_compile works and data_get_pine_lines works — that says nothing about next week after the desktop app updates. This isn't new territory for readers of this site — it's the same species of fragility we wrote about in "Pine Script Alerts Have No Memory": you're depending on behavior the platform never wrote down, and it has no obligation to warn you before it changes.

This site's core stance has always been: whether your trading flow can depend on an interface comes down to whether the interface provider gave you a written contract you can hold up. Official APIs, publicly documented webhook specs, behavior spelled out in terms of service — when those break, you can point at the document. But for CDP-wrapper tools like tradesdontlie, there's nothing to point at — TradingView has never written down that it will maintain any of these internal interfaces.

So: research, strategy writing, Pine practice, morning-open scans — MCP is great for all of these, because the cost of a break is just "can't do this today." Before you connect it to anything that moves money, ask once: when this link breaks, whose money is affected? If the answer is "mine," it doesn't belong in the critical path.

When To Close The Port: A Checklist You Can Act On

This isn't a "if you use MCP you must" sermon. It's "should the debug port be open right now" broken into concrete conditions you can check today.

  • Close it when you're done. After a session of AI-assisted chart analysis, quit TradingView and relaunch it normally (without --remote-debugging-port). "Leave it always open" costs more than you think, and buys you nothing extra — AI isn't going to open your charts on its own at 3 a.m.
  • Don't add the debug-mode TradingView to your login items. If you set the launcher script with --remote-debugging-port=9222 to run at boot, every startup opens an unauthenticated CDP port on your machine.
  • Only open it on machines you trust. Don't open it on shared computers, company-issued devices, or machines where you've installed anything of unknown provenance. "Local" is not a security boundary in those settings.
  • While the port is open, don't browse untrusted sites in the same browser profile. Browser CORS behavior toward localhost isn't fully consistent — don't assume the browser will block a fetch to localhost:9222 without testing.
  • If there's a webhook execution end downstream, pin the alert payload. The webhook end should at minimum verify a secret field inside the alert message (strategy ID, signature, shared key) — don't just trust "a signal came in, so place the trade." That way, even if someone creates an alert through CDP, the execution end rejects it.
  • Order-placement permission downstream is configured separately. AI holding a CDP connection is one thing; the execution end holding your exchange API keys is another — the two permission boundaries have to be managed apart. See the API key permissions checklist for non-custodial trading bots; that one covers permissions on the exchange side and complements the AI-side thinking here.
  • Don't say "it's just local" before you've done a threat model. "Local" is a network boundary, not a process boundary. That npm package you installed yesterday shares the same "local" as your CDP connection.

The Honest Section: AI Stays On The Generation And Analysis Side, Execution Rights Live Elsewhere

We can't guarantee that "debug port open + an MCP server running" will never lead to an incident — we haven't red-teamed it and this article isn't going to. All this piece can do is lay out what the author has already self-disclosed, so you can see the full picture before deciding.

But standing on this site's consistent position, we can say one thing: "AI generating a strategy" and "the strategy placing orders" are two different problems, and you shouldn't solve both over the same connection. Bridges like MCP make it convenient for AI to talk to your charts. When you get ready to let a strategy actually place real trades, that same connection shouldn't be the pipe. There should be a clean boundary in between: a non-custodial execution service, your own API keys, dry-run first, risk controls hard-coded on your side. That way, if the whole MCP/CDP stack has an incident down the road, the blast radius stops at the alert — everything past the alert is on infrastructure you built and control.

Frequently Asked Questions

I'm just using MCP to let Claude look at charts and edit Pine. Is anything going to happen?
For that single use case, most solo developers' everyday environments are fine — provided you've verified nothing you don't trust is running on the same machine. But the tool itself gives you no additional isolation — all the security rides on your own threat model. When you're done, quit TradingView and relaunch normally. Don't leave the port open.
Would it be safer to change the debug port from 9222 to something else?
Barely. Any local process can scan localhost ports and hit /json/list to fingerprint which app is running — changing the number just adds 200ms to an attacker's search. The real boundary isn't the port number, it's which processes can reach loopback.
Why does tradesdontlie say "it's safe to run"? Are they hand-waving?
They're not. The README's wording is "How It Works (and why it's safe to run)", which is about relative to "talking to TradingView's servers" or "intercepting network traffic" — this tool really only reads locally, and really doesn't touch TradingView's end. That sentence is accurate. It doesn't claim that every other process on your machine is harmless to this debug port — that's a different question, and the author never claimed otherwise.
If I hook up alert → webhook → TVSBot, does the CDP issue above bleed into it?
The alert step is still on TradingView's side, so while the CDP port is open it could be interfered with. But everything from the webhook to TVSBot is unrelated to CDP — the execution end reads the API keys and risk controls you configured on TVSBot. So the right pattern is: keep the debug port strictly as a research tool, entirely separated from the signal path. TVSBot also recommends carrying a shared secret inside the alert message and validating it on the webhook end — that way even an alert someone else created gets blocked at execution.
Can I use TradingView Web instead of Desktop so I don't have to open the debug port?
The Web version doesn't take --remote-debugging-port — that flag belongs to Chromium/Electron desktop apps. But tradesdontlie's MCP currently only supports the Desktop app; if you don't need MCP's capabilities (say you just want AI to generate Pine and paste it into Web to run), you never have to touch this port.

Get started

Ready to ship what you just learned?

Bring the Pine Script your AI just wrote, and let TVSBot handle the webhook-to-exchange leg — with your own API keys, dry-run first, risk controls you set, fully isolated from the CDP connection on the AI side.

Get started free