pilot_page_forms
Extract all form fields from web pages as structured JSON data for browser automation and data processing tasks.
Instructions
Get all form fields on the page as structured JSON.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/page.ts:82-111 (handler)Implementation of the 'pilot_page_forms' tool, which iterates through forms on the page and extracts their fields as structured JSON.
server.tool( 'pilot_page_forms', 'Get all form fields on the page as structured JSON.', {}, async () => { await bm.ensureBrowser(); try { const forms = await bm.getPage().evaluate(() => { return [...document.querySelectorAll('form')].map((form, i) => { const fields = [...form.querySelectorAll('input, select, textarea')].map(el => { const input = el as HTMLInputElement; return { tag: el.tagName.toLowerCase(), type: input.type || undefined, name: input.name || undefined, id: input.id || undefined, placeholder: input.placeholder || undefined, required: input.required || undefined, value: input.type === 'password' ? '[redacted]' : (input.value || undefined), }; }); return { index: i, action: form.action || undefined, method: form.method || 'get', id: form.id || undefined, fields }; }); }); return { content: [{ type: 'text' as const, text: JSON.stringify(forms, null, 2) }] }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );