Skip to main content
Glama

get-session-history

Retrieve previous analysis sessions to review code changes, track development progress, and maintain context for ongoing projects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesID of the session to retrieve history for
limitNoMaximum 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"), },
  • 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, }; } } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0xjcf/MCP_CodeAnalysis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server