Skip to main content
Glama
DumplingAI

Dumpling AI MCP Server

Official
by DumplingAI

extract-image

Extract structured data from images using a prompt to convert visual information into organized text or JSON format.

Instructions

Extract structured data from images based on a prompt.

Input Schema

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

Implementation Reference

  • The handler function that implements the tool logic by proxying requests to the external Dumpling AI API endpoint for extracting structured data from images.
    async ({ inputMethod, images, 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-image`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: `Bearer ${apiKey}`,
        },
        body: JSON.stringify({
          inputMethod,
          image: images[0],
          prompt,
          jsonMode,
          requestSource: "mcp",
        }), // Assuming single image for simplicity
      });
      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 input schema defining parameters for the extract-image tool: inputMethod, images array, prompt, and optional jsonMode.
    {
      inputMethod: z.enum(["url", "base64"]).describe("Input method"),
      images: z
        .array(z.string())
        .describe("Array of URLs or base64-encoded images"),
      prompt: z.string().describe("Extraction prompt"),
      jsonMode: z.boolean().optional().describe("Return in JSON format"),
    },
  • src/index.ts:690-723 (registration)
    Registration of the 'extract-image' MCP tool using server.tool, including name, description, input schema, and handler.
    server.tool(
      "extract-image",
      "Extract structured data from images based on a prompt.",
      {
        inputMethod: z.enum(["url", "base64"]).describe("Input method"),
        images: z
          .array(z.string())
          .describe("Array of URLs or base64-encoded images"),
        prompt: z.string().describe("Extraction prompt"),
        jsonMode: z.boolean().optional().describe("Return in JSON format"),
      },
      async ({ inputMethod, images, 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-image`, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            Authorization: `Bearer ${apiKey}`,
          },
          body: JSON.stringify({
            inputMethod,
            image: images[0],
            prompt,
            jsonMode,
            requestSource: "mcp",
          }), // Assuming single image for simplicity
        });
        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