MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / execute

Method execute

src/tools/browser/tools.ts:257–268  ·  view source on GitHub ↗
(args: z.infer<typeof EvaluateArgs>, _ctx: ToolContext)

Source from the content-addressed store, hash-verified

255 argsSchema = EvaluateArgs;
256
257 async execute(args: z.infer<typeof EvaluateArgs>, _ctx: ToolContext): Promise<ToolResult> {
258 try {
259 const s = await getSession();
260 // Wrap so the user can use `return` naturally in their script.
261 const fn = new Function('arg', args.script);
262 const result = await s.page.evaluate(fn.toString(), args.arg);
263 const formatted = typeof result === 'object' ? JSON.stringify(result, null, 2) : String(result);
264 return { content: `Result:\n${formatted.slice(0, 5000)}${formatted.length > 5000 ? '\n…[truncated]' : ''}` };
265 } catch (e: any) {
266 return { content: `[BROWSER_ERROR] evaluate failed: ${e?.message ?? String(e)}`, isError: true };
267 }
268 }
269}
270
271const GetTextArgs = z.object({

Callers

nothing calls this directly

Calls 2

getSessionFunction · 0.85
evaluateMethod · 0.80

Tested by

no test coverage detected