Skip to main content
Glama

extract-form-data

Extract structured data from forms such as receipts, invoices, and ID documents using Azure Form Recognizer in Orion Vision MCP Server. Input a document URL and specify the form type for accurate analysis.

Instructions

Extracts structured data from forms using Azure Form Recognizer

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formTypeYesType of form to analyze
urlYesURL of the form document to analyze

Implementation Reference

  • The core handler function that downloads the form from URL, maps formType to Azure model ID, analyzes it using Form Recognizer client, and returns JSON result.
    export const extractFormData = async (url: string, formType: string): Promise<string> => { const config = getConfig(); const client = new DocumentAnalysisClient( config.formRecognizerEndpoint, new AzureKeyCredential(config.formRecognizerKey) ); try { // Download the document from URL const response = await axios.get(url, { responseType: "arraybuffer" }); const buffer = Buffer.from(response.data); // Map form type to model ID const modelId = { receipt: "prebuilt-receipt", invoice: "prebuilt-invoice", idDocument: "prebuilt-idDocument", businessCard: "prebuilt-businessCard", custom: "prebuilt-document" }[formType]; if (!modelId) { throw new Error(`Invalid form type: ${formType}`); } // Analyze the form const poller = await client.beginAnalyzeDocument( modelId, buffer as FormRecognizerRequestBody ); const result = await poller.pollUntilDone(); return JSON.stringify(result, null, 2); } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Form data extraction failed: ${errorMessage}`); } };
  • Zod schema defining the input parameters: url (string URL) and formType (enum of supported form types).
    export const FormDataSchema = z.object({ url: z.string().url().describe("URL of the form document to analyze"), formType: z.enum(["receipt", "invoice", "idDocument", "businessCard", "custom"]).describe("Type of form to analyze"), });
  • Tool configuration object in the tools array, specifying name, description, input schema, and execute function that delegates to the handler.
    { name: "extract-form-data", description: "Extracts structured data from forms using Azure Form Recognizer", parameters: FormDataSchema, execute: async (args) => { return await extractFormData(args.url, args.formType); }, },
  • src/index.ts:17-20 (registration)
    Loop that registers all tools from the config array into the FastMCP server using addTool method.
    // Register all tools tools.forEach((tool) => { (server.addTool as Tool)(tool); });

Other Tools

Related Tools

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/Cognitive-Stack/orion-vision-mcp'

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