fakestore_get_user
Retrieve user details by ID from the Fake Store API to access customer information for e-commerce applications, testing, and development.
Instructions
Get a single user by their ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | User ID |
Implementation Reference
- src/tools/users.ts:32-36 (handler)Core handler function that fetches and returns a single user by ID from the FakeStore API after validating the ID.export async function getUserById(args: { id: number }): Promise<User> { const { id } = args; validatePositiveInteger(id, 'User ID'); return get<User>(`/users/${id}`); }
- src/tools/users.ts:213-226 (schema)Tool schema definition including name, description, and input schema for validating the 'id' parameter.{ name: 'fakestore_get_user', description: 'Get a single user by their ID', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'User ID', }, }, required: ['id'], }, },
- src/index.ts:176-181 (registration)Dispatch logic in the main CallToolRequestSchema handler that routes fakestore_get_user calls to the getUserById function.if (name === 'fakestore_get_user') { const result = await getUserById(args as { id: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:40-44 (registration)Registration of all tools, including userTools containing fakestore_get_user, for the ListToolsRequestSchema endpoint.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });