List sessions
listSessionsList sessions within a specified time range using pagination and optional environment filter to organize and access session data.
Instructions
List sessions within a time range.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number (default 1) | |
| limit | No | Items per page (default 50, max 100) | |
| fromTimestamp | No | ISO 8601 lower bound (inclusive) | |
| toTimestamp | No | ISO 8601 upper bound (exclusive) | |
| environment | No |
Implementation Reference
- src/tools.ts:78-90 (registration)Tool registration for 'listSessions' with title, description, and input schema (pagination, time range, environment).
server.registerTool( "listSessions", { title: "List sessions", description: "List sessions within a time range.", inputSchema: { ...paginationShape, ...timeRangeShape, environment: z.string().optional(), }, }, async (args) => asJson(await client.get("/api/public/sessions", args)), ); - src/tools.ts:89-89 (handler)Handler function that calls the Langfuse API GET /api/public/sessions with the provided arguments.
async (args) => asJson(await client.get("/api/public/sessions", args)), - src/tools.ts:83-87 (schema)Input schema for listSessions: pagination (page, limit), time range (fromTimestamp, toTimestamp), and optional environment filter.
inputSchema: { ...paginationShape, ...timeRangeShape, environment: z.string().optional(), }, - src/tools.ts:6-17 (helper)Helper function that wraps data in the MCP content format as JSON text.
const asJson = (data: unknown) => ({ content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }); const enc = encodeURIComponent; export function registerTools(server: McpServer, client: LangfuseClient): void { // ---------- Traces ---------- server.registerTool( "listTraces", { title: "List traces", - src/tools.ts:397-420 (registration)Entry in TOOL_NAMES constant array for the listSessions tool.
"listSessions", "getSession", "listScores", "getScore", "listScoreConfigs", "getScoreConfig", "listPrompts", "getPrompt", "listDatasets", "getDataset", "listDatasetItems", "getDatasetItem", "listDatasetRuns", "getDatasetRun", "getMetrics", "getDailyMetrics", "listModels", "getModel", "listProjects", "listComments", "getComment", "getMedia", "getHealth", ] as const;