export_collection
Export all documents from a collection into downloadable files. Preserves hierarchy and content in formats like Outline Markdown, JSON, or HTML. Use for backups, sharing, converting, or archiving content. Asynchronous operation provides status and access details upon completion.
Instructions
Exports all documents in a collection to a downloadable file.
IMPORTANT: This tool starts an asynchronous export operation which may
take time to complete. The function returns information about the
operation, including its status. When the operation is complete, the
file can be downloaded or accessed via Outline's UI. The export
preserves the document hierarchy and includes all document content and
structure in the
specified format.
Use this tool when you need to:
- Create a backup of collection content
- Share collection content outside of Outline
- Convert collection content to other formats
- Archive collection content for offline use
Args:
collection_id: The collection ID to export
format: Export format ("outline-markdown", "json", or "html")
Returns:
Information about the export operation and how to access the file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_id | Yes | ||
| format | No | outline-markdown |
Implementation Reference
- MCP tool handler for 'export_collection'. Uses OutlineClient to initiate export and returns formatted operation info.@mcp.tool( annotations=ToolAnnotations( readOnlyHint=True, destructiveHint=False, idempotentHint=True, ) ) async def export_collection( collection_id: str, format: str = "outline-markdown" ) -> str: """ Exports all documents in a collection to a downloadable file. IMPORTANT: This tool starts an asynchronous export operation which may take time to complete. The function returns information about the operation, including its status. When the operation is complete, the file can be downloaded or accessed via Outline's UI. The export preserves the document hierarchy and includes all document content and structure in the specified format. Use this tool when you need to: - Create a backup of collection content - Share collection content outside of Outline - Convert collection content to other formats - Archive collection content for offline use Args: collection_id: The collection ID to export format: Export format ("outline-markdown", "json", or "html") Returns: Information about the export operation and how to access the file """ try: client = await get_outline_client() file_operation = await client.export_collection( collection_id, format ) if not file_operation: return "Failed to start export operation." return _format_file_operation(file_operation) except OutlineClientError as e: return f"Error exporting collection: {str(e)}" except Exception as e: return f"Unexpected error: {str(e)}"
- Helper function used by the handler to format the file operation response for the user.def _format_file_operation(file_operation: Optional[Dict[str, Any]]) -> str: """Format file operation data into readable text.""" if not file_operation: return "No file operation data available." # Get the file operation details state = file_operation.get("state", "unknown") type_info = file_operation.get("type", "unknown") name = file_operation.get("name", "unknown") file_operation_id = file_operation.get("id", "") # Format output output = f"# Export Operation: {name}\n\n" output += f"State: {state}\n" output += f"Type: {type_info}\n" output += f"ID: {file_operation_id}\n\n" # Provide instructions based on the state if state == "complete": output += "The export is complete and ready to download. " output += ( "Use the ID with the appropriate download tool to retrieve " "the file.\n" ) else: output += "The export is still in progress. " output += ( f"Check the operation state again later using the ID: " f"{file_operation_id}\n" ) return output
- Core OutlineClient method that performs the HTTP POST to initiate the collection export API call.async def export_collection( self, collection_id: str, format: str = "outline-markdown" ) -> Dict[str, Any]: """ Export a collection to a file. Args: collection_id: The ID of the collection to export format: The export format (outline-markdown, json, or html) Returns: FileOperation data that can be queried for progress """ response = await self.post( "collections.export", {"id": collection_id, "format": format} ) return response.get("data", {})
- src/mcp_outline/features/documents/__init__.py:18-53 (registration)Calls collection_tools.register_tools(mcp) to register the collection tools including export_collection.def register( mcp, api_key: Optional[str] = None, api_url: Optional[str] = None ): """ Register document management features with the MCP server. Args: mcp: The FastMCP server instance api_key: Optional API key for Outline api_url: Optional API URL for Outline """ # Always register read-only tools document_search.register_tools(mcp) document_reading.register_tools(mcp) document_collaboration.register_tools(mcp) collection_tools.register_tools(mcp) # Conditionally register AI tools (can be disabled for local instances) if os.getenv("OUTLINE_DISABLE_AI_TOOLS", "").lower() not in ( "true", "1", "yes", ): ai_tools.register_tools(mcp) # Conditionally register write tools (disabled in read-only mode) if os.getenv("OUTLINE_READ_ONLY", "").lower() not in ( "true", "1", "yes", ): document_content.register_tools(mcp) document_lifecycle.register_tools(mcp) document_organization.register_tools(mcp) batch_operations.register_tools(mcp)
- src/mcp_outline/features/__init__.py:5-20 (registration)Top-level registration function called from server.py, which triggers documents.register(mcp) leading to collection tools registration.def register_all(mcp): """ Register all features with the MCP server. Args: mcp: The FastMCP server instance """ # Register health check routes health.register_routes(mcp) # Register document management features documents.register(mcp) # Register MCP resources resources.register(mcp)