Skip to main content
Glama
DumplingAI

Dumpling AI MCP Server

Official
by DumplingAI

extract-document

Extract structured data from documents using a prompt. Specify input method, files, and extraction criteria to process URLs or base64-encoded documents.

Instructions

Extract structured data from documents based on a prompt.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputMethodYesInput method
filesYesArray of URLs or base64-encoded documents
promptYesExtraction prompt
jsonModeNoReturn in JSON format

Implementation Reference

  • The handler function for the 'extract-document' tool. It proxies the request to the external Dumpling AI API endpoint /api/v1/extract-document, handles authentication with API key, and returns the response as MCP content.
        const apiKey = process.env.DUMPLING_API_KEY;
        if (!apiKey) throw new Error("DUMPLING_API_KEY not set");
        const response = await fetch(`${NWS_API_BASE}/api/v1/extract-document`, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            Authorization: `Bearer ${apiKey}`,
          },
          body: JSON.stringify({
            inputMethod,
            files,
            prompt,
            jsonMode,
            requestSource: "mcp",
          }),
        });
        if (!response.ok)
          throw new Error(`Failed: ${response.status} ${await response.text()}`);
        const data = await response.json();
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );
  • Zod schema defining the input parameters for the 'extract-document' tool: inputMethod (url or base64), files (array of strings), prompt (string), jsonMode (optional boolean).
      inputMethod: z.enum(["url", "base64"]).describe("Input method"),
      files: z
        .array(z.string())
        .describe("Array of URLs or base64-encoded documents"),
      prompt: z.string().describe("Extraction prompt"),
      jsonMode: z.boolean().optional().describe("Return in JSON format"),
    },
    async ({ inputMethod, files, prompt, jsonMode }) => {
  • src/index.ts:655-688 (registration)
    Registration of the 'extract-document' tool using McpServer.tool(), including name, description, input schema, and handler function.
      "extract-document",
      "Extract structured data from documents based on a prompt.",
      {
        inputMethod: z.enum(["url", "base64"]).describe("Input method"),
        files: z
          .array(z.string())
          .describe("Array of URLs or base64-encoded documents"),
        prompt: z.string().describe("Extraction prompt"),
        jsonMode: z.boolean().optional().describe("Return in JSON format"),
      },
      async ({ inputMethod, files, prompt, jsonMode }) => {
        const apiKey = process.env.DUMPLING_API_KEY;
        if (!apiKey) throw new Error("DUMPLING_API_KEY not set");
        const response = await fetch(`${NWS_API_BASE}/api/v1/extract-document`, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            Authorization: `Bearer ${apiKey}`,
          },
          body: JSON.stringify({
            inputMethod,
            files,
            prompt,
            jsonMode,
            requestSource: "mcp",
          }),
        });
        if (!response.ok)
          throw new Error(`Failed: ${response.status} ${await response.text()}`);
        const data = await response.json();
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      }
    );

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/DumplingAI/mcp-server-dumplingai'

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