delete_file
Remove the current file from the editor. This tool deletes files to manage workspace content and free up storage.
Instructions
Delete current file
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "delete_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/text_editor/server.py:775-799 (handler)The handler function for the 'delete_file' MCP tool. It deletes the currently set file (via set_file tool) using os.remove, resets the current_file_path, and returns success or error status.
@self.mcp.tool() async def delete_file() -> Dict[str, Any]: """ Delete current file """ if self.current_file_path is None: return {"error": "No file path is set. Use set_file first."} try: if not os.path.exists(self.current_file_path): return {"error": f"File '{self.current_file_path}' does not exist."} os.remove(self.current_file_path) deleted_path = self.current_file_path self.current_file_path = None return { "status": "success", "message": f"File '{deleted_path}' was successfully deleted.", } except Exception as e: return {"error": f"Error deleting file: {str(e)}"}