delete_chatmode
Remove unwanted chatmode files in the VS Code prompts directory by specifying the filename, streamlining prompt management in Mode Manager MCP.
Instructions
Delete a VS Code .chatmode.md file from the prompts directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | The filename of the chatmode to delete (with or without extension) |
Implementation Reference
- The main handler function for the 'delete_chatmode' tool. It checks if read-only mode is active, calls the chatmode_manager's delete method, and returns a success or error message.def delete_chatmode( filename: Annotated[str, "The filename of the chatmode to delete (with or without extension)"], ) -> str: """Delete a VS Code .chatmode.md file from the prompts directory.""" if read_only: return "Error: Server is running in read-only mode" try: success = chatmode_manager.delete_chatmode(filename) if success: return f"Successfully deleted VS Code chatmode: {filename}" else: return f"Failed to delete VS Code chatmode: {filename}" except Exception as e: return f"Error deleting VS Code chatmode '{filename}': {str(e)}"
- src/mode_manager_mcp/tools/chatmode_tools.py:160-176 (registration)Registration of the 'delete_chatmode' tool using the MCP @app.tool decorator, including description, tags, schema annotations for parameters and return type, and metadata.@app.tool( name="delete_chatmode", description="Delete a VS Code .chatmode.md file from the prompts directory.", tags={"public", "chatmode"}, annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Delete Chatmode", "parameters": { "filename": "The filename of the chatmode to delete. If a full filename is provided, it will be used as-is. Otherwise, .chatmode.md will be appended automatically. You can provide just the name (e.g. my-chatmode) or the full filename (e.g. my-chatmode.chatmode.md)." }, "returns": "Returns a success message if the chatmode was deleted, or an error message if the operation failed or the file was not found.", }, meta={ "category": "chatmode", }, )
- Input schema and output description defined in the tool annotations, specifying the 'filename' parameter and return message format.annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Delete Chatmode", "parameters": { "filename": "The filename of the chatmode to delete. If a full filename is provided, it will be used as-is. Otherwise, .chatmode.md will be appended automatically. You can provide just the name (e.g. my-chatmode) or the full filename (e.g. my-chatmode.chatmode.md)." }, "returns": "Returns a success message if the chatmode was deleted, or an error message if the operation failed or the file was not found.", },
- Helper method in ChatModeManager class that implements the core deletion logic: normalizes filename, checks existence, performs safe deletion with backup using safe_delete_file, and logs the action.def delete_chatmode(self, filename: str) -> bool: """ Delete a chatmode file with automatic backup. Args: filename: Name of the .chatmode.md file Returns: True if successful Raises: FileOperationError: If file cannot be deleted """ # Ensure filename has correct extension if not filename.endswith(".chatmode.md"): filename += ".chatmode.md" file_path = self.prompts_dir / filename if not file_path.exists(): raise FileOperationError(f"Chatmode file not found: {filename}") try: # Use safe delete which creates backup automatically safe_delete_file(file_path, create_backup=True) logger.info(f"Deleted chatmode file with backup: {filename}") return True except Exception as e: raise FileOperationError(f"Error deleting chatmode file {filename}: {e}")