render.extract_forms
Extract all forms from a webpage to identify input fields and potential attack surfaces for security testing.
Instructions
Extract all forms from a webpage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to extract forms from |
Implementation Reference
- src/tools/render.ts:147-193 (handler)The handler function that uses Puppeteer to navigate to the given URL, extracts detailed form information (action, method, inputs, textareas, selects) using page.$$eval, closes the page, and returns a formatted result with forms data or error.async ({ url }: any): Promise<ToolResult> => { let page: Page | null = null; try { const browserInstance = await getBrowser(); page = await browserInstance.newPage(); await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 }); const forms = await page.$$eval('form', (forms) => forms.map((form, index) => ({ index, action: form.action, method: form.method, enctype: form.enctype, inputs: Array.from(form.querySelectorAll('input')).map((input: any) => ({ name: input.name, type: input.type, id: input.id, placeholder: input.placeholder, required: input.required, })), textareas: Array.from(form.querySelectorAll('textarea')).map((textarea: any) => ({ name: textarea.name, id: textarea.id, placeholder: textarea.placeholder, })), selects: Array.from(form.querySelectorAll('select')).map((select: any) => ({ name: select.name, id: select.id, options: Array.from(select.options).map((opt: any) => opt.value), })), })) ); await page.close(); return formatToolResult(true, { url, forms, count: forms.length, }); } catch (error: any) { if (page) await page.close().catch(() => {}); return formatToolResult(false, null, error.message); } } );
- src/tools/render.ts:137-146 (schema)Input schema definition for the tool, requiring a 'url' parameter, with tool description.{ description: 'Extract all forms from a webpage', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to extract forms from' }, }, required: ['url'], }, },
- src/tools/render.ts:136-194 (registration)The server.tool call that registers the 'render.extract_forms' tool with its schema and handler function in the registerRenderTools function.'render.extract_forms', { description: 'Extract all forms from a webpage', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to extract forms from' }, }, required: ['url'], }, }, async ({ url }: any): Promise<ToolResult> => { let page: Page | null = null; try { const browserInstance = await getBrowser(); page = await browserInstance.newPage(); await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 }); const forms = await page.$$eval('form', (forms) => forms.map((form, index) => ({ index, action: form.action, method: form.method, enctype: form.enctype, inputs: Array.from(form.querySelectorAll('input')).map((input: any) => ({ name: input.name, type: input.type, id: input.id, placeholder: input.placeholder, required: input.required, })), textareas: Array.from(form.querySelectorAll('textarea')).map((textarea: any) => ({ name: textarea.name, id: textarea.id, placeholder: textarea.placeholder, })), selects: Array.from(form.querySelectorAll('select')).map((select: any) => ({ name: select.name, id: select.id, options: Array.from(select.options).map((opt: any) => opt.value), })), })) ); await page.close(); return formatToolResult(true, { url, forms, count: forms.length, }); } catch (error: any) { if (page) await page.close().catch(() => {}); return formatToolResult(false, null, error.message); } } );