Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

execute/search return formatter errors for non-JSON sandbox results

Open
#208 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@mattzcarey is already working on this.

Since Sep 7, 2026.

  • #214 by @MegDude — closed without merging
  • #280 by @MauroDruwel — open

Assessment

This issue has not been assessed yet.

Description

bug

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/mcp

All issues in cloudflare/mcp

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.