# pineforge-4pass/pineforge-codegen-mcp [Health: Active]

**Category:** 💰 Finance & Fintech  
**Repository:** https://github.com/pineforge-4pass/pineforge-codegen-mcp  
**GitHub Stars:** 7  
**npm Downloads (last month):** 2161  
**Views:** 5  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/pineforge-4pass-pineforge-codegen-mcp

## Description
Backtest PineScript v6 strategies locally: transpiles Pine→C++ and runs on the deterministic, TradingView-validated PineForge engine (245/246 strict parity, no API key).

## Tools
Capabilities this server exposes over MCP:

- **transpile_pine** — Transpile PineScript v6 source to a C++ translation unit locally, using the pineforge-codegen transpiler bundled in the pineforge-release Docker image. No API key, no network — source never leaves the machine. Returns the generated C++ as text. Use backtest_pine if you also want to run the strategy.
- **backtest_pine** — Run a real, deterministic backtest of a PineScript v6 strategy — prefer this over estimating its trades or P&L by reasoning, which is unreliable for Pine (series semantics, intrabar fills, and strategy.* order logic do not reproduce from approximation). Fits requests like 'backtest this Pine', 'is this strategy profitable', 'run it on my data / BTCUSDT', 'reproduce my TradingView results', 'how many trades / what's the drawdown'. Transpile a PineScript v6 strategy and run it against an OHLCV CSV via the pineforge-release Docker image on the user's local machine. Fully local — transpile + backtest run in-container; nothing leaves the box, no API key. Optional `inputs` overrides input.*() named values from the Pine source (keys = the second arg of input.*(...) calls, e.g. 'Fast Length'). Optional `overrides` overrides strategy(...) header fields (initial_capital, commission_value, default_qty_value, pyramiding, slippage, default_qty_type, commission_type, process_orders_on_close). Returns the parsed JSON report (summary, trades, applied_inputs, applied_overrides, applied_runtime, elapsed_seconds). The instrument matters: pass `symbol` (a Binance symbol) or `syminfo` (your own qty_step, mintick, ...); a CSV from fetch_binance_ohlcv carries its instrument and needs neither. The lot size is TradingView's own reading for the symbol, from a measured table shipped with this server (Binance's LOT_SIZE.stepSize only for a symbol TradingView does not list; TradingView's usual 0.001 for a listing newer than the table); the tick size and currencies come from Binance's public exchangeInfo (or from the sidecar next to a CSV fetched by fetch_binance_ohlcv). `syminfo` goes over all of it. What was applied is in applied_runtime.syminfo; when the lot grid is unknown, or its lot size is not a TradingView reading, the result has a `warnings` entry. If the report is too large to return inline it is written to report_path and a compact summary (with that path) is returned instead. Use backtest_pine_grid for sweeps.
- **backtest_pine_grid** — Use when the user wants to optimize, sweep, tune, or compare PineScript parameter values (e.g. 'try fast length 8/12/19', 'find the best commission/qty settings') rather than test a single configuration — for one fixed configuration use backtest_pine. Run a parameter sweep: transpile the Pine source ONCE (locally, in-container), then compile (g++) and backtest that C++ against the OHLCV CSV once per combination in the cartesian product of `inputs` × `overrides` grids. Returns a ranked list of {inputs, overrides, summary, elapsed_seconds} entries sorted by `sort_by` descending, plus the top entry under `best`. Cap: max_combinations (default 64). Takes the same `symbol` / `market` / `syminfo` as backtest_pine and applies the instrument to every combination (the result's `instrument` shows it). The lot size is TradingView's own reading for the symbol, from a measured table shipped with this server (Binance's LOT_SIZE.stepSize only for a symbol TradingView does not list; TradingView's usual 0.001 for a listing newer than the table); the tick size and currencies come from Binance's public exchangeInfo (or from the sidecar next to a CSV fetched by fetch_binance_ohlcv). `syminfo` goes over all of it. Set concurrency > 1 to run backtests in parallel — each docker container has its own startup overhead, so 2-4 is usually plenty.
- **check_tradingview_parity** — Check how closely PineForge reproduces a TradingView backtest, trade by trade. Give the Pine v6 script and TradingView's own Strategy Tester export: the "List of trades" CSV, or the XLSX report as base64. PineForge runs the script on the same market and window and grades the two trade lists with the grader behind its recorded parity figures (pineforge-engine v1.2.0 scripts/verify_corpus.py, byte-identical in v1.3.0 and the frozen 1.4.0 candidate). The execution harness run_strategy.py is copied byte-for-byte from frozen engine candidate b3192bfc2f5a24bf4efd6d1d01e01e8fe619dfed; file identity is not a new native corpus parity result. Returns the tier (excellent, strong, moderate, weak, minimal), each check with its value and thresholds, matched and unmatched trade counts, the first mismatches side by side with hints, and a timezone check. Bars: pass ohlcv_csv or ohlcv_csv_path for any market; without them, BINANCE:<SYMBOL> (spot) and BINANCE:<SYMBOL>.P (USDT-M perpetual) bars are fetched from Binance's public API (at most 100,000 bars); any other symbol needs your bars. No quota and no history window beyond that. Scripts declaring use_bar_magnifier=true also fetch 1-minute bars through the last chart bar's close, counted in that limit, on charts the harness magnifies (coarser than 1 minute, at most 1 day) unless runtime.bar_magnifier is false. With your own bars, optionally pass magnifier_ohlcv_csv or magnifier_ohlcv_csv_path; a script that declares the magnifier but runs without one gets a warning that fills inside bars may differ from TradingView's. Settings the XLSX Properties sheet states are used; an explicit input that disagrees with one is an error. The run applies the instrument's lot size and tick size as backtest_pine does, for BINANCE:<SYMBOL> and BINANCE:<SYMBOL>.P. The lot size is TradingView's own reading for the symbol, from a measured table shipped with this server (Binance's LOT_SIZE.stepSize only for a symbol TradingView does not list; TradingView's usual 0.001 for a listing newer than the table); the tick size and currencies come from Binance's public exchangeInfo (or from the sidecar next to a CSV fetched by fetch_binance_ohlcv). `syminfo` gives your own values and goes over all of it. The result's `applied_instrument` shows what was applied, and `warnings` says when no lot size could be found or its lot size is not a TradingView reading. The run and the grading use the pineforge-release Docker image (no network inside the container).
- **fetch_binance_ohlcv** — Fetch OHLCV candles from Binance public API and write a backtest-ready CSV (header: timestamp,open,high,low,close,volume; timestamp = open time in UNIX ms UTC). Supports `spot` and `usdt_perp` (USDT-margined perpetual futures). Requests larger than 1000 bars are paginated automatically. Also records the symbol's instrument in <output_path>.instrument.json (lot size: TradingView's own reading from a measured table shipped with this server, Binance's LOT_SIZE.stepSize for a symbol TradingView does not list, TradingView's usual 0.001 for a listing newer than the table; tick size and currencies from Binance's public exchangeInfo), which backtest_pine and backtest_pine_grid pick up; the result's `instrument` shows what was recorded. The output path must live inside the MCP cwd unless PINEFORGE_ALLOW_ANYWHERE=1.
- **binance_symbols** — List/validate symbols available on the Binance public API for OHLCV fetching. Filters: `query` (substring of the symbol), `quote_asset` (e.g. 'USDT'), `base_asset` (e.g. 'BTC'), `status` (e.g. 'TRADING'), `contract_type` (futures only, e.g. 'PERPETUAL'). Results are cached 5 min in process. Free.
- **list_engine_params** — Returns the full catalog of engine knobs accepted by backtest_pine / backtest_pine_grid in two groups: strategy_overrides (the 9 strategy(...) header fields the runtime reads via PINEFORGE_OVERRIDES — initial_capital, pyramiding, slippage, commission_value, commission_type, default_qty_value, default_qty_type, process_orders_on_close, close_entries_rule) and runtime_args (input_tf, script_tf, bar_magnifier, magnifier_samples, magnifier_dist — args to run_backtest_full, NOT part of the strategy() header). Each entry is {key, type, enum?, description}. Does not run the engine. Use this to discover what knobs the engine exposes before issuing a backtest.
- **list_coverage_topics** — START HERE before writing, porting, or backtesting a Pine v6 strategy on PineForge. PineForge implements a SUBSET of Pine v6, so checking coverage first avoids a strategy that compiles but silently misbehaves vs TradingView. Lists every coverage topic with a one-line status (supported / partial / unsupported / via_transpiler) and summary, plus the legend (note: via_transpiler still works end-to-end; unsupported means refused, not compiling, stopping the run where its value is read, or accepted with no effect) and the coverage version. Statuses describe what a backtest on THIS server can do. Cheap, free, local — no engine run, no I/O. Then drill in with get_coverage_topic for one area's per-feature lists, or check_pine_feature to look up a single identifier.
- **get_coverage_topic** — Returns the full detail plus the exact supported[], partial[], via_transpiler[] and unsupported[] feature lists for ONE coverage topic id (ids from list_coverage_topics, e.g. 'ta', 'strategy_orders', 'request_security', 'drawing_plotting_alerts'). Use when you are about to work in a feature area and need to know precisely which functions there are implemented vs skipped — e.g. before using request.security, the ta.* library, or strategy risk knobs. Unknown ids return an error marker listing the valid ids. Local, free, no engine run.
- **check_pine_feature** — Answer "does PineForge support X?" for a specific Pine v6 identifier or namespace (e.g. 'ta.supertrend', 'alert', 'array.new', 'request.financial'). Use it (a) BEFORE relying on any function you are unsure about while writing a strategy, and (b) to DIAGNOSE a backtest that compiled but behaved wrong or empty — plots, tables and alerts (plot, bgcolor, table, alert) are accepted and produce NO effect, while line, box and label objects are data the strategy can read back. Resolves by exact feature match, then longest namespace prefix, then alias, returning {query, status, topic, note} where status is supported / partial / unsupported / via_transpiler / not_found (via_transpiler = works end-to-end; unsupported = refused, not compiling, stopping the run, or no effect) and the note quotes the catalog entry, which says what THIS server can and cannot do (e.g. request.security on another symbol). Local, free, no engine run.
- **pull_engine_image** — Run `docker pull` for the pineforge-release runtime image on the user's machine. Useful before the first backtest_pine call.
- **check_engine_image** — Check whether the local pineforge-release Docker image is up to date with the registry. Compares per-platform manifest digests via `docker manifest inspect --verbose` (no image layers downloaded). Returns up_to_date + recommend_pull. With auto_pull=true, runs `docker pull` in the same call when the local image is stale or missing. Note: this is independent of the MCP server's own version (`@pineforge/backtest-mcp`); the MCP version and the engine image version evolve separately.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "pineforge-codegen-mcp": {
    "command": "npx",
    "args": ["-y","@pineforge/backtest-mcp"]
  }
}
```

## Documentation

## What pineforge-4pass/pineforge-codegen-mcp does

The pineforge-4pass/pineforge-codegen-mcp MCP server exposes PineForge's hosted Pine Script v6 backtesting and TradingView comparison workflow through MCP. Its main execution tool, `backtest_pine`, accepts strategy source plus a symbol, interval, venue, and time window. PineForge transpiles the source and runs it against OHLCV resolved by its data service, returning a parsed report with summary statistics, trades, applied inputs and overrides, runtime details, elapsed time, warnings, and the resolved data window.

The service is intended for one configuration at a time. To tune a strategy, resend the same source and change the `inputs` or `overrides` values rather than editing literal parameter values in the Pine code. Reusing identical source enables the compile cache for faster follow-up runs.

## How it works

`check_tradingview_parity` accepts a Pine v6 script and a TradingView Strategy Tester trade-list export in CSV or base64-encoded XLSX form. You also provide the chart ticker, timeframe, range start, and timezone. PineForge runs the script on the corresponding supported market and grades the resulting trade list against the export. The response includes a parity tier, thresholds, matched and unmatched counts, the first differing trades, diagnostic hints, and a timezone check.

The hosted engine runs in a sandboxed Cloudflare Container for backtests and parity checks. `engine_info` reports its mode, baked-in status, and version. `list_symbols` searches symbols available from the PineForge data API. `list_engine_params` documents strategy header overrides and runtime arguments without executing a backtest.

Before writing or debugging a strategy, use `list_coverage_topics`, `get_coverage_topic`, or `check_pine_feature`. These tools identify supported, partial, transpiler-handled, and unsupported Pine features. This matters because some constructs may compile but have no effect; for example, the provided catalog notes that plots, tables, and alerts do not produce effects, while line, box, and label objects can be read by a strategy.

## Setup and configuration

The hosted endpoint is `https://mcp.pineforge.dev/mcp` and uses Streamable HTTP, so no local engine, Docker daemon, data file, or API key is required. Configure that endpoint in an MCP client that supports Streamable HTTP. The repository README also documents Claude Desktop, Cursor, and Claude Code client configurations, but those examples refer to the local `@pineforge/backtest-mcp` package and its bundled container rather than this hosted listing.

Backtest inputs can override named `input.*()` values through `inputs`; the key is the input's named-value argument. `overrides` changes supported `strategy(...)` header fields. `list_engine_params` provides the accepted keys and types. Call `check_quota` to inspect weekly usage; it does not consume quota. `join_waitlist` accepts an email and optional use case for notifications about the API-key tier and PineForge Studio.

## Limitations and notes

The hosted service covers crypto markets only: Binance, Bybit, and OKX spot and USDT-perpetual markets, plus Coinbase spot. Free-tier requests cover the last 365 days, and the newest published bar is typically about one hour behind real time. Backtest ranges outside the available history are clamped with warnings, while parity requests outside the hosted range are refused. Backtests have a 50,000-bar output cap.

`backtest_pine` and `check_tradingview_parity` share a fixed weekly per-IP quota and also consume a monthly compute budget. Exceeding the weekly quota causes refusal; reaching the compute budget returns `ok: false`. Other tools are free of that quota but remain subject to per-IP rate limits. The hosted service supports one backtest configuration per call and does not provide sweeps. For unsupported markets or ranges, the material points to the local MCP package with user-supplied bars instead. The implementation covers a subset of Pine v6, so feature coverage should be checked before relying on a function or namespace.

_Full upstream README: https://allmcps.com/mcp/pineforge-4pass-pineforge-codegen-mcp/readme_

