dooray_files
Manage Dooray project files by listing task attachments, retrieving file metadata, and downloading content from tasks or drive storage.
Instructions
Manage Dooray files and images - list task files, get file metadata, download file content from tasks or directly by content ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform on files | |
| taskId | No | Task ID (required for task file actions) | |
| fileId | No | File ID (required for file operations) | |
| projectId | No | Project ID (optional - uses default from environment if not provided, required for task file actions) |
Implementation Reference
- src/dooray_mcp/tools/files.py:20-50 (handler)Core handler function for the dooray_files tool. Dispatches to specific action handlers based on the 'action' parameter.async def handle(self, arguments: Dict[str, Any]) -> str: """Handle files tool requests. Args: arguments: Tool arguments containing action and parameters Returns: JSON string with results """ action = arguments.get("action") if not action: return json.dumps({"error": "Action parameter is required"}) try: if action == "list_task_files": return await self._list_task_files(arguments) elif action == "get_task_file_metadata": return await self._get_task_file_metadata(arguments) elif action == "get_task_file_content": return await self._get_task_file_content(arguments) elif action == "get_drive_file_metadata": return await self._get_drive_file_metadata(arguments) elif action == "get_drive_file_content": return await self._get_drive_file_content(arguments) else: return json.dumps({"error": f"Unknown action: {action}"}) except Exception as e: logger.error(f"Error in files tool: {e}") return json.dumps({"error": str(e)})
- src/dooray_mcp/server.py:256-282 (schema)Input schema and tool description for dooray_files, defining available actions and parameters.types.Tool( name="dooray_files", description="Manage Dooray files and images - list task files, get file metadata, download file content from tasks or directly by content ID", inputSchema={ "type": "object", "properties": { "action": { "type": "string", "enum": ["list_task_files", "get_task_file_metadata", "get_task_file_content", "get_drive_file_metadata", "get_drive_file_content"], "description": "Action to perform on files" }, "taskId": { "type": "string", "description": "Task ID (required for task file actions)" }, "fileId": { "type": "string", "description": "File ID (required for file operations)" }, "projectId": { "type": "string", "description": "Project ID (optional - uses default from environment if not provided, required for task file actions)" } }, "required": ["action"] } ),
- src/dooray_mcp/server.py:370-372 (registration)Registration in the tool dispatcher: instantiates FilesTool and calls its handle method for dooray_files invocations.elif name == "dooray_files": tool = FilesTool(dooray_client) result = await tool.handle(args)
- src/dooray_mcp/tools/files.py:74-118 (helper)Helper method implementing file download from task attachments, including saving to temporary directory with safe filename.async def _get_task_file_content(self, arguments: Dict[str, Any]) -> str: """Get content of a file attached to a task and save to temporary file.""" project_id = arguments.get("projectId") task_id = arguments.get("taskId") file_id = arguments.get("fileId") if not project_id or not task_id or not file_id: return json.dumps({"error": "projectId, taskId, and fileId are required for get_task_file_content action"}) try: # Get file metadata first to get filename metadata = await self.client.get_task_file_metadata(project_id, task_id, file_id) filename = metadata.get("result", {}).get("name", f"file_{file_id}") # Download file content content = await self.client.get_task_file_content(project_id, task_id, file_id) # Create temporary file temp_dir = tempfile.gettempdir() dooray_temp_dir = os.path.join(temp_dir, "dooray_files") os.makedirs(dooray_temp_dir, exist_ok=True) # Use original filename but ensure it's safe safe_filename = self._make_safe_filename(filename) temp_file_path = os.path.join(dooray_temp_dir, f"{task_id}_{file_id}_{safe_filename}") # Write content to file with open(temp_file_path, 'wb') as f: f.write(content) result = { "file_path": temp_file_path, "filename": filename, "size": len(content), "content_type": "file", "task_id": task_id, "file_id": file_id } return json.dumps(result, ensure_ascii=False) except Exception as e: logger.error(f"Error downloading task file: {e}") return json.dumps({"error": f"Failed to download file: {str(e)}"})
- src/dooray_mcp/tools/files.py:51-61 (helper)Helper method to list files attached to a specific task.async def _list_task_files(self, arguments: Dict[str, Any]) -> str: """List files attached to a task.""" project_id = arguments.get("projectId") task_id = arguments.get("taskId") if not project_id or not task_id: return json.dumps({"error": "projectId and taskId are required for list_task_files action"}) result = await self.client.list_task_files(project_id, task_id) return json.dumps(result, ensure_ascii=False)