Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoMaximum number of history entries to return
sessionIdYesID 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"), },
  • 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, }; } } );

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