create_document
Create new documents in a specified collection for knowledge bases, guides, or notes. Add content via markdown, nest under parent documents, and publish immediately or save as draft.
Instructions
Creates a new document in a specified collection.
Use this tool when you need to:
- Add new content to a knowledge base
- Create documentation, guides, or notes
- Add a child document to an existing parent
- Start a new document thread or topic
Args:
title: The document title
collection_id: The collection ID to create the document in
text: Optional markdown content for the document
parent_document_id: Optional parent document ID for nesting
publish: Whether to publish the document immediately (True) or
save as draft (False)
Returns:
Result message with the new document ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_id | Yes | ||
| parent_document_id | No | ||
| publish | No | ||
| text | No | ||
| title | Yes |
Implementation Reference
- The core handler function for the 'create_document' tool. It uses the OutlineClient to POST to 'documents.create' endpoint with the provided title, collection_id, text, parent, and publish parameters.@mcp.tool( annotations=ToolAnnotations( readOnlyHint=False, destructiveHint=False, idempotentHint=False, ) ) async def create_document( title: str, collection_id: str, text: str = "", parent_document_id: Optional[str] = None, publish: bool = True, ) -> str: """ Creates a new document in a specified collection. Use this tool when you need to: - Add new content to a knowledge base - Create documentation, guides, or notes - Add a child document to an existing parent - Start a new document thread or topic Note: For Mermaid diagrams, use ```mermaidjs (not ```mermaid) as the code fence language identifier for proper rendering. Args: title: The document title collection_id: The collection ID to create the document in text: Optional markdown content for the document parent_document_id: Optional parent document ID for nesting publish: Whether to publish the document immediately (True) or save as draft (False) Returns: Result message with the new document ID """ try: client = await get_outline_client() data = { "title": title, "text": text, "collectionId": collection_id, "publish": publish, } if parent_document_id: data["parentDocumentId"] = parent_document_id response = await client.post("documents.create", data) document = response.get("data", {}) if not document: return "Failed to create document." doc_id = document.get("id", "unknown") doc_title = document.get("title", "Untitled") return f"Document created successfully: {doc_title} (ID: {doc_id})" except OutlineClientError as e: return f"Error creating document: {str(e)}" except Exception as e: return f"Unexpected error: {str(e)}"
- src/mcp_outline/features/documents/__init__.py:43-52 (registration)Conditional registration of write tools including document_content.register_tools(mcp) which registers the create_document handler, only when OUTLINE_READ_ONLY is not set.# 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/documents/__init__.py:18-19 (registration)The register function that orchestrates registration of all document tools, calling document_content.register_tools among others conditionally.def register( mcp, api_key: Optional[str] = None, api_url: Optional[str] = None
- The function signature defines the input schema via type hints: title (str required), collection_id (str required), text (str optional), parent_document_id (str optional), publish (bool default True). Returns str message with new doc ID.async def create_document( title: str, collection_id: str, text: str = "", parent_document_id: Optional[str] = None, publish: bool = True, ) -> str: