read_document
Retrieve formatted document content from Mnemosyne knowledge graphs as structured TipTap XML for processing and analysis.
Instructions
Reads document content as TipTap XML with full formatting.
Blocks: paragraph, heading (level="1-3"), bulletList, orderedList, blockquote, codeBlock (language="..."), taskList (taskItem checked="true"), horizontalRule Marks (nestable): strong, em, strike, code, mark (highlight), a (href="..."), footnote (data-footnote-content="..."), commentMark (data-comment-id="...") Lists: item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes | ||
| document_id | Yes |
Implementation Reference
- src/neem/mcp/tools/hocuspocus.py:105-144 (handler)The handler function that executes the read_document tool: authenticates, connects to Hocuspocus document channel, reads TipTap XML content and comments using DocumentReader, returns structured result.async def read_document_tool( graph_id: str, document_id: str, context: Context | None = None, ) -> dict: """Read document content as TipTap XML.""" auth = MCPAuthContext.from_context(context) auth.require_auth() try: # Connect to the document channel await hp_client.connect_document(graph_id, document_id) # Get the channel and read content channel = hp_client.get_document_channel(graph_id, document_id) if channel is None: raise RuntimeError(f"Document channel not found: {graph_id}/{document_id}") reader = DocumentReader(channel.doc) xml_content = reader.to_xml() comments = reader.get_all_comments() result = { "graph_id": graph_id, "document_id": document_id, "content": xml_content, "comments": comments, } return result except Exception as e: logger.error( "Failed to read document", extra_context={ "graph_id": graph_id, "document_id": document_id, "error": str(e), }, ) raise RuntimeError(f"Failed to read document: {e}")
- src/neem/mcp/tools/hocuspocus.py:96-104 (registration)The @server.tool decorator that registers the read_document tool, defines its name, title, description (schema metadata), and parameter types via function signature.@server.tool( name="read_document", title="Read Document Content", description="""Reads document content as TipTap XML with full formatting. Blocks: paragraph, heading (level="1-3"), bulletList, orderedList, blockquote, codeBlock (language="..."), taskList (taskItem checked="true"), horizontalRule Marks (nestable): strong, em, strike, code, mark (highlight), a (href="..."), footnote (data-footnote-content="..."), commentMark (data-comment-id="...") Lists: <bulletList><listItem><paragraph>item</paragraph></listItem></bulletList>""", )
- src/neem/mcp/server/standalone_server.py:317-317 (registration)Call to register_hocuspocus_tools which defines and registers the read_document tool (among others) to the FastMCP server instance.register_hocuspocus_tools(mcp_server)