Skip to main content
Glama

list_projects

List all Claude Code projects on your machine and identify the currently active project.

Instructions

List all Claude Code projects on this machine. Shows which project is currently active.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual tool handler for 'list_projects'. Defined via server.tool() call. Scans all projects using fileScanner.scanProjects(), counts sessions per project, marks the current project, and returns sorted JSON results.
    // ─── list_projects ───────────────────────────────────────────────
    server.tool(
      'list_projects',
      'List all Claude Code projects on this machine. Shows which project is currently active.',
      {},
      async () => {
        try {
          const { fileScanner, currentProjectId } = await getServices()
          const projects = await fileScanner.scanProjects()
    
          const results = []
          for (const project of projects) {
            const sessions = await fileScanner.scanSessions(project.path)
            results.push({
              id: project.id,
              name: project.name,
              sessionCount: sessions.length,
              lastModified: project.lastModified,
              isCurrent: project.id === currentProjectId,
            })
          }
    
          // Put current project first
          results.sort((a, b) => (b.isCurrent ? 1 : 0) - (a.isCurrent ? 1 : 0))
    
          return {
            content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],
          }
        } catch (error) {
          return {
            content: [{ type: 'text', text: `Error listing projects: ${error.message}` }],
            isError: true,
          }
        }
      }
    )
  • The export function registerTools(server, getServices) that registers all tools on the MCP server instance, including list_projects.
    export function registerTools(server, getServices) {
  • Where registerTools is called to wire the tools (including list_projects) to the MCP server.
    registerTools(server, getServices)
    registerResources(server, getServices)
    registerPrompts(server)
  • The scanProjects() method on FileScanner that reads the projects directory and returns project metadata (id, name, path, lastModified).
    async scanProjects() {
      try {
        const entries = await fs.readdir(this.projectsRoot, { withFileTypes: true });
        const projects = [];
    
        for (const entry of entries) {
          if (entry.isDirectory()) {
            const projectPath = path.join(this.projectsRoot, entry.name);
            const stats = await fs.stat(projectPath);
            
            projects.push({
              id: entry.name,
              name: this.cleanProjectName(entry.name),
              path: projectPath,
              lastModified: stats.mtime.toISOString()
            });
          }
        }
    
        return projects.sort((a, b) => new Date(b.lastModified) - new Date(a.lastModified));
      } catch (error) {
        console.error('Error scanning projects:', error);
        throw new Error(`Failed to scan projects directory: ${error.message}`);
      }
    }
  • getProjectRoot() resolves the projects directory (from PROJECT_ROOT env or default ~/.claude/projects).
    export function getProjectRoot() {
      const envPath = process.env.PROJECT_ROOT;
    
      // If PROJECT_ROOT is set, expand it
      if (envPath) {
        return expandPath(envPath);
      }
    
      // Default fallback: ~/.claude/projects
      return path.join(os.homedir(), '.claude', 'projects');
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It clearly states that the tool lists projects, implying read-only behavior, and mentions showing the active project. It does not discuss side effects, permissions, or output format, but for a simple listing tool this is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, 14 words, no wasted text. Front-loaded with the main verb 'List' and resource. Highly concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 0 parameters and no output schema or annotations, the description is complete. It tells the agent everything needed: what it lists and that it indicates the active project.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0 parameters, so baseline is 4. The description adds no parameter information, but schema coverage is effectively 100%, meeting the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and the resource 'Claude Code projects', and adds the specific detail of showing the active project. This distinguishes it from sibling tools like get_project_context which focuses on context rather than listing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing projects, but does not explicitly state when to use it versus alternatives like get_project_context, nor does it provide any when-not-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/kunwar-shah/claudex'

If you have feedback or need assistance with the MCP directory API, please join our Discord server