pinescript-mcp
v1.0.0
Published
MCP server for Pine Script development — linting, validation, migration, and templates. No TradingView Desktop required.
Downloads
147
Maintainers
Readme
pinescript-mcp
MCP server for Pine Script development. Lint, validate, migrate, and scaffold Pine Script without needing TradingView Desktop.
8 tools. Zero external dependencies beyond the MCP SDK. Pure static analysis.
Tools
| Tool | Description |
|------|-------------|
| pine_validate | Parse and validate structure — version, declaration, variables, functions, inputs, plots |
| pine_lint | 16 rules across errors, warnings, and info — catches v4/v5/v6 breaking changes, repainting, bad practices |
| pine_migrate | Migrate code between v4→v5, v5→v6, or v4→v6 with a full change log |
| pine_migration_guide | Get the complete breaking changes guide for a version pair |
| pine_template | 7 starter templates — indicators, strategies, libraries, alerts |
| pine_reference | Look up built-in functions, variables, and constants by name |
| pine_namespace | Browse Pine Script namespaces (ta, math, str, request, strategy) |
| pine_repainting_check | Focused repainting analysis — lookahead leaks, timenow, barstate, varip |
Install
npm install pinescript-mcpClaude Code
claude mcp add pinescript -- npx pinescript-mcpClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"pinescript": {
"command": "npx",
"args": ["pinescript-mcp"]
}
}
}Manual
npx pinescript-mcpCommunicates over stdio using the Model Context Protocol.
Lint Rules
Errors
| Rule | Description |
|------|-------------|
| E001 | Missing //@version=N annotation |
| E002 | Missing indicator() / strategy() / library() declaration |
| E003 | = vs := reassignment confusion |
| E004 | v4 functions used in v5+ (e.g., sma() → ta.sma()) |
| E005 | security() without request. prefix in v5+ |
| E006 | v6 breaking changes (transp removal, when parameter removal) |
| E007 | Plot functions called inside user-defined functions |
Warnings
| Rule | Description |
|------|-------------|
| W001 | request.security() with lookahead_on but no [1] offset (repainting) |
| W002 | timenow usage (always repaints) |
| W003 | barstate.isrealtime without barstate.isconfirmed guard |
| W004 | varip — not reproducible on historical bars |
| W005 | More than 40 request.*() calls |
| W006 | More than 64 plot calls |
| W007 | calc_on_every_tick=true in strategy |
Info
| Rule | Description |
|------|-------------|
| I001 | Missing title on plot functions |
| I002 | Strategy with entries but no exits or risk management |
Migration
Supports v4→v5, v5→v6, and v4→v6 (chained).
v4 → v5 renames 40+ functions:
study()→indicator()sma()→ta.sma(),ema()→ta.ema(),rsi()→ta.rsi(), ...security()→request.security()abs()→math.abs(),ceil()→math.ceil(), ...tostring()→str.tostring()iff(cond, a, b)→cond ? a : bresolution=→timeframe=
v5 → v6 handles breaking changes:
transpparameter removal (flags with TODO)whenparameter removal from strategy functionstimeframe.periodcomparison updates ("D"→"1D")
Templates
indicator-basic— Simple overlay indicatorindicator-oscillator— Oscillator with overbought/oversold levelsstrategy-basic— Moving average crossover strategystrategy-rsi-mean-reversion— RSI mean reversion with risk managementstrategy-breakout— Donchian channel breakoutlibrary-basic— Reusable library scaffoldalert-setup— Alert condition patterns
Reference
Built-in reference covers 5 namespaces with function signatures, descriptions, and examples:
- ta — Technical analysis (sma, ema, rsi, macd, bb, stoch, crossover, ...)
- math — Math functions (abs, ceil, floor, round, sqrt, log, pow, ...)
- str — String operations (tostring, tonumber, contains, replace, ...)
- request — Data requests (security, security_lower_tf, currency_rate, ...)
- strategy — Strategy functions (entry, exit, close, close_all, risk, ...)
Development
git clone https://github.com/edgeless-ai/pinescript-mcp.git
cd pinescript-mcp
npm install
npm test53 tests across parser, linter, and migrator modules.
License
MIT
