list_projects
Retrieve all Claude Code projects and their associated session counts for managing conversation sessions.
Instructions
List all Claude Code projects with session counts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/index.ts:15-20 (registration)Registers the 'list_projects' MCP tool. No input schema. The handler runs session.listProjects() and returns the result as formatted JSON text in MCP content format.server.tool('list_projects', 'List all Claude Code projects with session counts', {}, async () => { const result = await Effect.runPromise(session.listProjects) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], } })
- src/lib/session.ts:18-54 (handler)The main handler logic for listing projects: checks if sessions directory exists, reads directories, counts .jsonl session files in each project directory concurrently.export const listProjects = Effect.gen(function* () { const sessionsDir = getSessionsDir() const exists = yield* Effect.tryPromise(() => fs .access(sessionsDir) .then(() => true) .catch(() => false) ) if (!exists) { return [] as Project[] } const entries = yield* Effect.tryPromise(() => fs.readdir(sessionsDir, { withFileTypes: true })) const projects = yield* Effect.all( entries .filter((e) => e.isDirectory()) .map((entry) => Effect.gen(function* () { const projectPath = path.join(sessionsDir, entry.name) const files = yield* Effect.tryPromise(() => fs.readdir(projectPath)) const sessionFiles = files.filter((f) => f.endsWith('.jsonl')) return { name: entry.name, path: projectPath, sessionCount: sessionFiles.length, } satisfies Project }) ), { concurrency: 10 } ) return projects })