pinescript-mcp-server
Validates, fixes, and generates PineScript code for TradingView strategies and indicators.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pinescript-mcp-servervalidate this PineScript code for v5"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TradingView PineScript MCP Server
A Model Context Protocol (MCP) server for working with TradingView PineScript. This server provides tools for validating, fixing, and generating PineScript code through a standardized API.
Features
PineScript Validation - Automatically validates PineScript code for syntax errors and warnings
Error Fixing - Automatically fixes common PineScript syntax errors
Template Generation - Provides validated templates for various PineScript strategies and indicators
Related MCP server: PineScript Docs
Getting Started
Prerequisites
Node.js 16.x or higher
npm 8.x or higher
Installation
Clone the repository
git clone https://github.com/yourusername/pinescriptproject1.git
cd pinescriptproject1Install dependencies
npm installBuild the project
npm run buildRunning the Server
Start the MCP server:
npm run start-serverThis will start the server with stdio transport, which allows it to communicate with MCP clients.
API
Tools
The MCP server exposes the following tools:
1. validate_pinescript
Validates PineScript code for syntax errors and warnings.
Parameters:
script(string): The PineScript code to validateversion(string, optional): Expected PineScript version (e.g., 'v5', 'v4')
Returns:
valid(boolean): Whether the script is validerrors(string[]): List of syntax errorswarnings(string[]): List of warnings
2. fix_pinescript_errors
Automatically fixes common syntax errors in PineScript code.
Parameters:
script(string): The PineScript code to fix
Returns:
fixed(boolean): Whether any fixes were appliedfixedCode(string): The fixed scriptchanges(string[]): List of changes made
3. get_pinescript_template
Provides validated templates for common PineScript strategies and indicators.
Parameters:
template_type(string): Type of template ('strategy' or 'indicator')name(string): Template name
Returns:
template(string): The template codemessage(string): Confirmation message
Supported PineScript Features
Syntax Validation
The validator currently checks for:
Empty scripts
Version annotations
Balanced parentheses
String quotes
Comma placement in function calls
Deprecated functions in PineScript v5
Incorrect variable export syntax
Error Fixing
The fixer can automatically fix:
Missing version annotations
Unbalanced parentheses
Unclosed string literals
Missing commas in function calls
Deprecated study() function
Incorrect variable export syntax
Development
Running Tests
npm testDebugging
To run the server in development mode with automatic reloading:
npm run devLicense
ISC
Contributing
Contributions are welcome!
This server cannot be deployed
Maintenance
Related MCP Connectors
AI trading bots: generate strategies, backtest, deploy live to 10+ brokers. No coding required.
LuxAlgo Library — the encyclopedia of trading & technical analysis for AI agents. Free, keyless.
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
- CPZAIOAuthcom.cpz-lab.mcp
Build, backtest, and deploy quantitative trading strategies from your AI agent.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables trading analysis across Forex, Stocks, and Crypto with 25+ technical indicators, real-time market data, and Pine Script v6 development tools including syntax validation, autocomplete, and version conversion.57MIT
- AlicenseAqualityBmaintenanceProvides comprehensive Pine Script v6 documentation and tools to help AI assistants look up functions, validate syntax, and generate accurate code. It enables linting, version conversion from v5 to v6, and deep conceptual analysis to prevent code hallucinations.1066 PyPI9MIT
- AlicenseNot gradedqualityFmaintenanceEnables creation, optimization, and management of PineScript trading strategies with Claude Desktop integration for AI-assisted development.11 npm105MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-assisted creation, optimization, and management of PineScript trading strategies, with backtesting and TradingView integration.11 npmMIT