get-session-history
Retrieve session history entries from the CodeAnalysis MCP Server by providing a session ID and optional limit. Streamline code analysis workflows by accessing detailed session data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of history entries to return | |
| sessionId | Yes | ID of the session to retrieve history for |
Implementation Reference
- Executes the get-session-history tool: retrieves session history, limits recent entries, formats and returns JSON success/error response.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, }; } }
- Zod input schema: sessionId (string, required), limit (number, default 10).{ 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)Registers the get-session-history tool on the MCP server with name, input schema, and inline handler function.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, }; } } );