get_user
Retrieve user details by providing a user ID to access information stored in the Kapiti CMS platform for management purposes.
Instructions
Get user details by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | User ID |
Implementation Reference
- src/index.ts:351-374 (handler)The handler function that executes the get_user tool logic: fetches user details from the Headlesshost API endpoint `/tools/membership/users/${id}` and returns the JSON response.async ({ id }) => { try { const response: AxiosResponse<ApiResponse<User>> = await apiClient.get(`/tools/membership/users/${id}`); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } }
- src/index.ts:55-64 (schema)TypeScript interface defining the User object structure, used in the tool's response typing (ApiResponse<User>).interface User { id: string; email: string; firstName: string; lastName: string; isActive: boolean; role?: string; createdAt: string; updatedAt: string; }
- src/index.ts:347-349 (schema)Zod input schema for the get_user tool, validating the required 'id' parameter as a string.inputSchema: { id: z.string().describe("User ID"), },
- src/index.ts:342-376 (registration)MCP server registration of the 'get_user' tool, specifying name, metadata, input schema, and handler function.server.registerTool( "get_user", { title: "Get User", description: "Get user details by ID", inputSchema: { id: z.string().describe("User ID"), }, }, async ({ id }) => { try { const response: AxiosResponse<ApiResponse<User>> = await apiClient.get(`/tools/membership/users/${id}`); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } } );
- src/index.ts:158-166 (helper)Helper function used in the error handling of the get_user tool to format API error messages.function handleApiError(error: any): string { if (error.response) { return `API Error ${error.response.status}: ${error.response.data?.message || error.response.statusText}`; } else if (error.request) { return "Network Error: Unable to reach API server"; } else { return `Error: ${error.message}`; } }