MCPcopy Create free account
hub / github.com/cloudflare/mcp / runExecute

Function runExecute

tests/executor.test.ts:28–41  ·  view source on GitHub ↗

Run an `execute` tool call whose code hits `path`, with MSW returning `body`.

(path: string, body: unknown, init?: ResponseInit)

Source from the content-addressed store, hash-verified

26
27/** Run an `execute` tool call whose code hits `path`, with MSW returning `body`. */
28async function runExecute(path: string, body: unknown, init?: ResponseInit): Promise<string> {
29 mockIdentityProbe({ accounts: [{ id: ACCOUNT_ID, name: 'Acc' }] })
30 server.use(
31 http.get(`${API_BASE}${path}`, () =>
32 typeof body === 'string'
33 ? new HttpResponse(body, init)
34 : HttpResponse.json(body as object, init)
35 )
36 )
37 const result = await callTool(API_TOKEN, 'execute', {
38 code: `async () => cloudflare.request({ method: "GET", path: "${path}" })`
39 })
40 return toolText(result)
41}
42
43describe('codemode tool titles', () => {
44 it('exposes a title on the execute tool', async () => {

Callers 1

executor.test.tsFile · 0.70

Calls 5

mockIdentityProbeFunction · 0.90
callToolFunction · 0.90
toolTextFunction · 0.90
jsonMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected