Skip to main content
Glama
es6kr

claude-session-manager

by es6kr

list_projects

View all Claude Code projects and their session counts to track development activity and manage workflows.

Instructions

List all Claude Code projects with session counts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that lists all projects in ~/.claude/projects, counts sessions per project, formats display names, and returns sorted list.
    def get_projects() -> list[dict]:
        """Get all projects."""
        base_path = get_base_path()
        projects = []
    
        if not base_path.exists():
            return projects
    
        for project_dir in base_path.iterdir():
            if project_dir.is_dir() and not project_dir.name.startswith('.'):
                # Count sessions
                session_count = len(list(project_dir.glob("*.jsonl")))
                projects.append({
                    "name": project_dir.name,
                    "display_name": format_project_name(project_dir.name),
                    "session_count": session_count
                })
    
        return sorted(projects, key=lambda p: p["name"])
  • Registers the 'list_projects' tool in the MCP list_tools() function, including its description and input schema (no parameters required).
    Tool(
        name="list_projects",
        description="List all Claude Code projects with session counts",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": []
        }
    ),
  • Dispatches tool calls to the get_projects() handler within the main @mcp.call_tool() function.
    if name == "list_projects":
        result = get_projects()
  • Helper function returning the base directory path for Claude projects.
    def get_base_path() -> Path:
        """Get base path for Claude projects."""
        return Path(os.path.expanduser("~/.claude/projects"))
  • Helper function to format raw project directory names into user-friendly display names.
    def format_project_name(name: str) -> str:
        """Format project name for display."""
        if name.startswith('-'):
            name = name[1:]
        name = name.replace('--', '/.')
        parts = name.split('-')
        if len(parts) > 1:
            last = parts[-1]
            if last in ('com', 'org', 'net', 'io', 'dev', 'md', 'txt', 'py', 'js', 'ts'):
                parts[-2] = parts[-2] + '.' + last
                parts = parts[:-1]
        name = '/' + '/'.join(parts)
        if name.startswith('/Users/young'):
            name = '~' + name[len('/Users/young'):]
        return name
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'List' implies a read operation, the description doesn't specify whether this requires authentication, what format the output takes, whether there are rate limits, or how session counts are calculated. This leaves significant behavioral gaps.

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?

The description is a single, efficient sentence that communicates the core purpose without any wasted words. It's appropriately sized for a simple list operation and front-loads the essential information.

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

Completeness3/5

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

For a zero-parameter read operation with no output schema, the description covers the basic purpose adequately. However, it lacks important context about what 'session counts' means, the format of returned data, and how this differs from 'list_sessions'. The absence of annotations means the description should do more heavy lifting.

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 tool has 0 parameters with 100% schema description coverage, so the schema fully documents the parameter situation. The description appropriately doesn't discuss parameters since none exist, earning a baseline 4 for this dimension.

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

Purpose4/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 resource ('Claude Code projects with session counts'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'list_sessions', but the resource specification provides some distinction.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'list_sessions' or 'preview_cleanup'. There's no mention of prerequisites, timing considerations, or comparison with sibling tools.

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/es6kr/claude-session-manager'

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