Skip to main content
Glama

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
NameRequiredDescriptionDefault
urlYesURL to extract forms from

Implementation Reference

  • 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); } } );
  • 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'], }, },
  • 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); } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/telmon95/VulneraMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server