RuntimeEval
Evaluate JavaScript expressions in an Observable notebook's runtime, accessing all variables to compute derived values via a return statement. Optionally persist results for later queries.
Instructions
Evaluate an expression in the Observable runtime context, with access to all notebook variables. Must use a return statement. Prefer this over Eval when computing derived values from runtime state. Examples: "return a + b" computes a sum; "return data.filter(d => d.value > 0)" filters a dataset.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"body": "<body>"
},
"name": "RuntimeEval"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | JavaScript code to evaluate. Must use "return" to produce a result. All notebook variables are accessible. | |
| name | No | If provided, the result persists in the runtime as a named variable for subsequent GetValue queries. If omitted, the result is returned and discarded. | |
| notebook | No | Target notebook (URL, path like "index" or "voronoi", or index like "0"). Optional if you've used FocusNotebook or only one notebook is connected. | |
| timeout_ms | No | Maximum time to wait for the value to resolve (default: 10 seconds) |