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

Method execute

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

Source from the content-addressed store, hash-verified

281 argsSchema = GetTextArgs;
282
283 async execute(args: z.infer<typeof GetTextArgs>, _ctx: ToolContext): Promise<ToolResult> {
284 try {
285 const s = await getSession();
286 const maxChars = args.max_chars ?? 5000;
287 let text: string;
288 if (args.selector) {
289 const el = await s.page.$(args.selector);
290 if (!el) return { content: `[BROWSER_ERROR] selector not found: ${args.selector}`, isError: true };
291 text = await el.innerText();
292 } else {
293 text = await s.page.innerText('body');
294 }
295 const truncated = text.length > maxChars;
296 return {
297 content: `${text.slice(0, maxChars)}${truncated ? `\n…[truncated, ${text.length - maxChars} more chars]` : ''}`,
298 metadata: { fullLength: text.length },
299 };
300 } catch (e: any) {
301 return { content: `[BROWSER_ERROR] get_text failed: ${e?.message ?? String(e)}`, isError: true };
302 }
303 }
304}
305
306const WaitForArgs = z.object({

Callers

nothing calls this directly

Calls 1

getSessionFunction · 0.85

Tested by

no test coverage detected