get-session-history
Retrieve previous analysis sessions to review code changes, track development progress, and maintain context for ongoing projects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the session to retrieve history for | |
| limit | No | Maximum number of history entries to return |
Implementation Reference
- The handler function for 'get-session-history' tool. It retrieves the session using getSession(sessionId), gets its history, limits to the most recent 'limit' entries (default 10), handles errors, and returns a formatted success or error response using createSuccessResponse or createErrorResponse.async ({ sessionId, limit }) => { try { const session = getSession(sessionId); const history = session.getHistory(); // Get the most recent entries up to the limit const limitedHistory = history.slice(-limit); const result = createSuccessResponse( { sessionId, totalEntries: history.length, returnedEntries: limitedHistory.length, history: limitedHistory, }, "get-session-history" ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( createErrorResponse( error instanceof Error ? error.message : String(error), "get-session-history" ), null, 2 ), }, ], isError: true, }; } }
- Input schema for 'get-session-history' tool defined with Zod: sessionId (required string, ID of the session), limit (optional number, default 10, maximum history entries to return).{ sessionId: z .string() .describe("ID of the session to retrieve history for"), limit: z .number() .default(10) .describe("Maximum number of history entries to return"), },
- src/features/session-manager/index.ts:138-194 (registration)Registration of the 'get-session-history' tool via server.toolcall in registerSessionTools function, specifying name, input schema, and inline handler.server.tool( "get-session-history", { sessionId: z .string() .describe("ID of the session to retrieve history for"), limit: z .number() .default(10) .describe("Maximum number of history entries to return"), }, async ({ sessionId, limit }) => { try { const session = getSession(sessionId); const history = session.getHistory(); // Get the most recent entries up to the limit const limitedHistory = history.slice(-limit); const result = createSuccessResponse( { sessionId, totalEntries: history.length, returnedEntries: limitedHistory.length, history: limitedHistory, }, "get-session-history" ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( createErrorResponse( error instanceof Error ? error.message : String(error), "get-session-history" ), null, 2 ), }, ], isError: true, }; } } );