extract-video
Extract structured data from videos using a prompt. Specify a URL or base64-encoded video and retrieve results in JSON format for efficient data processing and analysis.
Instructions
Extract structured data from videos based on a prompt.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputMethod | Yes | Input method | |
| jsonMode | No | Return in JSON format | |
| prompt | Yes | Extraction prompt | |
| video | Yes | URL or base64-encoded video |
Implementation Reference
- src/index.ts:769-790 (handler)The main handler function for the 'extract-video' tool. It checks for API key, makes a POST request to the Dumpling API's /extract-video endpoint with the provided parameters, handles errors, and returns the JSON response as text content.async ({ inputMethod, video, 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-video`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, video, 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) }] }; }
- src/index.ts:763-768 (schema)Zod schema defining the input parameters for the 'extract-video' tool: inputMethod (url or base64), video (string), prompt (string), and optional jsonMode (boolean).{ inputMethod: z.enum(["url", "base64"]).describe("Input method"), video: z.string().describe("URL or base64-encoded video"), prompt: z.string().describe("Extraction prompt"), jsonMode: z.boolean().optional().describe("Return in JSON format"), },
- src/index.ts:760-791 (registration)The complete registration of the 'extract-video' tool using server.tool(), including name, description, input schema, and inline handler function.server.tool( "extract-video", "Extract structured data from videos based on a prompt.", { inputMethod: z.enum(["url", "base64"]).describe("Input method"), video: z.string().describe("URL or base64-encoded video"), prompt: z.string().describe("Extraction prompt"), jsonMode: z.boolean().optional().describe("Return in JSON format"), }, async ({ inputMethod, video, 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-video`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ inputMethod, video, 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) }] }; } );