Skip to main content
Glama

list-sessions

Retrieve active or past sessions on the CodeAnalysis MCP Server to track and manage code analysis tasks, syntax evaluations, and workflow progress efficiently.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Inline handler for the 'list-sessions' MCP tool. Fetches all active session IDs using getSessionIds(), extracts summary info (tools used count and last activity timestamp) for each session, formats a success response with the list, or error response on failure.
    server.tool("list-sessions", {}, async () => { try { const sessionIds = getSessionIds(); const sessionInfo = sessionIds.map((id) => { const session = getSession(id); const context = session.getContext(); return { sessionId: id, toolsUsed: context.history.length, lastActivity: context.history.length > 0 ? context.history[context.history.length - 1].timestamp : null, }; }); const result = createSuccessResponse( { activeSessions: sessionIds.length, sessions: sessionInfo, }, "list-sessions" ); 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), "list-sessions" ), null, 2 ), }, ], isError: true, }; } });
  • Registers the 'list-sessions' tool on the MCP server within the registerSessionTools function, using an empty input schema and inline handler.
    server.tool("list-sessions", {}, async () => { try { const sessionIds = getSessionIds(); const sessionInfo = sessionIds.map((id) => { const session = getSession(id); const context = session.getContext(); return { sessionId: id, toolsUsed: context.history.length, lastActivity: context.history.length > 0 ? context.history[context.history.length - 1].timestamp : null, }; }); const result = createSuccessResponse( { activeSessions: sessionIds.length, sessions: sessionInfo, }, "list-sessions" ); 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), "list-sessions" ), null, 2 ), }, ], isError: true, }; } });
  • Helper function that returns an array of all active session IDs from the global 'sessions' Map, used by the list-sessions handler to identify sessions to summarize.
    export function getSessionIds(): string[] { return Array.from(sessions.keys()); }

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