jsonplaceholder_albums
Retrieve test album data from JSONPlaceholder for development and testing purposes, filtering by user ID and limiting results as needed.
Instructions
Get test albums data from JSONPlaceholder
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | No | User ID to get albums for (1-10, optional) | |
| limit | No | Maximum number of albums to return (1-100) |
Implementation Reference
- The execute handler function that calls the API client to fetch albums data and formats the response.
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/tools/testing/jsonplaceholder-tools.ts:324-369 (registration)Full tool registration block defining name, description, input schema, and 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 and fetches albums data.
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; } - src/utils/input-validator.ts:277-280 (schema)Zod input validation schema specific to the jsonplaceholder_albums tool.
'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/index.ts:245-245 (registration)Top-level call to register the JSONPlaceholder tools including jsonplaceholder_albums.
registerJSONPlaceholderTools(this.toolRegistry); // 2 tools: test_jsonplaceholder, test_httpbin