list_projects
List all analyzed projects to retrieve their names, paths, and last analysis timestamps for a quick codebase overview.
Instructions
List all projects that have been analyzed by CodeAtlas. Returns project names, paths, and last analysis time.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:132-154 (registration)Registration of the 'list_projects' tool on the MCP server, including its description (empty schema, no params) and handler callback.
// Tool 0: List all discovered projects server.tool( "list_projects", "List all projects that have been analyzed by CodeAtlas. Returns project names, paths, and last analysis time.", {}, async () => { const projects = discoverProjects(); if (projects.length === 0) { return { content: [{ type: "text" as const, text: "No analyzed projects found. Run 'CodeAtlas: Analyze Project' in VS Code first." }] }; } const result = { projectCount: projects.length, projects: projects.map((p) => ({ name: p.name, path: p.dir, lastAnalyzed: p.modifiedAt.toISOString(), })), }; return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] }; } ); - index.ts:137-153 (handler)Handler function for list_projects: calls discoverProjects(), formats results with project count, name, path, and lastAnalyzed timestamp, returns as JSON string.
async () => { const projects = discoverProjects(); if (projects.length === 0) { return { content: [{ type: "text" as const, text: "No analyzed projects found. Run 'CodeAtlas: Analyze Project' in VS Code first." }] }; } const result = { projectCount: projects.length, projects: projects.map((p) => ({ name: p.name, path: p.dir, lastAnalyzed: p.modifiedAt.toISOString(), })), }; return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] }; } - index.ts:50-102 (helper)The discoverProjects() helper function that scans directories (env var, cwd, home children) for .codeatlas/analysis.json files and returns sorted project info.
function discoverProjects(): { name: string; dir: string; analysisPath: string; modifiedAt: Date }[] { const projects: { name: string; dir: string; analysisPath: string; modifiedAt: Date }[] = []; const homeDir = process.env.HOME || process.env.USERPROFILE || "/home"; // Scan directories for .codeatlas/analysis.json const searchDirs: string[] = []; // Add env var project if specified if (process.env.CODEATLAS_PROJECT_DIR) { searchDirs.push(process.env.CODEATLAS_PROJECT_DIR); } // Add cwd searchDirs.push(process.cwd()); // Scan home directory children (max depth 2) try { const homeDirs = fs.readdirSync(homeDir); for (const d of homeDirs) { if (d.startsWith(".")) continue; const fullPath = path.join(homeDir, d); try { if (fs.statSync(fullPath).isDirectory()) { searchDirs.push(fullPath); } } catch { /* skip */ } } } catch { /* skip */ } // Check each directory for .codeatlas/analysis.json const seen = new Set<string>(); for (const dir of searchDirs) { const analysisPath = path.join(dir, ".codeatlas", "analysis.json"); if (seen.has(analysisPath)) continue; seen.add(analysisPath); if (fs.existsSync(analysisPath)) { try { const stat = fs.statSync(analysisPath); projects.push({ name: path.basename(dir), dir, analysisPath, modifiedAt: stat.mtime, }); } catch { /* skip */ } } } // Sort by most recently modified projects.sort((a, b) => b.modifiedAt.getTime() - a.modifiedAt.getTime()); return projects; } - index.ts:136-136 (schema)Schema for list_projects: an empty object ({}) meaning no input parameters are required.
{},