fakestore_get_users
Retrieve user data from the Fake Store API for testing or development. Filter results with limit and sort parameters to manage e-commerce user information.
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 that fetches users from the FakeStore API with optional limit and sort parameters. Performs input validation and constructs query parameters.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, including properties for limit and sort.{ 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:169-173 (handler)MCP tool call handler that dispatches to getAllUsers and formats the JSON 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:40-44 (registration)Registers all tools including userTools (with fakestore_get_users) for the ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });