Skip to main content
Glama
Cognitive-Stack

Orion Vision MCP Server

analyze-document

Extract structured data from documents using Azure Form Recognizer. Ideal for processing receipts, invoices, and IDs by analyzing the document URL with optional custom models.

Instructions

Analyzes a document using Azure Form Recognizer and returns structured data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelIdNoOptional model ID for custom models
urlYesURL of the document to analyze

Implementation Reference

  • The core handler function that downloads the document from the URL, analyzes it using Azure Form Recognizer client, and returns the JSON string result.
    export const analyzeDocument = async (url: string, modelId?: 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);
    
        // Analyze the document
        const poller = await client.beginAnalyzeDocument(
          modelId || "prebuilt-document",
          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(`Document analysis failed: ${errorMessage}`);
      }
    };
  • Zod schema defining the input parameters for the analyze-document tool: url (required string URL) and optional modelId.
    export const DocumentSchema = z.object({
      url: z.string().url().describe("URL of the document to analyze"),
      modelId: z.string().optional().describe("Optional model ID for custom models"),
    });
  • Registration of the 'analyze-document' tool in the tools array, specifying name, description, schema, and execute wrapper that calls the handler.
    {
      name: "analyze-document",
      description: "Analyzes a document using Azure Form Recognizer and returns structured data",
      parameters: DocumentSchema,
      execute: async (args) => {
        return await analyzeDocument(args.url, args.modelId);
      },
    },

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

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