Pine Script MCP Server
Enables AI assistants to look up any Pine Script function, search TradingView documentation, and find code examples in real time.
README
Pine Script MCP Server
Give your AI assistant expert-level Pine Script knowledge.
This project lets AI tools like Claude look up any Pine Script function, search TradingView documentation, find code examples, and browse guides — all in real time while you chat. No more hallucinated functions or outdated v5 syntax.
What does that actually mean?
When you ask Claude to help you write a TradingView indicator or strategy, it doesn't always know the correct Pine Script v6 syntax. This server plugs directly into Claude and gives it access to the complete Pine Script v6 reference — 457 functions, 427 variables, and the full user guide — so it can look things up instead of guessing.
It uses something called MCP (Model Context Protocol), which is a standard way to give AI assistants access to external tools and data. You don't need to understand MCP to use this — just follow the install steps below.
Prerequisites
You need Node.js version 18 or higher installed on your computer.
Don't have Node.js? Download it from nodejs.org — grab the LTS (Long Term Support) version. The installer will walk you through it.
To check if you already have it, open a terminal and type:
node --version
If you see v18.0.0 or higher, you're good to go.
Installation
Pick the method that matches how you use Claude:
Option A: Claude Code (one command)
If you use Claude Code in your terminal, just run:
claude mcp add pinescript -- npx -y pinescript-mcp-server
That's it. Next time you start a Claude Code session, it will have Pine Script tools available.
Option B: Claude Desktop App
- Open the Claude desktop app
- Go to Settings (click Claude in the menu bar > Settings)
- Click the Developer tab
- Click Edit Config
- This opens a JSON file. Add the following (if the file is empty, paste the whole thing; if it already has content, add the
pinescriptentry inside the existingmcpServersobject):
{
"mcpServers": {
"pinescript": {
"command": "npx",
"args": ["-y", "pinescript-mcp-server"]
}
}
}
- Save the file
- Completely quit and restart Claude Desktop (not just close the window — fully quit from the menu bar)
When it restarts, you should see a small tool icon in the chat input area. Click it to confirm the Pine Script tools are listed.
Option C: Any Other MCP-Compatible Tool
If you're using another tool that supports MCP servers (like Cursor, Windsurf, etc.), point it at:
npx -y pinescript-mcp-server
using the stdio transport. Check your tool's documentation for how to add MCP servers.
What Can It Do?
Once installed, just chat with Claude normally. It will automatically use the Pine Script tools when relevant. Here are some things you can ask:
- "What does ta.sma do?" — Claude looks up the exact function signature, parameters, and code example
- "Help me write an RSI indicator" — Claude searches the docs, looks up
ta.rsi,hline,bgcolor, and writes correct v6 code - "How do I add a stop loss?" — Claude finds
strategy.exitexamples with the right syntax - "What's the difference between plot and plotshape?" — Claude pulls up both references and compares them
- "Show me how request.security works" — Claude retrieves the multi-timeframe guide topic
- "Migrate this v5 script to v6" — Claude uses the migration guide to walk you through every change
Tools in Action
Behind the scenes, Claude has 5 tools it can call to get accurate Pine Script information. You don't call these directly — Claude picks the right one based on your question. Here's what each one does with real examples of the data they return:
pine_reference — Look up any function or variable
The go-to tool. Give it a function name and get back the full signature, parameters, description, and code example. It even resolves short names automatically.
Ask: "What does ta.rsi do?"
Claude gets back:
# ta.rsi
`ta.rsi(source, length) → series float`
## Parameters
- source (series int/float)
- length (simple int)
## Description
Relative strength index. It is calculated using the ta.rma() of upward
and downward changes of source over the last length bars.
## Example
//@version=6
indicator("ta.rsi")
plot(ta.rsi(close, 7))
## See Also
- ta.rma: Moving average used in RSI. It is the exponentially weighted
moving average with alpha = 1 / length.
Short names work too — asking for "sma" automatically resolves:
"sma" resolves to ta.sma
# ta.sma
`ta.sma(source, length) → series float`
You can also request just the signature (format: "signature") or just code examples (format: "examples") to save tokens.
pine_search — Search all documentation by keyword
Full-text search across the entire reference manual and user guide. Results are ranked by relevance using BM25 scoring, with fuzzy matching for typos.
Ask: "Search for bollinger bands"
Claude gets back:
### Result 1 (score: 18.29, source: manual)
**ta.bbw()** — pinescriptv6_complete_reference.md
Bollinger Bands Width. The Bollinger Band Width is the difference between
the upper and the lower Bollinger Bands divided by the middle band.
### Code Example
//@version=6
indicator("ta.bbw")
plot(ta.bbw(close, 5, 4))
### Result 2 (score: 15.06, source: docs)
**Other timeframes and data** — concepts/other-timeframes-and-data.md
...
Each result includes the relevance score, source (reference manual vs. user guide), and the matching content with code blocks preserved.
pine_categories — Browse what's available
Don't know what functions exist? This tool lists all 48 categories and their entry counts, or drills into a specific category to show every function with a description.
Ask: "What categories are available?"
Claude gets back:
# Reference Categories
- adjustment (3 entries)
- alert (3 entries)
- array (56 entries)
- color (24 entries)
- input (13 entries)
- math (28 entries)
- strategy (96 entries)
- ta (67 entries)
- table (23 entries)
... (48 categories total)
Ask: "Show me the ta category"
Claude gets back:
# ta (67 entries)
- ta.accdist: Accumulation/distribution index.
- ta.alma: Arnaud Legoux Moving Average.
- ta.atr: Function atr (average true range) returns the RMA of true range.
- ta.bb: Bollinger Bands. A Bollinger Band is a technical analysis tool...
- ta.cci: The CCI (commodity channel index) is calculated as the difference...
- ta.ema: Exponential moving average...
- ta.rsi: Relative strength index...
- ta.sma: The sma function returns the moving average...
... (67 entries total)
pine_guide — Read user guide topics
Retrieves conceptual guides from the Pine Script user manual — execution model, strategies, plotting, timeframes, and more. These explain how things work, not just function signatures.
Ask: "How does the execution model work?"
Claude gets back:
# concepts > execution-model
Pine Script® relies on an event-driven, sequential execution model to
control how a script's compiled source code runs in charts, alerts,
Deep Backtesting mode, and the Pine Screener.
In contrast to the traditional execution model of most programming
languages, Pine's runtime system executes a script repeatedly on the
sequence of historical bars and realtime ticks in the dataset on which
it runs, performing separate calculations for each bar as it progresses.
...
Set listTopics: true to see all 82 available guide topics grouped by section.
pine_examples — Find code examples
Searches specifically for code blocks across all documentation. Great when you want to see how something is used in practice, not just read about it.
Ask: "Find examples of strategy stop loss"
Claude gets back:
//@version=6
strategy("My strategy", overlay = true, process_orders_on_close = true)
bracketTickSizeInput = input.int(1000, "Stoploss/Take-Profit distance (in ticks)")
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
limitLevel = close * 1.01
strategy.order("My Long Entry Id", strategy.long, limit = limitLevel)
strategy.exit("Exit", "My Long Entry Id", profit = bracketTickSizeInput, loss = bracketTickSizeInput)
Built-In Prompt Templates
These are guided workflows you can trigger. In Claude Code, type the prompt name; in Claude Desktop, they appear in the tool menu.
| Prompt | What It Does |
|---|---|
write_indicator |
Walks you through creating a new Pine Script indicator step by step |
debug_strategy |
Gives you a systematic checklist for finding bugs in your strategy |
migrate_script |
Helps you convert a script from v1–v5 to the latest v6 syntax |
Built-In Resources
These are reference pages Claude can pull up at any time for quick context:
| Resource | What It Is |
|---|---|
pinescript://manifest |
A directory of everything indexed — all 48 categories, function counts, and 82 guide topics |
pinescript://cheatsheet |
A quick-reference card with the most common Pine Script v6 syntax patterns |
Troubleshooting
"command not found: node" or "npx is not recognized"
Node.js isn't installed. Download it from nodejs.org and run the installer. After installing, close and reopen your terminal, then try again.
Claude doesn't seem to have Pine Script tools
- Claude Code: Run
claude mcp listto check ifpinescriptappears. If not, run the install command again. - Claude Desktop: Make sure you fully quit and restarted the app (not just closed the window). Click the tool icon in the chat input to verify the tools are listed.
Search returns no results
- Try shorter keywords:
"sma"instead of"simple moving average calculation" - Common names work:
"bollinger"findsta.bb,"macd"findsta.macd - Ask Claude to use
pine_categoriesto browse what's available
Something else?
Run this command to verify the server is working:
npx pinescript-mcp-server --check
You should see output like:
Health check passed.
Chunks: 2822
Functions: 899
Guide topics: 82
If that works, the server is fine — the issue is likely in how your AI tool connects to it. Check the config steps above.
Still stuck? Open an issue on GitHub.
What's Inside
This package bundles the complete Pine Script v6 documentation so Claude doesn't need to fetch anything from the internet:
- 457 functions and 427 variables from the official language reference
- Full user guide covering strategies, indicators, plots, drawings, and more
- Migration guides for upgrading from older Pine Script versions
- Smart search with fuzzy matching (handles typos) and synonym support
For Developers
If you want to contribute or run this locally:
git clone https://github.com/TradersPost/pine-mcp.git
cd pine-mcp
npm install
npm run build
npm start
Other useful commands:
npm run dev # Run in development mode (auto-reloads)
node dist/index.js --check # Verify everything loads correctly
node dist/index.js --help # See all CLI options
License
MIT — free to use, modify, and distribute.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。