tradeblocks-mcp 1.3.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@ Model Context Protocol (MCP) server for options trading analysis. Works with Cla
4
4
 
5
5
  ## Features
6
6
 
7
- - **34 MCP tools** for comprehensive trading analysis
7
+ - **Comprehensive MCP tools** for trading analysis
8
8
  - **SQL analytics layer** - `run_sql` for arbitrary queries, `describe_database` for schema discovery
9
9
  - **Two transport modes**: stdio (CLI tools) and HTTP (web platforms)
10
10
  - **Block-based data organization** - each folder is a trading strategy
@@ -122,28 +122,22 @@ See [Gemini CLI MCP documentation](https://geminicli.com/docs/tools/mcp-server/)
122
122
 
123
123
  ### Web Platforms (ChatGPT, Google AI Studio, Julius)
124
124
 
125
- Web AI platforms require HTTP transport with an ngrok tunnel:
125
+ Web AI platforms require HTTP transport with a publicly reachable URL:
126
126
 
127
- **Terminal 1:** Start HTTP server
128
127
  ```bash
129
128
  tradeblocks-mcp --http ~/Trading/backtests
130
129
  ```
131
130
 
132
- **Terminal 2:** Expose via ngrok
133
- ```bash
134
- ngrok http 3100
135
- ```
136
-
137
- Then add the ngrok URL (`https://xxx.ngrok.io/mcp`) to your platform's MCP settings.
131
+ Then expose port 3100 however you prefer (ngrok, Cloudflare Tunnel, reverse proxy, Docker on a server, etc.) and add the URL (`https://your-host/mcp`) to your platform's MCP settings.
138
132
 
139
- See [Web Platforms Guide](docs/WEB-PLATFORMS.md) for detailed setup instructions.
133
+ See [Web Platforms Guide](docs/WEB-PLATFORMS.md) for platform-specific setup, or [Docker Deployment](#docker-deployment) for running on a remote server.
140
134
 
141
135
  ## Transport Modes
142
136
 
143
137
  | Mode | Flag | Use Case | Platforms |
144
138
  |------|------|----------|-----------|
145
139
  | stdio | (default) | Local CLI tools | Claude Desktop, Claude Code, Codex CLI, Gemini CLI |
146
- | HTTP | `--http` | Web platforms via ngrok | ChatGPT, Google AI Studio, Julius AI |
140
+ | HTTP | `--http` | Web platforms, remote servers | ChatGPT, Google AI Studio, Julius AI |
147
141
 
148
142
  ```bash
149
143
  # stdio mode (default)
@@ -154,6 +148,70 @@ tradeblocks-mcp --http ~/backtests
154
148
  tradeblocks-mcp --http --port 8080 ~/backtests
155
149
  ```
156
150
 
151
+ ## Docker Deployment
152
+
153
+ Run the MCP server in a container for remote/server deployments.
154
+
155
+ ### Pre-built image (recommended)
156
+
157
+ ```bash
158
+ docker run -d -p 3100:3100 -v ./data:/data --env-file .env ghcr.io/davidromeo/tradeblocks-mcp:latest
159
+ ```
160
+
161
+ Or with docker compose, set the image in `docker-compose.yml`:
162
+ ```yaml
163
+ services:
164
+ tradeblocks:
165
+ image: ghcr.io/davidromeo/tradeblocks-mcp:latest
166
+ ```
167
+
168
+ ### Build from source
169
+
170
+ ```bash
171
+ cd packages/mcp-server
172
+ npm run build # build on host (resolves workspace deps)
173
+ docker build -t tradeblocks-mcp .
174
+ docker compose up -d
175
+ ```
176
+
177
+ Place your block folders (each containing CSV files) in the `data/` directory. The container runs in HTTP mode on port 3100 by default. See [Authentication](#authentication) below for configuring credentials.
178
+
179
+ Connect any MCP client to `http://<your-host>:3100/mcp`. How you expose this endpoint (reverse proxy, tunnel, VPN, etc.) is up to you.
180
+
181
+ ## Authentication
182
+
183
+ HTTP mode includes **OAuth 2.1 with PKCE** authentication, enabled by default. MCP clients that support OAuth (Claude, ChatGPT, etc.) handle the flow automatically — users see a login prompt on first connection.
184
+
185
+ ### Setup
186
+
187
+ Copy `.env.example` to `.env` and configure:
188
+
189
+ ```env
190
+ # Required for HTTP mode
191
+ TRADEBLOCKS_USERNAME=admin
192
+ TRADEBLOCKS_PASSWORD=changeme
193
+ TRADEBLOCKS_JWT_SECRET= # generate with: openssl rand -hex 32
194
+
195
+ # Optional
196
+ TRADEBLOCKS_PORT=3100 # HTTP port (default: 3100)
197
+ TRADEBLOCKS_JWT_EXPIRY=24h # Token lifetime (default: 24h)
198
+ TRADEBLOCKS_ISSUER_URL= # Public URL when behind a reverse proxy (e.g. https://mcp.yourdomain.com)
199
+
200
+ # DuckDB tuning
201
+ DUCKDB_THREADS=2
202
+ DUCKDB_MEMORY_LIMIT=512MB
203
+ ```
204
+
205
+ ### Disabling Auth
206
+
207
+ If the server is behind a reverse proxy or tunnel that already handles authentication:
208
+
209
+ ```bash
210
+ tradeblocks-mcp --http --no-auth ~/backtests
211
+ ```
212
+
213
+ Or set `TRADEBLOCKS_NO_AUTH=true` in `.env`.
214
+
157
215
  ## Agent Skills
158
216
 
159
217
  For guided conversational workflows, install the bundled agent skills:
@@ -245,6 +303,17 @@ backtests/
245
303
  | `run_sql` | Execute SQL queries against trades and market data |
246
304
  | `describe_database` | Schema discovery with table info and example queries |
247
305
 
306
+ ### Market Data Tools
307
+ | Tool | Description |
308
+ |------|-------------|
309
+ | `import_market_csv` | Import market data CSV with column mapping |
310
+ | `import_from_database` | Import from external DuckDB databases |
311
+ | `enrich_market_data` | Compute ~40 derived indicators from raw OHLCV |
312
+ | `enrich_trades` | Enrich trades with market context (lookahead-free) |
313
+ | `analyze_regime_performance` | Analyze P&L by market regime |
314
+ | `suggest_filters` | Suggest trade filters based on market conditions |
315
+ | `calculate_orb` | Opening range breakout analysis from intraday bars |
316
+
248
317
  ### Import Tools
249
318
  | Tool | Description |
250
319
  |------|-------------|
@@ -268,21 +337,25 @@ npm run mcpb:pack
268
337
 
269
338
  ## Market Data (Optional)
270
339
 
271
- For market context (VIX regimes, intraday timing, gap analysis), export underlying/VIX data from TradingView using the included PineScript indicators. The MCP server syncs these CSVs into DuckDB automatically.
340
+ For market context (VIX regimes, intraday timing, gap analysis), import market data from TradingView exports using MCP tools:
341
+
342
+ 1. **Export** from TradingView (any chart: SPX daily, VIX daily, SPX 5-min, etc.)
343
+ 2. **Import** via `import_market_csv` with a column mapping
344
+ 3. **Enrich** via `enrich_market_data` to compute ~40 derived indicators
272
345
 
273
- Supported `_marketdata` filename patterns:
274
- - `<ticker>_daily.csv` (example: `spx_daily.csv`, `msft_daily.csv`)
275
- - `<ticker>_15min.csv` (example: `spx_15min.csv`, `msft_15min.csv`)
276
- - `<scope>_vix_intraday.csv` or `vix_intraday.csv` (global scope `ALL`)
346
+ No Pine Scripts needed — TradingView exports raw OHLCV natively.
277
347
 
278
- Market tables are keyed by `(ticker, date)`, and trade enrichment joins on ticker + date.
348
+ Market data lives in a separate `market.duckdb` (configurable via `MARKET_DB_PATH` or `--market-db`). Tables:
349
+ - `market.daily` — Daily OHLCV + enriched indicators (keyed by `ticker, date`)
350
+ - `market.context` — VIX / volatility context (keyed by `date`)
351
+ - `market.intraday` — Intraday bars at any resolution (keyed by `ticker, date, time`)
279
352
 
280
- See [scripts/README.md](../../scripts/README.md) for setup instructions, field documentation, and the 3 PineScript indicators.
353
+ See [scripts/README.md](../../scripts/README.md) for import examples and column mapping reference.
281
354
 
282
355
  ## Related
283
356
 
284
357
  - [Usage Guide](docs/USAGE.md) - Detailed usage examples and workflows
285
358
  - [Web Platforms Guide](docs/WEB-PLATFORMS.md) - Connect to ChatGPT, Google AI Studio, Julius
286
359
  - [Agent Skills](../agent-skills/README.md) - Conversational workflows for guided analysis
287
- - [Market Data Scripts](../../scripts/README.md) - TradingView PineScript indicators for SPX/VIX data
360
+ - [Market Data Import](../../scripts/README.md) - Import workflow and column mapping reference
288
361
  - [Main Application](../../README.md) - Web-based UI for TradeBlocks
@@ -22,9 +22,9 @@ Skills do not execute code directly - they require the TradeBlocks MCP server fo
22
22
  | `tradeblocks-health-check` | Strategy health evaluation - metrics, stress tests, risk indicators | `get_statistics`, `run_monte_carlo`, `get_tail_risk` |
23
23
  | `tradeblocks-wfa` | Walk-forward analysis - test parameter robustness on unseen data | `run_walk_forward` |
24
24
  | `tradeblocks-risk` | Risk assessment and position sizing | `calculate_position_sizing`, `get_tail_risk` |
25
- | `tradeblocks-compare` | Performance comparison - backtest vs actual, strategy correlations | `compare_backtest_vs_actual`, `calculate_correlation` |
26
- | `tradeblocks-portfolio` | Portfolio addition decisions - should I add this strategy? | `calculate_correlation`, `get_statistics` |
27
- | `tradeblocks-optimize` | Parameter optimization with overfitting awareness | `list_available_fields`, `aggregate_by_field` |
25
+ | `tradeblocks-compare` | Performance comparison - backtest vs actual, strategy correlations | `compare_backtest_to_actual`, `get_correlation_matrix` |
26
+ | `tradeblocks-portfolio` | Portfolio addition decisions - should I add this strategy? | `get_correlation_matrix`, `get_statistics` |
27
+ | `tradeblocks-optimize` | Parameter optimization with overfitting awareness | `run_sql`, `describe_database` |
28
28
 
29
29
  ## Prerequisites
30
30