flox-mcp
OfficialThe lrvx MCP server gives AI agents grounded access to lrvx: discover APIs/docs, scaffold and validate strategies/projects, record/backtest data, analyze AMM/DEX pools, and inspect or control a running engine.
Discover the lrvx surface: overview guidance, full-text docs search, cross-binding symbol lookup, binding/C-API/indicator listings, error-code resolution, event-structure explanations, canonical examples, and indicator suggestions.
Build and verify code: scaffold Python/Node/Codon/QuickJS strategies (bar-driven, trade-driven, hybrid), init research/live/indicator-library projects, statically validate strategies, and check for lookahead bias.
Record and backtest: capture live or historical ccxt data into
.lrvxtapes, run sandboxed Python backtests on CSV datasets, compute indicator outputs, replay time windows, and run parameter what-ifs.Analyze markets and venues: get a guide for building a matching-engine venue, price AMM swaps, route best DEX execution, compute price impact/depth, and replay pool histories or LP positions.
Inspect a live engine: read positions, open orders, PnL, kill-switch state, strategies, strategy state, live indicator values, event logs, and causal decision chains.
Control trading with safety gates: place/cancel orders, cancel all orders, flatten positions, and set/resume the kill switch, using dry-run defaults and live-token gating where applicable.
Implement and run trading strategies via the embedded JavaScript (QuickJS) binding of the FLOX framework. Includes scaffolding support.
Develop and execute trading strategies using Node.js bindings of the FLOX framework. Supports scaffolding and strategy execution.
Run and backtest trading strategies using Python bindings of the FLOX framework. Provides tools for scaffolding strategies, running sandboxed backtests on CSV data, and executing live strategies.
lrvx
lrvx is a framework for building trading systems.
Strategies, backtests, paper trading, and live execution sit behind one toolkit. AI agents discover the surface and drive it end-to-end through an MCP control plane. One strategy class runs backtest, paper, and live. Bindings for Python, Node.js, Codon, embedded JavaScript, and a stable C API.
Documentation is available at docs.lrvx.dev
Related MCP server: TradingMCP
Language bindings
Language | Install | Docs |
Python |
| |
Node.js |
| |
Codon | build from source | |
JavaScript (embedded) | bundled with C++ build | |
C API |
|
All bindings expose the same strategy API, indicators, order books, backtesting, and data I/O. The C API is the integration point for adding support for any other language.
AI companion
lrvx-mcp is a Model Context Protocol server that gives AI coding agents (Cursor, Claude Code, Cline) grounded access to the lrvx surface — symbol lookups across bindings, scaffolders, indicator and backtest tools, full-text doc search.
pip install lrvx-mcpSee the package README for setup and the full tool list.
Connectors
Native exchange connectors (Bybit, Bitget, Hyperliquid, Polymarket) live under connectors/ and build with -DLRVX_BUILD_CONNECTORS=ON. The flag defaults to OFF so a backtest-only or research build doesn't pay the dependency cost. See the connectors README for adapter notes and the optional Polymarket Rust toolchain step.
Venue
Beyond trading on a market, lrvx can be one: the optional venue/ module adds a matching engine and the machinery around it, so many participants can trade against a single order book. See the venue docs.
Build options
The CMake options that gate every optional artefact (bindings, demo, tools, tests, benchmarks, connectors) are catalogued in docs/build/feature-flags.md. Defaults are OFF so a bare cmake -B build produces only the core C++ static library.
Commercial Services
For commercial support, enterprise connectors, and custom development, visit lrvx.dev/services.
Contributing
Contributions are welcome via pull requests.
Please follow the existing structure and naming conventions.
Tests, benchmarks, and documentation should be included where appropriate.
Code style is enforced via clang-format. See contributing guide.
License
lrvx is licensed under the MIT License. See LICENSE for details.
Disclaimer
lrvx is provided "as is" without warranty of any kind, express or implied. The authors are not liable for any damages or financial harm arising from its use, including trading losses or system failures. This software is intended for educational and research purposes. Production use is at your own risk. See DISCLAIMER.md for full legal notice.
Available Tools
38 toolsamm_price_impactA
The depth / slippage table for one AMM pool: the realized average price and price impact for each of a list of trade sizes, exact to the wei. Use this to reason about how large a trade a pool can absorb before quoting. Sizes are human 'NUMBER SYMBOL' strings. Requires the optional lrvx dependency.
Inputs: pool (required), sizes (required).
cancel_allA
Cancel every open order, optionally filtered by symbol. Default dry_run=true. The most common 'panic stop' primitive after set_kill_switch. account is required and gated the same way as place_order: paper scope may only target paper-prefixed accounts.
Inputs: account (required), symbol, dry_run.
cancel_orderA
Cancel one open order by id. Talks HTTP to the local ControlServer. Default dry_run=true. Useful for operator-driven cleanup or panic stop. account is required and gated the same way as place_order: paper scope may only target paper-prefixed accounts.
Inputs: account (required), order_id (required), dry_run.
compute_indicatorA
Run a single lrvx indicator over a list of floats and return the output. Use this to sanity-check an indicator's behaviour on a small price array BEFORE wiring it into a strategy — especially when the indicator has window / period / smoothing parameters whose effect isn't obvious from the name. Input is capped at 1 MiB. Requires the optional lrvx dependency.
Inputs: data (required), name (required).
docs_searchA
Top-k full-text search over the lrvx documentation (how-to guides, reference pages, tutorials, error codes, bindings overviews, explanations). Use this to ground answers about lrvx behavior, configuration, or APIs in the actual docs instead of relying on training data — call it whenever the user asks 'how do I X' / 'what does Y do' / 'where is Z documented'. The index is built from a strict allowlist; private tracker / strategy / author files are NEVER indexed.
Query syntax: plain word lists are AND-matched (every token must appear). Wrap a phrase in double quotes for exact match: "walk forward". FTS5 operators (OR, NEAR, *, parens) pass through.
Canonical workflow queries (run these instead of guessing the canonical path from training data):
• User wants to record market data → docs_search('record tape'). Covers live capture and the ccxt.fetch_ohlcv historical-backfill pattern.
• User asks 'how should I structure a lrvx project' → docs_search('project layout').
• User mentions an exchange / live data → docs_search('ccxt').
• User wants to backtest a strategy on a recorded tape → docs_search('backtest').
• User mentions strategy traces, signals, or .lrvxrun → docs_search('lrvxrun').
Inputs: query (required), k.
explain_decisionA
Walk an event's causal-parent chain back toward the root. Returns the chain in order from the requested event to its root. Use when the user asks 'why did this fill happen' / 'trace the cause of order 42' — the chain shows which signal produced the order, which event triggered the signal, etc.
Inputs: event_id (required), max_depth.
explain_eventA
Describe the fields of a lrvx event struct. Accepts a type name ('LrvxTradeData', 'LrvxBookData', 'LrvxBarData', 'LrvxSymbolContext', 'LrvxSignal') OR a raw event dict; returns each field's name, type, units, and human description. Use when the user asks 'what's in this event'.
Inputs: event, type_name.
flatten_positionsA
Close every open position with opposite-side market orders, optionally filtered by symbol. Default dry_run=true. Use for 'close everything' operator actions or end-of-day flatten. account is required and gated the same way as place_order: paper scope may only target paper-prefixed accounts, and rows the positions accessor tags with a different account are skipped.
Inputs: account (required), symbol, dry_run.
get_event_logA
Query the engine event log (signals emitted, orders placed, fills received, risk checks). Filters AND-compose. Read-only. Use for 'what happened in the last 5 minutes' / 'show me all the signals from ema-trend'. Default limit 100.
Inputs: type, limit, strategy, to_ts_ns, +1 more.
get_exampleA
Return canonical lrvx example code for a topic, filtered optionally by language. Use this when the user asks 'show me how to {backtest|connect to ccxt|wire an indicator}' BEFORE writing fresh code from memory — the bundled examples are CI-validated, your generated code is not. Topics: strategy, connector, indicator, event-handler, risk, backtest. Languages: python, node, codon, cpp.
Inputs: topic (required), language.
get_indicator_valuesA
Return the live values of indicators inside a strategy. Optional name filter narrows to one indicator. Read-only. Use for 'what's the EMA reading' / 'is the RSI overbought now'.
Inputs: strategy (required), name.
get_kill_switchA
Read kill-switch state from the runtime state snapshot. Returns {active, reason, since_ns}. Use this for 'is trading halted' / 'why was the kill switch tripped'. When no engine has written a snapshot, returns the idle response with active=false (there is no live trading to halt). Read-only — to flip the switch use set_kill_switch.
Inputs: state_path.
get_open_ordersA
Read in-flight orders from the runtime state snapshot. Use this for 'what orders are pending' / 'do I have anything sitting on Bybit'. Optional substring filter matches against symbol_name or strategy. Returns the engine_not_running idle response when no snapshot is present yet (no error). Read-only.
Inputs: filter, state_path.
get_pnlA
Read PnL totals plus per-strategy breakdown from the runtime state snapshot. Use this for 'what's my PnL' / 'how is strategy X doing today'. Returns realized + unrealized + fees per strategy. Returns the engine_not_running idle response when no snapshot is present yet (no error). Read-only.
Inputs: strategy, state_path.
get_positionsA
Read positions from a running lrvx engine via its runtime state snapshot. Use this when the user asks 'what's in my positions' / 'show me the BTC position' / 'is strategy X long or short'. Returns a JSON object {snapshot_age_ms, data:[{account, strategy, symbol_id, symbol_name, qty, avg_price, unrealized_pnl}, ...]}. Snapshot path is LRVX_RUNTIME_STATE env var or the passed state_path; the user app is responsible for writing the snapshot. When no engine has written a snapshot yet, returns {engine: 'not_running', data: [], hint: ...} instead of an error — that's a normal pre-engine state, not a problem to surface to the user. Read-only — never modifies state.
Inputs: account, strategy, state_path.
get_strategy_stateA
Return one strategy's current state as a JSON dict — params, position view, last decisions. Read-only. Use when the user asks 'what does strategy X think right now' / 'show me state for ema-trend'.
Inputs: name (required).
init_projectA
Create a new lrvx project from a bundled template. Thin wrapper around the canonical lrvx new CLI — the CLI stays the source of truth, this tool only makes it discoverable from MCP. Use when the user asks 'set up a new lrvx project' / 'I want to scaffold a research notebook' / 'start a live trading bot'. Three templates ship with lrvx: research (notebook + sample data + main.py), live (CCXT broker + dry-run safety harness), indicator-library (standalone indicator package with tests). Result includes the CLI output and a Next steps section with docs_search queries.
Inputs: template (required), project_name (required), target_dir.
list_bindingsA
Enumerate the public exports of one lrvx binding surface (C-API / Python / Node / Codon / QuickJS). Use this when the user asks 'what does the {Python|Node|Codon} binding expose?' or when they want to browse a binding before picking a symbol. Substring filter is case-insensitive.
Inputs: language (required), limit, filter.
list_capi_functionsA
Search the lrvx C-API surface from the committed ABI snapshot. Returns name + return type + parameter types for every exported lrvx_* function. Use when the user is writing FFI code (Codon, QuickJS, Rust cgo, ctypes) or asks 'what C symbols can I call'.
Inputs: limit, filter.
list_indicatorsA
List every indicator exposed by the lrvx Python binding with its class signature, batch function (if any), and shape (single-input scalar, OHLC tuple, multi-output, …). Use this when the user asks 'what indicators does lrvx support' or before suggesting an indicator name.
Inputs: filter.
list_strategiesA
List the strategies the running lrvx engine knows about, with name, status, and the symbols each one subscribes to. Read-only. Use when the user asks 'what's running' / 'which strategies are active'.
Inputs: no named parameters.
lookup_error_codeA
Resolve a lrvx error code (e.g. 'E_SYM_001') to its full Markdown documentation page — fix recipe, common causes, diagnostics. Use whenever a LrvxError is raised in user code; never guess at a fix from the message alone.
Inputs: code (required).
lookup_symbolA
Resolve a lrvx symbol across every surface (C++, C-API, Python, Node, Codon, QuickJS). Methods resolve too, reported as Owner.method. Returns the local name, kind, and signature for each binding that exports it. Use this whenever the user names a struct, function, or indicator and you need to know what it's called in their language — never guess at the cross-language spelling. Accepts any spelling the user knows ('LrvxBarData', 'BarData', 'lrvx_indicator_ema', 'ema', 'Ema'). Filter to one language with the language arg if the user is writing in a specific binding. When the symbol has hand-curated semantic gotchas (silent quantization, ordering preconditions, subscribed-vs-registry distinctions), they appear under a ## Gotchas section in the response.
Inputs: name (required), language.
lrvx_overviewA
Call this FIRST when you don't know which lrvx MCP tool to use. Returns a Markdown narrative of the toolkit organised by category (discovery, building a backtest, live engine inspection, calibration), with canonical workflows for the most common tasks and a recent-additions section. No arguments. Cheap; pure bundled text. Cuts the AI-agent cycles spent rediscovering what the surface is on every fresh session.
Inputs: no named parameters.
lrvx_venue_guideA
Use when the user wants to BUILD A MARKET rather than trade on one: simulate several agents/strategies against one shared order book, model market impact with reacting counterparties, or run a matching engine, clearing ledger, margin/liquidation, market-data feed or venue gateway. Returns a Markdown guide to the optional lrvx venue module (lrvx::venue): headers, order vocabulary, derivatives waterfall, the multi-agent demo, build flag, and verification posture. No arguments. Cheap; pure bundled text. NOT for an ordinary single-strategy backtest over historical data -- use run_backtest.
Inputs: no named parameters.
place_orderA
Place an order through the user's running lrvx engine. Talks HTTP to the local ControlServer the user app embeds; reads URL + bearer token from LRVX_CONTROL_URL and LRVX_CONTROL_TOKEN. Default dry_run=true; the server simulates acceptance without dispatching to the executor. live tier additionally requires an approve_token issued out of band by the operator. Use this for manual hedges or operator-driven order entry.
Inputs: qty (required), side (required), symbol (required), account (required), +5 more.
price_amm_swapA
Price a DEX swap against an AMM pool, exact to the wei, through lrvx's integer curves. Use this to quote a fill or measure price impact on a constant-product (Uniswap v2), Raydium CP (Solana), or Uniswap v3 concentrated-liquidity pool from its on-chain state. Amounts are decimal strings (native wei / lamports), so 256-bit values are lossless. Requires the optional lrvx dependency.
Inputs: pool (required), venue (required), amount_in (required), i, +1 more.
record_dataA
Capture market data into a .lrvx tape. Wraps the canonical recording paths — for mode=live shells out to the lrvx tape record CLI; for mode=historical shells out to scripts/backfill_to_tape.py which uses ccxt's fetch_ohlcv / fetch_trades. Use this when the user asks to 'record some BTC data' / 'pull a month of klines for backtest' / 'tape the last hour of trades'. The result is a .lrvx directory drivable by BacktestRunner.run_tape.
Inputs: mode (required), symbol (required), exchange (required), out_path (required), +5 more.
replay_pool_tapeA
Backtest a DEX position from a recorded pool history. Replays a list of swaps (or decoded Uniswap v2 Swap logs) through the exact curve and returns the price / reserves / LP-value / impermanent-loss / drift series over time. Use this to evaluate an LP position or a trading sequence against a real transcript. Requires the optional lrvx dependency.
Inputs: pool (required), swaps, evm_logs.
replay_windowB
Run a sandbox replay over a time window. The engine side decides what 'replay' means: typical setups use the bundled tape primitives to drive a SimulatedExecutor over a tape slice. Read-only (sandbox-only mutations). Use for 'replay the last hour' / 'rerun this period in sandbox'.
Inputs: strategy, to_ts_ns, from_ts_ns, param_overrides.
route_amm_swapA
Best execution for a DEX swap across a set of AMM pools, exact to the wei. Give it the same notional and several venues (constant-product, Raydium CP, Uniswap v3) and it returns the venue that fills the most, the fill, and a per-venue comparison. Amounts are human 'NUMBER SYMBOL' strings (e.g. '50000 USDC'); each pool carries its token symbols and decimals, so directions are by symbol and a mis-routed swap raises instead of returning a quiet zero. Requires the optional lrvx dependency.
Inputs: amount (required), venues (required), into.
run_backtestA
Run a Python lrvx strategy against a CSV dataset in a sandboxed subprocess (rlimits on CPU / memory / output size + a wall-clock timeout). Use this when the user asks 'try this strategy on my data' or 'does this code actually work'. Treat as MVP sandbox: it caps resources but does NOT isolate the filesystem or network — never aim it at untrusted code outside a developer's own machine. Returns the backtest stats dict as JSON plus any stdout the strategy printed.
Dispatch routing: the worker introspects the strategy class. If on_bar is overridden the dataset is dispatched as real BarEvents through run_bars (CSV columns: ts,open,high,low,close,volume); otherwise the rows are synthesised into trades for on_trade via run_csv. A strategy that overrides neither hook fails loudly.
Inputs: dataset_path (required), strategy_code (required), symbol, wall_timeout_s.
scaffold_strategyA
Return a starter lrvx strategy class that compiles and passes validate_strategy. Use this as the first thing you write when the user asks to 'build a new strategy' — start from this canonical shell, then edit the indicator + signal logic, instead of writing the lrvx bookkeeping (constructor, hook names, signal builder) from memory. language is required — lrvx is polyglot and picking the binding for the user is wrong; ask which language they want first. Supported: python, node, codon, quickjs. Three kinds: bar-driven (TA on bar close), trade-driven (tick-by-tick), hybrid (both). The result includes a Next steps section with docs_search queries for the recording / backtest / layout follow-ups; follow them in order.
Inputs: language (required), kind, name.
set_kill_switchA
Set the engine's kill-switch state. active=true halts all trading; active=false resumes. Default dry_run=true; explicit dry_run=false applies the change. Use for emergency halt and for resuming after manual review. The kill switch is engine-level, not per-account, so only live scope may call this -- paper tokens are refused even with dry_run=false.
Inputs: active (required), reason, dry_run.
suggest_indicatorA
Recommend lrvx indicators for an English description of the user's intent ('trend filter', 'momentum oscillator', 'volatility band', 'mean revert', 'regime test'). Use this when the user describes what they want without naming an indicator — the tool maps phrasing to a ranked shortlist of real lrvx indicators. Pure keyword heuristic; no LLM call. Always confirm shape with list_indicators after picking one.
Inputs: description (required), k.
validate_strategyA
Static-analysis check on a Python lrvx strategy: AST parses, expected hooks present (on_trade / on_bar), no forbidden patterns (eval, exec, import tricks). Use this before running user-authored strategy code. Does NOT execute the code.
Inputs: code (required).
validate_strategy_no_lookaheadA
Static-analysis check for the most common backtest bug: lookahead bias. Walks the strategy code's AST and flags negative .shift(N), forward-index arithmetic like df.iloc[i+1], open-upper slices inside per-bar callbacks, and attribute names that look future-dated (next_*, future_*, lookahead_*). Heuristic, not a proof — false negatives are possible. Run before trusting any backtest result.
Inputs: code (required).
whatifA
Counterfactual replay: same as replay_window plus a strategy-name filter and required param_overrides. Use for 'what if EMA period was 50 instead of 21' / 'show me the PnL if I had used a wider stop'.
Inputs: strategy (required), param_overrides (required), to_ts_ns, from_ts_ns.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 38 tools
Most tools have clearly distinct resource+action targets (place_order vs cancel_order vs flatten_positions; compute_indicator vs get_indicator_values). A few pairs invite confusion: validate_strategy vs validate_strategy_no_lookahead, and the discovery cluster (lookup_symbol, list_bindings, list_capi_functions, lrvx_overview, docs_search) overlap in 'find out about the API' intent. Descriptions do enough work to disambiguate in practice.
Overwhelmingly consistent snake_case verb_noun (get_pnl, list_strategies, place_order, cancel_all). Minor deviations: bare 'whatif' lacks a verb_noun shape, and lrvx_overview / lrvx_venue_guide carry a redundant lrvx_ prefix absent from the rest. Still highly predictable overall.
38 tools is heavy for a single MCP server and sits well past the 25+ threshold. Although the domain (a full polyglot trading framework spanning docs, authoring, backtesting, live control, and AMM pricing) is genuinely broad, the surface is large enough that agents must lean on the overview tool to navigate it.
Coverage is unusually thorough: onboarding/overview, docs/symbol lookup, scaffolding, validation (including lookahead checks), data recording, backtesting, live engine reads (positions, orders, PnL, indicators, log, kill switch), order lifecycle control, replay/counterfactual, and DEX/AMM pricing. No obvious lifecycle gaps or dead ends.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Research-only MCP server: your AI as a quant research desk. 90 tools, no trades, no brokers.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
MCP server exposing the Backtest360 engine API as tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceFull-lifecycle algorithmic trading MCP server. AI strategy generation from plain English, backtesting, live bot deployment to 10+ brokers, portfolio monitoring, and prediction markets. Stocks, options, crypto, futures. 32 tools. Free tier.-
- AlicenseBqualityBmaintenanceOpen-source MCP server for market analysis: screeners, multi-timeframe technical analysis and backtests for crypto, stocks, forex and futures. 39 tools. Hosted version: TradingMCP.375,220MIT
- AlicenseNot gradedqualityDmaintenanceThe most complete AI-powered trading toolkit for Claude and MCP clients, offering backtesting, live sentiment, Yahoo Finance, and 30+ technical analysis tools in one MCP server.MIT
- AlicenseAqualityDmaintenanceAn MCP server that exposes trading analytics — technical indicators, portfolio state, risk metrics, and backtest results — as tools an LLM agent can call.5MIT