Skip to main content
Glama

list_projects

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

Instructions

List all Claude Code projects with session counts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that lists all Claude Code projects from ~/.claude/projects, counts sessions (*.jsonl files), formats display names, excludes hidden dirs, 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"])
  • Tool schema definition: no input parameters required.
    name="list_projects", description="List all Claude Code projects with session counts", inputSchema={ "type": "object", "properties": {}, "required": [] }
  • Tool dispatch/registration in the call_tool handler: maps 'list_projects' calls to get_projects() execution.
    if name == "list_projects": result = get_projects()
  • Helper function returning the base projects directory path.
    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 human-readable 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

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

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