jsonplaceholder_albums
Retrieve test album data for a specific user or a set of users. Specify a user ID or limit the number of albums returned to streamline data retrieval.
Instructions
Get test albums data from JSONPlaceholder
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of albums to return (1-100) | |
| userId | No | User ID to get albums for (1-10, optional) |
Input Schema (JSON Schema)
{
"properties": {
"limit": {
"default": 10,
"description": "Maximum number of albums to return (1-100)",
"maximum": 100,
"minimum": 1,
"type": "number"
},
"userId": {
"description": "User ID to get albums for (1-10, optional)",
"type": "number"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- The execute handler function for the jsonplaceholder_albums tool. Fetches albums via the API client, handles errors, and returns structured output with success status, data, and metadata.execute: async (args: any) => { try { const albums = await client.getAlbums(args.userId, args.limit || 10); return { success: true, data: { source: 'JSONPlaceholder API', type: 'albums', userId: args.userId, results: albums, count: albums.length, timestamp: Date.now(), apiUsed: true } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get test albums' }; } }
- src/utils/input-validator.ts:277-280 (schema)Zod schema definition for input validation of the jsonplaceholder_albums tool parameters (userId optional 1-10, limit optional default 10 max 100). Used by the global input validator.'jsonplaceholder_albums': z.object({ userId: z.number().int().min(1).max(10).optional(), limit: z.number().int().min(1).max(100).optional().default(10) }),
- src/tools/testing/jsonplaceholder-tools.ts:324-369 (registration)Full tool registration block in registerJSONPlaceholderTools function, defining name, description, category, source, inputSchema, and inline execute handler.registry.registerTool({ name: 'jsonplaceholder_albums', description: 'Get test albums data from JSONPlaceholder', category: 'testing', source: 'jsonplaceholder.typicode.com', inputSchema: { type: 'object', properties: { userId: { type: 'number', description: 'User ID to get albums for (1-10, optional)' }, limit: { type: 'number', description: 'Maximum number of albums to return (1-100)', default: 10, minimum: 1, maximum: 100 } }, required: [] }, execute: async (args: any) => { try { const albums = await client.getAlbums(args.userId, args.limit || 10); return { success: true, data: { source: 'JSONPlaceholder API', type: 'albums', userId: args.userId, results: albums, count: albums.length, timestamp: Date.now(), apiUsed: true } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get test albums' }; } } });
- Helper method in JSONPlaceholderAPIClient class that constructs the API endpoint for albums, fetches data using makeRequest, and applies optional limit slicing.async getAlbums(userId?: number, limit?: number) { const endpoint = userId ? `/users/${userId}/albums` : '/albums'; const albums = await this.makeRequest(endpoint); return limit ? albums.slice(0, limit) : albums; }