execute/search return formatter errors for non-JSON sandbox results
Maintainers usually reply within 1 day
@mattzcarey is already working on this.
Since Sep 7, 2026.
Assessment
This issue has not been assessed yet.
Description
Current behavior
execute and search can return JavaScript values that cross the Worker RPC boundary successfully but are not JSON-stringifiable. The shared response formatter then throws and turns a successful sandbox program into an MCP tool error.
Confirmed real-tool examples:
async () => {}
async () => 1n
async () => { const x = {}; x.self = x; return x }
Observed errors include:
Error: Cannot read properties of undefined (reading 'length')
Error: Do not know how to serialize a BigInt
Error: Converting circular structure to JSON
Reproduction / evidence
Reproduced through the real MCP tool path on the current branch state using Node 22.23.2. Each value fails through both execute and search.
The direct root cause is in src/truncate.ts: every non-string goes through JSON.stringify(content, null, 2), then the result is treated as a string. undefined produces no string; BigInt and cyclic objects make JSON serialization throw.
Existing truncation tests cover strings, objects, large values, empty string, null, and arrays, but not these structured-clone values.
Expected behavior
A sandbox program that completes successfully should produce a valid MCP text result (using a deliberate representation for values JSON cannot encode), rather than an internal response-formatting exception.
Likely scope
This appears narrowly fixable in response formatting plus regression coverage. It should not require auth/token, deployment, dependency, or OpenAPI pipeline changes.
Duplicate / ownership check
I searched open/closed issues and PRs for the exact errors, truncateResponse, undefined/no-return, BigInt, and circular-result behavior and did not find a matching report or active fix. Issue #68 is broader model-evaluation work and does not appear to cover this formatter defect.
If this is a useful fix, I can take it; assignment or maintainer direction would be appreciated before I implement it.
- Dominant language
- TypeScript
- Stars
- 972
- Forks
- 143
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 54
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/mcp
-
[Connection guide] Claude CodePossibly taken @umeraamir69 claimed this 5 days ago. Openenhancement good first issue
Difficulty 1/5 Under an hour Newbie friendliness 72/100
cloudflare/mcp#39 · 6 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
ChatGPT Web OAuth fails: Client metadata is temporarily unavailable (503)Possibly taken @mattzcarey claimed this 2 days ago. Openbug
cloudflare/mcp#329 · 1 assignee ·
Maintainers usually reply within 1 day
-
R2 JPEG GET returns lossy UTF-8 text instead of binary bytesPossibly taken @mattzcarey claimed this 4 days ago. Openbug
cloudflare/mcp#322 · 1 assignee ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
cloudflare/mcp#320 ·
Maintainers usually reply within 1 day
-
Track Codex and ChatGPT step-up: they need the challenge in the tool result, not the spec's 403Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 25/100
cloudflare/mcp#298 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
a10y a10y-audit ai-driven-qa claude
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
linagora/twake-directory-manager#219 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
0️⃣ phase/new
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Pulse v7: buildPreferencesFromTelos() bypasses telosSectionOrFile(), renders empty on unified-TELOS installsPossibly taken @zephyr91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
danielmiessler/LifeOS#2393 ·
Maintainers usually reply within 4 days