get_user_stats
Retrieve statistics for a WebSim user to analyze their activity and performance within the platform.
Instructions
Get statistics for a specific WebSim user
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user | Yes | Username |
Input Schema (JSON Schema)
{
"properties": {
"user": {
"description": "Username",
"type": "string"
}
},
"required": [
"user"
],
"type": "object"
}
Implementation Reference
- server.js:515-527 (handler)The handler function for the 'get_user_stats' MCP tool. It validates the input arguments using UserParamsSchema, calls the apiClient.getUserStats method to fetch data from the WebSim API, and returns a formatted text content response with the results.handler: async (args) => { const { user } = UserParamsSchema.parse(args); const result = await apiClient.getUserStats(user); return { content: [{ type: "text", text: JSON.stringify({ success: true, data: result, message: `Successfully retrieved statistics for user ${user}` }, null, 2) }] };
- server.js:505-514 (schema)The inputSchema definition for the 'get_user_stats' tool, specifying the required 'user' parameter as a string.inputSchema: { type: "object", properties: { user: { type: "string", description: "Username" } }, required: ["user"] },
- server.js:502-528 (registration)The complete tool registration object for 'get_user_stats' within the tools array, which is used by the MCP server's ListToolsRequestHandler and CallToolRequestHandler.{ name: "get_user_stats", description: "Get statistics for a specific WebSim user", inputSchema: { type: "object", properties: { user: { type: "string", description: "Username" } }, required: ["user"] }, handler: async (args) => { const { user } = UserParamsSchema.parse(args); const result = await apiClient.getUserStats(user); return { content: [{ type: "text", text: JSON.stringify({ success: true, data: result, message: `Successfully retrieved statistics for user ${user}` }, null, 2) }] }; }
- server.js:141-143 (helper)Supporting utility method in the WebSimAPIClient class that performs the HTTP request to retrieve user statistics from the WebSim API endpoint.async getUserStats(user) { return this.makeRequest(`/api/v1/users/${user}/stats`); }
- server.js:37-39 (schema)Zod validation schema for user parameters, used in the handler for input parsing.const UserParamsSchema = z.object({ user: z.string().describe('Username') });