
TradingView PineScript
STDIOMCP server for validating, fixing, and generating TradingView PineScript code
MCP server for validating, fixing, and generating TradingView PineScript code
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.
git clone https://github.com/yourusername/pinescriptproject1.git cd pinescriptproject1
npm install
npm run build
Start the MCP server:
npm run start-server
This will start the server with stdio transport, which allows it to communicate with MCP clients.
The MCP server exposes the following tools:
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 warningsfix_pinescript_errors
Automatically fixes common syntax errors in PineScript code.
Parameters:
script
(string): The PineScript code to fixReturns:
fixed
(boolean): Whether any fixes were appliedfixedCode
(string): The fixed scriptchanges
(string[]): List of changes madeget_pinescript_template
Provides validated templates for common PineScript strategies and indicators.
Parameters:
template_type
(string): Type of template ('strategy' or 'indicator')name
(string): Template nameReturns:
template
(string): The template codemessage
(string): Confirmation messageThe validator currently checks for:
The fixer can automatically fix:
npm test
To run the server in development mode with automatic reloading:
npm run dev
ISC
Contributions are welcome!