TradingView PineScript
STDIOTradingView PineScript代码验证与生成服务
TradingView PineScript代码验证与生成服务
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_pinescriptValidates 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_errorsAutomatically 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_templateProvides 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!