Skip to main content
Glama
mickm3n

Roam Research MCP Server

by mickm3n

get_page_content

Retrieve structured content from a specific Roam Research page, including all nested child blocks up to five levels deep. Returns hierarchical markdown with timestamps, enabling easy integration and analysis of page data.

Instructions

Get the complete content of a specific page in Roam Research with all nested child blocks.

Retrieves all blocks on the specified page with their hierarchical structure, including nested children up to 5 levels deep. Returns content in markdown format with proper indentation to reflect the block hierarchy. Args: page_name: Exact name of the page to retrieve (case-sensitive) Returns: JSON string containing: - result: Array of blocks with content and timestamps - Each block includes: content (markdown), timestamp (edit time) Examples: get_page_content("Daily Notes") get_page_content("Project Planning") get_page_content("信用卡")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_nameYes

Implementation Reference

  • main.py:389-417 (handler)
    MCP tool handler for get_page_content, decorated with @mcp.tool(). Calls the underlying Roam client method and returns JSON response. Includes docstring defining input schema and output format.
    @mcp.tool() async def get_page_content(page_name: str) -> str: """Get the complete content of a specific page in Roam Research with all nested child blocks. Retrieves all blocks on the specified page with their hierarchical structure, including nested children up to 5 levels deep. Returns content in markdown format with proper indentation to reflect the block hierarchy. Args: page_name: Exact name of the page to retrieve (case-sensitive) Returns: JSON string containing: - result: Array of blocks with content and timestamps - Each block includes: content (markdown), timestamp (edit time) Examples: get_page_content("Daily Notes") get_page_content("Project Planning") get_page_content("信用卡") """ try: client = get_roam_client() result = client.get_page_content(page_name) return json.dumps(result, indent=2) except Exception as e: print(f"Error getting page content: {e}", file=sys.stderr) return f"Error: {str(e)}"
  • Core helper method in RoamResearchMCPServer class that implements the logic to query Roam API for page blocks, sort by timestamp, convert to hierarchical markdown, and return structured result.
    def get_page_content(self, page_name: str) -> Dict[str, Any]: """Get content of a specific page with child blocks""" # Query to get all blocks on the page with nested children query = """[:find (pull ?block [:block/string :block/uid :edit/time :block/order {:block/children [:block/string :block/uid :edit/time {:block/children [:block/string :block/uid :edit/time {:block/children [:block/string :block/uid :edit/time {:block/children [:block/string :block/uid :edit/time]}]}]}]}]) ?time :in $ ?PAGE :where [?page :node/title ?PAGE] [?block :block/page ?page] [?block :edit/time ?time] ]""" data = {"query": query, "args": [page_name]} endpoint = f"/api/graph/{self.graph_name}/q" raw_result = self._make_request("POST", endpoint, data) # Sort by time (descending) results = raw_result.get("result", []) sorted_results = sorted(results, key=lambda x: x[1], reverse=True) # Transform the result to only include markdown content with children simplified_result = [] for item in sorted_results: if item and len(item) > 0: block = item[0] timestamp = item[1] content = self._build_block_with_children(block) simplified_result.append({"content": content, "timestamp": timestamp}) return {"result": simplified_result}

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mickm3n/roam-research-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server