image_tagging
Extract descriptive tags from online images to identify content, objects, and themes for open-source intelligence analysis.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Image URL to tag using Imagga |
Implementation Reference
- src/tools/imagga.ts:27-58 (handler)The handler function that executes the actual API request to Imagga for image tagging.
async tagImageUrl(imageUrl: string): Promise<ImaggaResult> { const apiKey = configManager.get("IMAGGA_API_KEY"); const apiSecret = configManager.get("IMAGGA_API_SECRET"); if (!apiKey || !apiSecret) { throw new McpError( ErrorCode.InvalidRequest, "IMAGGA_API_KEY or IMAGGA_API_SECRET is not configured" ); } const auth = Buffer.from(`${apiKey}:${apiSecret}`).toString("base64"); try { const data = await this.fetch<any>("tags", { method: "GET", headers: { Authorization: `Basic ${auth}`, }, }, { image_url: imageUrl, }); return ImaggaResultSchema.parse(data); } catch (error) { if (error instanceof McpError) throw error; throw new McpError( ErrorCode.InternalError, `Imagga error: ${(error as Error).message}` ); } } - src/index.ts:329-338 (registration)The tool registration for "image_tagging" which calls the imClient.tagImageUrl handler.
server.tool( "image_tagging", { url: z.string().url().describe("Image URL to tag using Imagga") }, async ({ url }) => { const result = await imClient.tagImageUrl(url); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } ); - src/tools/imagga.ts:6-17 (schema)Validation schema for the Imagga API response.
export const ImaggaResultSchema = z.object({ result: z.object({ tags: z.array(z.object({ confidence: z.number(), tag: z.object({ en: z.string(), }), })), }), }); export type ImaggaResult = z.infer<typeof ImaggaResultSchema>;