search_sessions
Search and filter user sessions by date, filters, and pagination on the OpenReplay MCP Server. Requires userId and API key authentication for streamlined session analysis.
Instructions
[Requires userId with API key auth] Search and filter sessions. Full search requires JWT authentication.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endDate | No | End date in ISO format | |
| filters | No | Filters (limited with API key auth) | |
| limit | No | Number of sessions to return | |
| offset | No | Offset for pagination | |
| sort | No | ||
| startDate | No | Start date in ISO format | |
| userId | No | Required: User ID to search sessions for |
Implementation Reference
- src/index.ts:346-376 (handler)The core handler function implementing the search_sessions tool logic. It requires a userId and fetches sessions from the OpenReplay API /users/{userId}/sessions endpoint with date range parameters, returning JSON data.private async searchSessions(args: any) { // Note: The v1 API with API keys has limited endpoints // For full session search, JWT authentication is required // This uses the user sessions endpoint as an alternative if (!args.userId) { return { content: [ { type: "text", text: "Session search requires a userId when using API key authentication. For full search capabilities, JWT authentication is needed.", }, ], }; } const response = await this.api.get(`/api/v1/${OPENREPLAY_PROJECT_KEY}/users/${args.userId}/sessions`, { params: { start_date: args.startDate ? new Date(args.startDate).getTime() : Date.now() - 7 * 24 * 60 * 60 * 1000, end_date: args.endDate ? new Date(args.endDate).getTime() : Date.now() } }); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/index.ts:79-108 (schema)JSON Schema defining the input parameters for the search_sessions tool, including userId (required in practice), dates, filters array, pagination, and sorting.inputSchema: { type: "object", properties: { userId: { type: "string", description: "Required: User ID to search sessions for" }, startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" }, filters: { type: "array", description: "Filters (limited with API key auth)", items: { type: "object", properties: { type: { type: "string", description: "Filter type" }, operator: { type: "string", description: "Operator" }, value: { type: ["string", "number", "array"], description: "Filter value" } } } }, limit: { type: "number", description: "Number of sessions to return" }, offset: { type: "number", description: "Offset for pagination" }, sort: { type: "object", properties: { field: { type: "string", description: "Field to sort by" }, order: { type: "string", enum: ["asc", "desc"], description: "Sort order" } } } }, required: [] }
- src/index.ts:76-109 (registration)Registration of the search_sessions tool in the list of available tools returned by ListToolsRequest, including name, description, and input schema.{ name: "search_sessions", description: "[Requires userId with API key auth] Search and filter sessions. Full search requires JWT authentication.", inputSchema: { type: "object", properties: { userId: { type: "string", description: "Required: User ID to search sessions for" }, startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" }, filters: { type: "array", description: "Filters (limited with API key auth)", items: { type: "object", properties: { type: { type: "string", description: "Filter type" }, operator: { type: "string", description: "Operator" }, value: { type: ["string", "number", "array"], description: "Filter value" } } } }, limit: { type: "number", description: "Number of sessions to return" }, offset: { type: "number", description: "Offset for pagination" }, sort: { type: "object", properties: { field: { type: "string", description: "Field to sort by" }, order: { type: "string", enum: ["asc", "desc"], description: "Sort order" } } } }, required: [] } },
- src/index.ts:278-279 (registration)Dispatch routing in the CallToolRequest handler switch statement that calls the searchSessions method.case "search_sessions": return await this.searchSessions(args);