Skip to main content
Glama
dailydaniel

Logseq MCP Server

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)
                    )
                )
            ]
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states what the tool does but lacks behavioral details: it doesn't specify if this requires an active Logseq session, what happens if no current page exists (error vs. null), the format of 'hierarchical block structure' (e.g., tree vs. list), or any rate limits. The description is minimal and misses key operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero waste. It front-loads the core action and resource ('Get hierarchical block structure of current page'), making it immediately understandable. Every word earns its place, and there's no fluff or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that fetches structured data. It doesn't explain the return format (e.g., JSON tree), error conditions, or dependencies like needing an open page. For a read operation with potential complexity in output, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately adds no parameter details, avoiding redundancy. A baseline of 4 is applied for zero parameters, as it efficiently omits unnecessary information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('hierarchical block structure of current page'), making the purpose understandable. It distinguishes from siblings like 'logseq_get_page_content' by specifying 'current page' rather than any page. However, it doesn't explicitly contrast with 'logseq_get_current_page' (which might return metadata vs. content), leaving slight ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a current page open), exclusions, or comparisons to siblings like 'logseq_get_page_content' (for arbitrary pages) or 'logseq_get_editing_block_content' (for focused editing). Usage is implied by 'current page' but not explicitly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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