fakestore_get_users
Retrieve user data from the Fake Store API with optional filtering and sorting capabilities for e-commerce testing and development.
Instructions
Get all users from the store. Optionally limit results and sort.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Limit the number of users returned | |
| sort | No | Sort users (asc or desc) |
Implementation Reference
- src/tools/users.ts:12-27 (handler)Core handler function implementing the fakestore_get_users tool logic: validates optional limit and sort parameters, constructs query params, and calls the API to fetch users.export async function getAllUsers(args: { limit?: number; sort?: SortOrder }): Promise<User[]> { const { limit, sort } = args; if (limit !== undefined) { validateLimit(limit); } if (sort !== undefined) { validateSortOrder(sort); } const params: Record<string, unknown> = {}; if (limit) params.limit = limit; if (sort) params.sort = sort; return get<User[]>('/users', params); }
- src/tools/users.ts:195-212 (schema)Input schema definition for the fakestore_get_users tool within the userTools array.{ name: 'fakestore_get_users', description: 'Get all users from the store. Optionally limit results and sort.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit the number of users returned', }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Sort users (asc or desc)', }, }, }, },
- src/index.ts:40-44 (registration)Tool registration in MCP list tools handler; includes userTools which contains fakestore_get_users.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
- src/index.ts:169-173 (handler)Dispatch handler in MCP call tool request that invokes getAllUsers for fakestore_get_users and formats response.if (name === 'fakestore_get_users') { const result = await getAllUsers(args as { limit?: number; sort?: 'asc' | 'desc' }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], };
- src/index.ts:20-20 (registration)Import of userTools (with schema/registration) and getAllUsers (handler) from users module.import { userTools, getAllUsers, getUserById, addUser, updateUser, deleteUser } from './tools/users.js';