get_image_stats
Retrieve provider-specific statistics and image counts from Openverse to analyze and understand openly-licensed image resources effectively.
Instructions
Get statistics about image providers and counts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:157-176 (handler)The main handler function that executes the tool logic by fetching image statistics from the Openverse API endpoint and returning the JSON response.execute: async () => { try { const response = await fetch(`${OPENVERSE_API_BASE}/images/stats/`, { headers: { 'User-Agent': 'MCP-Openverse/1.0' } }); if (!response.ok) { throw new Error(`Failed to fetch stats: ${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:156-156 (schema)Zod schema for tool parameters, which is an empty object indicating no input parameters are required.parameters: z.object({}),
- src/index.ts:153-177 (registration)Registration of the 'get_image_stats' tool with FastMCP server using server.addTool method.server.addTool({ name: 'get_image_stats', description: 'Get statistics about image providers and counts', parameters: z.object({}), execute: async () => { try { const response = await fetch(`${OPENVERSE_API_BASE}/images/stats/`, { headers: { 'User-Agent': 'MCP-Openverse/1.0' } }); if (!response.ok) { throw new Error(`Failed to fetch stats: ${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' }); } } });