list_projects
View all Claude Code projects and their session counts to track development progress and manage conversations.
Instructions
List all Claude Code projects with session counts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/lib/session.ts:11-47 (handler)Core handler function that lists all Claude Code projects by scanning the ~/.claude/projects directory, counting session files (.jsonl) in each project directory.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 })
- src/mcp/index.ts:14-20 (registration)Registers the 'list_projects' MCP tool with no input parameters. The handler runs session.listProjects and returns the result as formatted JSON text content.// List all projects 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/schema.ts:27-33 (schema)TypeScript schema definition for Project type used in listProjects output, defining name, path, and sessionCount fields.export const ProjectSchema = Schema.Struct({ name: Schema.String, path: Schema.String, sessionCount: Schema.Number, }) export type Project = Schema.Schema.Type<typeof ProjectSchema>