Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.55.7

### Fixed — `blockrun_modal` reserves the gateway's new sandbox prices

The gateways now price a create by size as well as lifetime. The flat rate needs
300 seconds or less, at most 1 CPU and at most 1024 MB. Anything else pays the new
hourly rates (CPU $0.25, T4 $4, L4 $4.50, A10G $5, A100 $7, H100 $9), never below
the flat rate. The estimator, budget cap, confirm dialog, tool text and skill now
use the same rule, so `{ gpu: "T4", cpu: 8, memory: 32768, timeout: 300 }` reserves
$0.335 instead of $0.052. The skill's GPU example also no longer sends a custom
image and `setup_commands`, which the gateway refuses.

## 0.55.6

### Fixed — agents are no longer offered Exa's retired `tweet` category
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Package managers have shown install size for decades. Almost no MCP server shows

| Profile | Tools | Context |
|---------|-------|---------|
| `full` *(default)* | 19 | 14,227 |
| `full` *(default)* | 19 | 14,265 |
| `trading` | 8 | 5,471 |
| `media` | 7 | 7,016 |
| `research` | 5 | 2,807 |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.55.6
0.55.7
4 changes: 2 additions & 2 deletions assets/context-cost-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/context-cost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/mcp-schema-overhead.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Written 2026-09-01, verified against `@modelcontextprotocol/sdk` 1.29.0. Numbers

| Profile | Tools | Context |
|---------|-------|---------|
| `full` *(default)* | 19 | 14,227 |
| `full` *(default)* | 19 | 14,265 |
| `trading` | 8 | 5,471 |
| `media` | 7 | 7,016 |
| `research` | 5 | 2,807 |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockrun/mcp",
"version": "0.55.6",
"version": "0.55.7",
"mcpName": "io.github.BlockRunAI/blockrun-mcp",
"description": "BlockRun MCP Server - Give your AI agent web search, deep research, prediction markets, and crypto data. Pay per call from a USDC wallet (Solana or Base) or a BlockRun API key.",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const PROBES: Probe[] = [
{ label: "pm/markets/search", path: "pm/markets/search?q=election", expected: MARKETS_PRICE_USD },

// Body-priced: modal bills off gpu + timeout, NOT the path. A 24h H100 is
// $192 upfront and non-refundable — the case that made this script exist.
// $216 upfront and non-refundable — the case that made this script exist.
{ label: "modal create {} (flat)", path: "modal/sandbox/create", body: {}, expected: estimateModalCost("sandbox/create", {}) },
{ label: "modal create T4 300s", path: "modal/sandbox/create", body: { timeout: 300, gpu: "T4" }, expected: estimateModalCost("sandbox/create", { timeout: 300, gpu: "T4" }) },
{ label: "modal create CPU 1h", path: "modal/sandbox/create", body: { timeout: 3600 }, expected: estimateModalCost("sandbox/create", { timeout: 3600 }) },
Expand Down
38 changes: 18 additions & 20 deletions skills/modal/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ That makes `timeout` the single most expensive field in this MCP:
|---|---|
| `{ timeout: 300 }` | **$0.0110** |
| `{ timeout: 300, gpu: "A100" }` | **$0.2010** |
| `{ timeout: 600, gpu: "A100" }` | **$0.6677** |
| `{ timeout: 86400, gpu: "H100" }` | **$192.0010** |
| `{ timeout: 600, gpu: "A100" }` | **$1.1677** |
| `{ timeout: 300, gpu: "T4", cpu: 8, memory: 32768 }` | **$0.3343** |
| `{ timeout: 86400, gpu: "H100" }` | **$216.0010** |

All four are live-verified quotes. A 24h H100 sandbox costs **$192 upfront, non-refundable**, even if your job finishes in a minute.
A 24h H100 sandbox costs **$216 upfront, non-refundable**, even if your job finishes in a minute.

**So: ask for the time you need, not a safe-looking ceiling.** Need 20 minutes of H100? `timeout: 1200` is $2.67, not $192. Keep `timeout ≤ 300` and you stay on the flat rate entirely.
**So: ask for the time you need, not a safe-looking ceiling.** Need 20 minutes of H100? `timeout: 1200` is $3.00, not $216. Keep `timeout ≤ 300`, `cpu ≤ 1` and `memory ≤ 1024` and you stay on the flat rate.

## How to Call from MCP

```ts
// 1. Create — timeout: 300 keeps you on the FLAT rate ($0.0110, or $0.2010 with A100).
// Anything above 300 bills hourly for the full requested lifetime, no refund.
// Anything above 300, or above 1 CPU or 1024 MB, bills hourly for the full requested lifetime, no refund.
blockrun_modal({ path: "sandbox/create", body: {
image: "python:3.11",
gpu: "A100",
Expand All @@ -69,14 +70,14 @@ blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: "sb_abc..." } })

| Path | Method | Body | Price |
|---|---|---|---|
| `sandbox/create` | POST | `{ image?, timeout?, cpu?, memory?, gpu?, setup_commands? }` | **depends on `timeout` + `gpu` — see below** |
| `sandbox/create` | POST | `{ image?, timeout?, cpu?, memory?, gpu?, setup_commands? }` | **depends on `timeout`, `gpu`, `cpu` and `memory` — see below** |
| `sandbox/exec` | POST | `{ sandbox_id, command: ["python","-c","..."], timeout? }` | $0.0020 |
| `sandbox/status` | POST | `{ sandbox_id }` | $0.0020 |
| `sandbox/terminate` | POST | `{ sandbox_id }` | $0.0020 |

### `sandbox/create` pricing is bimodal

**`timeout ≤ 300s` — flat rate, charged once:**
**`timeout ≤ 300s`, `cpu ≤ 1` and `memory ≤ 1024` — flat rate, charged once:**

| gpu | price |
|---|---|
Expand All @@ -87,20 +88,19 @@ blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: "sb_abc..." } })
| `A100` | $0.2010 |
| `H100` | $0.4010 |

**`timeout > 300s` — per-hour × the full requested lifetime, upfront, no refund:**
**Anything longer or larger — per-hour × the full requested lifetime, never below the flat rate, upfront, no refund:**

| gpu | per hour | 1h | 24h (max) |
|---|---|---|---|
| *(none, CPU)* | $0.10 | $0.1010 | $2.4010 |
| `T4` | $1.50 | $1.5010 | $36.0010 |
| `L4` | $2.00 | $2.0010 | $48.0010 |
| `A10G` | $2.50 | $2.5010 | $60.0010 |
| `A100` | $4.00 | $4.0010 | $96.0010 |
| `H100` | $8.00 | $8.0010 | **$192.0010** |
| *(none, CPU)* | $0.25 | $0.2510 | $6.0010 |
| `T4` | $4.00 | $4.0010 | $96.0010 |
| `L4` | $4.50 | $4.5010 | $108.0010 |
| `A10G` | $5.00 | $5.0010 | $120.0010 |
| `A100` | $7.00 | $7.0010 | $168.0010 |
| `H100` | $9.00 | $9.0010 | **$216.0010** |

Hours are exact, not rounded up — `timeout: 1800` on `A100` is 0.5h = $2.0010. Every figure above includes the $0.001 flat transaction fee. Max `timeout` is 86400 (24h).
Hours are exact, not rounded up — `timeout: 1800` on `A100` is 0.5h = $3.5010. Every figure above includes the $0.001 flat transaction fee. Max `timeout` is 86400 (24h).

One quirk worth knowing: `timeout: 300` costs $0.0110 (flat) but `timeout: 301` costs $0.0094 (CPU-hourly) — just past the cliff is briefly *cheaper* on CPU. It stops being cheaper at 360s.

## Field Reference

Expand All @@ -109,7 +109,7 @@ One quirk worth knowing: `timeout: 300` costs $0.0110 (flat) but `timeout: 301`
| `image` | `python:3.11` | Any public Docker image. `nvidia/cuda:12-runtime` if you bring GPU code. |
| `timeout` | 300 | **BILLED lifetime in seconds — charged upfront for the full amount, never refunded.** NOT idle eviction: you pay for what you ask for, not what you use. `≤300` = flat rate; `>300` switches to per-hour billing (see the tables above). Max 86400 (24h). This is the field that turns a $0.01 sandbox into a $192 one. |
| `cpu` | 1 | CPU cores |
| `memory` | 1024 | Memory in MB |
| `memory` | 512 | Memory in MB |
| `gpu` | none | `T4` / `L4` / `A10G` / `A100` / `H100` — those five only. Anything else is rejected: `{"gpu":"A100-80GB"}` returns HTTP 400 *"Unsupported GPU type. Allowed: T4, L4, A10G, A100, H100"*. Drives the price hard — see the tables above. |
| `setup_commands` | `[]` | Shell commands run once during sandbox provisioning |
| `command` (exec) | required | Array form: `["python","-c","print(2+2)"]` |
Expand All @@ -132,11 +132,9 @@ await blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: sb.sandbox

```ts
blockrun_modal({ path: "sandbox/create", body: {
image: "pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime",
gpu: "A100",
timeout: 1200,
memory: 16384,
setup_commands: ["pip install --quiet transformers accelerate"]
memory: 16384
}})
```
Then `sandbox/exec` with your inference command.
Expand Down
46 changes: 28 additions & 18 deletions src/tools/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ import type { BudgetState } from "../types.js";
// sandbox/create is priced off the BODY, not the path. Mirrors
// getModalCreatePricing() in the gateway's src/lib/modal.ts:
//
// timeout <= 300s -> flat rate: CPU $0.01, or the GPU tier below
// timeout > 300s -> hourly: rate x (timeout/3600), EXACT (not rounded up),
// charged upfront for the full requested lifetime
// with NO refund on early terminate
// timeout <= 300s, cpu <= 1 and memory <= 1024 MB
// -> flat rate: CPU $0.01, or the GPU tier below
// anything else -> hourly: rate x (timeout/3600), EXACT (not rounded up),
// never below the flat rate, charged upfront for
// the full requested lifetime with NO refund on
// early terminate
//
// Estimating on the path alone reserved a flat $0.01 for every create. Verified
// live against the payment-required header:
//
// { timeout: 86400, gpu: "H100" } -> charged $192.0020 (reserved $0.012 — 16,000x short)
// { timeout: 3600, gpu: "A100" } -> charged $4.0020
// { timeout: 86400, gpu: "H100" } -> charged $192.0020 (reserved $0.012 — 16,000x short; old rates)
// { timeout: 3600, gpu: "A100" } -> charged $4.0020 (old rates)
// { timeout: 300 } -> charged $0.0120
//
// A $1 agent cap could settle $192 of non-refundable spend. Keep these tables in
Expand All @@ -54,9 +56,11 @@ const MODAL_OPERATION_PRICE_USD = 0.001;
const MODAL_GPU_CREATE_PRICE_USD = new Map<string, number>([
["T4", 0.05], ["L4", 0.08], ["A10G", 0.1], ["A100", 0.2], ["H100", 0.4],
]);
const MODAL_CPU_HOURLY_PRICE_USD = 0.1;
const MODAL_FLAT_RATE_MAX_CPU = 1;
const MODAL_FLAT_RATE_MAX_MEMORY_MB = 1024;
const MODAL_CPU_HOURLY_PRICE_USD = 0.25;
const MODAL_GPU_HOURLY_PRICE_USD = new Map<string, number>([
["T4", 1.5], ["L4", 2.0], ["A10G", 2.5], ["A100", 4.0], ["H100", 8.0],
["T4", 4.0], ["L4", 4.5], ["A10G", 5.0], ["A100", 7.0], ["H100", 9.0],
]);
const MODAL_GPU_TIERS = [...MODAL_GPU_HOURLY_PRICE_USD.keys()];

Expand Down Expand Up @@ -107,13 +111,13 @@ export function estimateModalCost(path: string, body?: unknown): number {
// a single invisible character moved the most expensive call this server can
// make into the cheapest tier: `sandbox/cre<TAB>ate` reserved $0.003 (fetch
// deletes the tab, so the gateway still routed and billed a real create — up
// to $192.00, non-refundable), and $0.003 clears every budget cap there is.
// to $216.00, non-refundable), and $0.003 clears every budget cap there is.
// `%63reate` did the same via the router's own percent-decode. This is the
// shared helper `hasPathTraversal` has always used; modal was the one price
// table that never adopted it. See test/modal-cost.test.ts.
if (!normalizeClassifyPath(path).includes("sandbox/create")) return withTxFee(MODAL_OPERATION_PRICE_USD);

const o = body && typeof body === "object" ? (body as { gpu?: unknown; timeout?: unknown }) : {};
const o = body && typeof body === "object" ? (body as { gpu?: unknown; timeout?: unknown; cpu?: unknown; memory?: unknown }) : {};
// Trimmed, as the gateway prices it — see normalizeModalCreateBody. The
// handler sends a body normalised the same way; this is belt-and-braces so
// the estimator is right even for a caller that skipped the handler.
Expand All @@ -124,17 +128,23 @@ export function estimateModalCost(path: string, body?: unknown): number {
? o.timeout
: MODAL_DEFAULT_CREATE_TIMEOUT_SECONDS;

if (seconds > MODAL_FLAT_RATE_MAX_SECONDS) {
// Size is priced too: absent means the gateway's small default. A non-number
// never reaches a charge, the gateway 400s it before payment.
const cpu = typeof o.cpu === "number" ? o.cpu : 1;
const memory = typeof o.memory === "number" ? o.memory : 512;
const flatPrice = (gpu !== undefined ? MODAL_GPU_CREATE_PRICE_USD.get(gpu) : undefined) ?? MODAL_CREATE_PRICE_USD;

if (seconds > MODAL_FLAT_RATE_MAX_SECONDS || cpu > MODAL_FLAT_RATE_MAX_CPU || memory > MODAL_FLAT_RATE_MAX_MEMORY_MB) {
// An absent gpu is the CPU rate — same as the gateway's
// `opts.gpu && opts.gpu in TABLE ? TABLE[gpu] : CPU_RATE`, which runs on
// the trimmed value. An unknown gpu also falls back here, but only so the
// estimator stays total: the handler refuses it before the reserve
// (unsupportedModalGpu), and the gateway 400s it before payment.
const hourly = gpu !== undefined ? MODAL_GPU_HOURLY_PRICE_USD.get(gpu) : undefined;
return withTxFee((hourly ?? MODAL_CPU_HOURLY_PRICE_USD) * (seconds / 3600));
// Floored at the flat rate, as the gateway does: large and short is not cheaper.
return withTxFee(Math.max(flatPrice, (hourly ?? MODAL_CPU_HOURLY_PRICE_USD) * (seconds / 3600)));
}
const flat = gpu !== undefined ? MODAL_GPU_CREATE_PRICE_USD.get(gpu) : undefined;
return withTxFee(flat ?? MODAL_CREATE_PRICE_USD);
return withTxFee(flatPrice);
}

// Modal sandbox/exec is synchronous — the HTTP call stays open for the whole
Expand Down Expand Up @@ -162,12 +172,12 @@ export function registerModalTool(server: McpServer, budget: BudgetState): void
Use when you need: a clean ephemeral environment, GPU access (T4/L4/A10G/A100/H100 — those five only), or a safer place for untrusted code. Prefer local tools for normal repo work.

⚠️ \`timeout\` IS THE BILLED LIFETIME — charged upfront in full, NEVER refunded. It is not an idle timeout: you pay for the time you ASK for, not the time you use, and terminating early refunds nothing. Ask for what you need, not a safe-looking ceiling.
- timeout ≤ 300s → flat: $0.0120 CPU · $0.0520 T4 · $0.0820 L4 · $0.1020 A10G · $0.2020 A100 · $0.4020 H100
- timeout > 300s → PER-HOUR × the full requested lifetime: $0.10/h CPU · $1.50 T4 · $2.00 L4 · $2.50 A10G · $4.00 A100 · $8.00/h H100
e.g. { timeout: 600, gpu: "A100" } = $0.6687 · { timeout: 86400, gpu: "H100" } = $192.00
- timeout ≤ 300s, cpu ≤ 1 and memory ≤ 1024 → flat: $0.0120 CPU · $0.0520 T4 · $0.0820 L4 · $0.1020 A10G · $0.2020 A100 · $0.4020 H100
- anything longer or larger → PER-HOUR × the full requested lifetime, never below flat: $0.25/h CPU · $4.00 T4 · $4.50 L4 · $5.00 A10G · $7.00 A100 · $9.00/h H100
e.g. { timeout: 600, gpu: "A100" } = $1.1687 · { timeout: 300, gpu: "T4", cpu: 8 } = $0.3353 · { timeout: 86400, gpu: "H100" } = $216.00

Common paths (all POST):
- sandbox/create — body: { image?, timeout?, cpu?, memory?, gpu?, setup_commands? } (see above — $0.0120 to $192.00)
- sandbox/create — body: { image?, timeout?, cpu?, memory?, gpu?, setup_commands? } (see above — $0.0120 to $216.00)
- sandbox/exec — body: { sandbox_id, command: ["python","-c","..."], timeout? } ($0.0030)
- sandbox/status — body: { sandbox_id } ($0.0030)
- sandbox/terminate — body: { sandbox_id } ($0.0030)
Expand Down
Loading
Loading