Skip to main content
Glama
es6kr

claude-session-manager

by es6kr

delete_session

Remove a specific session from the Claude Code Session Manager by moving it to a backup folder for potential recovery.

Instructions

Delete a session (moves to .bak folder for recovery)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesProject folder name
session_idYesSession ID to delete

Implementation Reference

  • Core handler function that implements the delete_session tool logic: locates the session JSONL file and either deletes it if empty or moves it to a .bak backup directory.
    def delete_session(project_name: str, session_id: str) -> bool:
        """Delete a session (move to .bak folder, or delete if empty)."""
        base_path = get_base_path()
        project_path = base_path / project_name
        jsonl_file = project_path / f"{session_id}.jsonl"
    
        if not jsonl_file.exists():
            return False
    
        # If file is empty (0 bytes), just delete it without backing up
        if jsonl_file.stat().st_size == 0:
            jsonl_file.unlink()
            return True
    
        backup_dir = base_path / ".bak"
        backup_dir.mkdir(exist_ok=True)
        backup_file = backup_dir / f"{project_name}_{session_id}.jsonl"
        jsonl_file.rename(backup_file)
        return True
  • MCP tool registration for delete_session, including name, description, and input schema definition.
    Tool(
        name="delete_session",
        description="Delete a session (moves to .bak folder for recovery)",
        inputSchema={
            "type": "object",
            "properties": {
                "project_name": {
                    "type": "string",
                    "description": "Project folder name"
                },
                "session_id": {
                    "type": "string",
                    "description": "Session ID to delete"
                }
            },
            "required": ["project_name", "session_id"]
        }
    ),
  • Dispatch handler within the main @mcp.call_tool() function that handles the delete_session tool call by extracting parameters and invoking the core delete_session function.
    elif name == "delete_session":
        project_name = arguments.get("project_name", "")
        session_id = arguments.get("session_id", "")
        success = delete_session(project_name, session_id)
        result = {"success": success, "message": "Session deleted (backed up to .bak)" if success else "Failed to delete session"}
  • Input schema definition for the delete_session tool, specifying required project_name and session_id parameters.
    inputSchema={
        "type": "object",
        "properties": {
            "project_name": {
                "type": "string",
                "description": "Project folder name"
            },
            "session_id": {
                "type": "string",
                "description": "Session ID to delete"
            }
        },
        "required": ["project_name", "session_id"]
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that deletion moves sessions to a .bak folder for recovery, which is useful behavioral context beyond basic deletion. However, it lacks details on permissions, side effects, or error handling, leaving gaps for a mutation tool.

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 front-loads the core action and includes a key behavioral detail (.bak folder recovery). There is zero waste, making it appropriately sized and well-structured.

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 mutation tool with no annotations and no output schema, the description provides basic purpose and a recovery mechanism but lacks details on return values, error conditions, or full behavioral context. It's minimally adequate but has clear gaps given the complexity.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters (project_name and session_id). The description doesn't add any additional meaning or context about these parameters beyond what the schema provides, meeting the baseline for high coverage.

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 action ('Delete') and resource ('a session'), specifying that it moves to a .bak folder for recovery. However, it doesn't explicitly differentiate from sibling tools like clear_sessions or delete_message, which prevents a perfect score.

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?

No guidance is provided on when to use this tool versus alternatives like clear_sessions or delete_message. The description mentions recovery via .bak folder, but doesn't specify prerequisites, exclusions, or comparative contexts with siblings.

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