get_user_sessions
Retrieve user session data from OpenReplay by specifying a user ID and optional date range to analyze behavior patterns and interactions.
Instructions
Get sessions for a specific user ID (API key authentication supported)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | The user ID to get sessions for | |
| startDate | No | Start date in ISO format | |
| endDate | No | End date in ISO format |
Implementation Reference
- src/index.ts:327-344 (handler)The handler function that implements the logic for the 'get_user_sessions' tool. It extracts userId, optional startDate and endDate from args, makes an authenticated API GET request to OpenReplay's /users/{userId}/sessions endpoint with date params converted to timestamps, and returns the JSON response as MCP content.private async getUserSessions(args: any) { const { userId, startDate, endDate } = args; const response = await this.api.get(`/api/v1/${OPENREPLAY_PROJECT_KEY}/users/${userId}/sessions`, { params: { start_date: startDate ? new Date(startDate).getTime() : undefined, end_date: endDate ? new Date(endDate).getTime() : undefined } }); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/index.ts:66-74 (schema)Input schema defining the parameters for the 'get_user_sessions' tool: required 'userId' (string), optional 'startDate' and 'endDate' (ISO strings).inputSchema: { type: "object", properties: { userId: { type: "string", description: "The user ID to get sessions for" }, startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" } }, required: ["userId"] }
- src/index.ts:63-75 (registration)Registration of the 'get_user_sessions' tool in the MCP server's list of available tools, including name, description, and input schema.{ name: "get_user_sessions", description: "Get sessions for a specific user ID (API key authentication supported)", inputSchema: { type: "object", properties: { userId: { type: "string", description: "The user ID to get sessions for" }, startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" } }, required: ["userId"] } },
- src/index.ts:276-277 (registration)Dispatcher case in the CallToolRequestSchema handler that routes calls to the 'get_user_sessions' handler method.case "get_user_sessions": return await this.getUserSessions(args);