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.
Clone the repository:
shell
git clone https://github.com/yourusername/pinescriptproject1.git
cd pinescriptproject1
Install dependencies:
shell
npm install
Build the project:
shell
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 validate
- version (string, optional): Expected PineScript version (e.g., 'v5', 'v4')
Returns:
- valid (boolean): Whether the script is valid
- errors (string[]): List of syntax errors
- warnings (string[]): List of warnings
fix_pinescript_errorsAutomatically fixes common syntax errors in PineScript code.
Parameters:
- script (string): The PineScript code to fix
Returns:
- fixed (boolean): Whether any fixes were applied
- fixedCode (string): The fixed script
- changes (string[]): List of changes made
get_pinescript_templateProvides 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 code
- message (string): Confirmation message
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
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
npm test
To run the server in development mode with automatic reloading:
npm run dev
ISC
Contributions are welcome!
No description, website, or topics provided.
No releases published
No packages published