kiro_session_clear
Clear Kiro CLI session history by deleting the session.json file to manage workspace data and maintain isolated project contexts.
Instructions
Clear kiro-cli session history in working directory (deletes .kiro/session.json)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | Optional MCP session ID |
Implementation Reference
- src/kiro_cli_mcp/server.py:413-439 (handler)The handler function that implements the kiro_session_clear tool by deleting the .kiro/session.json file in the session's working directory.async def _handle_session_clear( session_manager: SessionManager, arguments: dict[str, Any] ) -> dict[str, Any]: """Handle kiro_session_clear tool call - clear kiro-cli session file.""" session_id = arguments.get("session_id") session = await session_manager.get_or_create_session(session_id) # Delete .kiro/session.json in working directory working_dir = session.working_directory or "." session_file = Path(working_dir) / ".kiro" / "session.json" if session_file.exists(): session_file.unlink() logger.info(f"Cleared kiro-cli session file: {session_file}") return { "success": True, "message": f"Cleared kiro-cli session in {working_dir}", "path": str(session_file), } else: return { "success": False, "message": "No kiro-cli session file found", "path": str(session_file), }
- src/kiro_cli_mcp/tools.py:217-229 (schema)The input schema definition for the kiro_session_clear tool, specifying an optional session_id parameter.{ "name": "kiro_session_clear", "description": "Clear kiro-cli session history in working directory (deletes .kiro/session.json)", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "Optional MCP session ID" } } } },
- src/kiro_cli_mcp/server.py:127-128 (registration)The dispatch registration in the main handle_call_tool function that routes calls to the kiro_session_clear handler.elif name == "kiro_session_clear": result = await _handle_session_clear(session_manager, arguments)