Skip to main content
Glama

logseq_get_current_page_content

Retrieve the hierarchical block structure of the current page in Logseq, enabling LLMs to programmatically access and manage content within your knowledge graph.

Instructions

Get hierarchical block structure of current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main tool handler: calls Logseq API 'logseq.Editor.getCurrentPageBlocksTree' with no arguments and formats the hierarchical blocks tree result for output.
    elif name == "logseq_get_current_page_content": result = make_request("logseq.Editor.getCurrentPageBlocksTree", []) return [TextContent( type="text", text=format_blocks_tree(result) )]
  • Tool registration in MCP server.list_tools(), defining name, description, and input schema (empty).
    Tool( name="logseq_get_current_page_content", description="Get hierarchical block structure of current page", inputSchema=GetCurrentBlocksTreeParams.model_json_schema() # No parameters ),
  • Pydantic model defining the input schema for the tool (no parameters required).
    class GetCurrentBlocksTreeParams(LogseqBaseModel): pass
  • Supporting function that recursively formats the Logseq blocks into a readable tree structure with indentation.
    def format_blocks_tree(blocks: list) -> str: """Format hierarchical block structure""" def print_tree(block, level=0): output = [] prefix = " " * level + "- " output.append(f"{prefix}{block.get('content', '')}") for child in block.get('children', []): output.extend(print_tree(child, level + 1)) return output return "\n".join( line for block in blocks for line in print_tree(block) )
  • Prompt handler variant: similar logic for get_prompt() when used as a prompt.
    elif name == "logseq_get_current_page_content": result = make_request("logseq.Editor.getCurrentPageBlocksTree", []) return GetPromptResult( description="Current page content", messages=[ PromptMessage( role="user", content=TextContent( type="text", text=format_blocks_tree(result) ) ) ] )

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/dailydaniel/logseq-mcp'

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