get_session_changes
Retrieve all changes logged in a session to review prior modifications. Use at session start to understand what was done previously.
Instructions
Retrieve all changes logged in the current session. Use at session start to understand what was done previously.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes |
Implementation Reference
- src/managers/LedgerManager.ts:54-65 (handler)The actual execution logic for get_session_changes: reads the ledger file via fs.readLedger, filters entries by sessionId, and returns results with branch and shortSha from git context.
async function getSessionChanges(sessionId: string): Promise<LedgerQueryResult> { const [entries, context] = await Promise.all([ fs.readLedger(ledgerPath), git.getBranchContext(repoDir), ]); return { entries: entries.filter((e) => e.sessionId === sessionId), branch: context.branch, sha: context.shortSha, }; } - src/tools/ledger.tool.ts:16-18 (schema)Zod schema for get_session_changes input validation: requires a sessionId string.
export const GetSessionChangesSchema = z.object({ sessionId: z.string().min(1), }); - src/tools/ledger.tool.ts:36-41 (registration)Registration of the 'get_session_changes' tool on the MCP server with its schema and handler that calls manager.getSessionChanges.
server.tool('get_session_changes', 'Retrieve all changes logged in the current session. Use at session start to understand what was done previously.', GetSessionChangesSchema.shape, async (args) => { const result = await manager.getSessionChanges(args.sessionId); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; }); - src/access/FileSystemAccess.ts:49-57 (helper)Helper function readLedger that reads and parses the ledger file (used by getSessionChanges handler).
async function readLedger(ledgerPath: string): Promise<LedgerEntry[]> { if (!existsSync(ledgerPath)) return []; const raw = await readFile(ledgerPath, 'utf8'); return raw .trim() .split('\n') .filter(Boolean) .map((line) => JSON.parse(line) as LedgerEntry); }