get_image_details
Extract detailed information for a specific image using its Openverse image ID. Provides insights for openly-licensed images, helping users identify and verify image attributes.
Instructions
Get detailed information about a specific image
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_id | Yes | Openverse image ID (UUID format) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"image_id": {
"description": "Openverse image ID (UUID format)",
"type": "string"
}
},
"required": [
"image_id"
],
"type": "object"
}
Implementation Reference
- src/index.ts:95-114 (handler)The execute handler function for the get_image_details tool. It fetches detailed information about a specific image from the Openverse API using the provided image_id, handles errors, and returns the JSON data.execute: async (args) => { try { const response = await fetch(`${OPENVERSE_API_BASE}/images/${args.image_id}/`, { headers: { 'User-Agent': 'MCP-Openverse/1.0' } }); if (!response.ok) { throw new Error(`Failed to fetch image details: ${response.status} ${response.statusText}`); } const data = await response.json(); return JSON.stringify(data, null, 2); } catch (error) { return JSON.stringify({ error: error instanceof Error ? error.message : 'Unknown error' }); } }
- src/index.ts:29-31 (schema)Zod schema for input validation of the get_image_details tool, requiring a single 'image_id' parameter.const imageDetailsSchema = z.object({ image_id: z.string().describe('Openverse image ID (UUID format)') });
- src/index.ts:91-115 (registration)Registration of the 'get_image_details' tool with FastMCP server, including name, description, input schema, and handler function.server.addTool({ name: 'get_image_details', description: 'Get detailed information about a specific image', parameters: imageDetailsSchema, execute: async (args) => { try { const response = await fetch(`${OPENVERSE_API_BASE}/images/${args.image_id}/`, { headers: { 'User-Agent': 'MCP-Openverse/1.0' } }); if (!response.ok) { throw new Error(`Failed to fetch image details: ${response.status} ${response.statusText}`); } const data = await response.json(); return JSON.stringify(data, null, 2); } catch (error) { return JSON.stringify({ error: error instanceof Error ? error.message : 'Unknown error' }); } } });