Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-mcp-sandbox): keep raw facade error text out of sandboxedTool errors #2283 (GitHub #2284)

Mergedtanstack-sourcemerged 2 commits intomain fromfactory/issue-2281merged by AlemTuzlak View on GitHub

Showing 4 changed files with 20 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/sandboxed-tool-error-cause.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-mcp-sandbox': patch
+---
+​
+`sandboxedTool()` no longer sends raw facade error text to the MCP client. A blocked run now throws `sandboxed tool "<name>" blocked: the snippet failed` or `...: a sandbox limit was hit`, the same pattern `sandboxedChatTool()` uses. The raw message, which can carry downstream detail such as a database host name or a rejected user, stays in the audit record and on `error.cause` for host logs.
2 additions and 0 deletionsdocs/mcp/server-sandboxed-tools.mdModified
View file
@@ -170,6 +170,8 @@
​
The snippet source must match `snippetHash`, so a changed snippet with an unchanged manifest is refused at startup.
​
+A blocked run throws, so the MCP client gets a normal tool error. The message names only the kind of stop: `sandboxed tool "<name>" blocked: the snippet failed` or `...: a sandbox limit was hit`. The raw message can carry facade internals, such as a database host name. It stays in the audit record and on `error.cause`, so log it on the host.
+​
## Limits
​
`limits` is the budget for one run. The wrapper stops a run that goes past any of them:
13 additions and 1 deletionpackages/ai-mcp-sandbox/src/sandboxed-tool.tsModified
View file
@@ -71,6 +71,12 @@
* Turn a signed snippet + manifest into a plain `ServerTool` that runs the
* snippet inside an isolate, capability-scoped per caller. Drops straight into
* `createMCPServer({ tools: [...] })` alongside trusted tools.
+ *
+ * A blocked run (timeout, injected-call limit, a thrown error such as an
+ * undefined facade, oversized result) throws, so the MCP client sees a normal
+ * tool error. The message the client sees names only the kind of stop; the raw
+ * text, which can carry facade internals, goes to the audit record and to