fakestore_get_user
Retrieve user details by ID from the Fake Store API to access e-commerce user information for testing or development purposes.
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 validates the user ID and fetches the user data from the FakeStore API endpoint `/users/${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)Input schema definition for the tool, specifying the required 'id' parameter as a number.{ 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)Tool dispatch registration in the main MCP CallToolRequestSchema handler, which calls the getUserById function and formats the response.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 tool list including userTools (which contains fakestore_get_user schema) for ListToolsRequestSchema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });