Skip to main content
Glama
mikeysrecipes

Logseq MCP Tools

insert_block

Adds a new bullet point as a child to an existing block in Logseq, enabling hierarchical content organization and structured note-taking.

Instructions

Inserts a new block as a child of the specified parent block.

This allows for creating hierarchical content by adding children to existing blocks.

IMPORTANT NOTES:
1. All blocks are automatically formatted as bullet points in Logseq UI
2. To create links to other pages, use double brackets: [[Page Name]]
3. The new block will be inserted at the beginning or end of the parent's children
   depending on the 'before' parameter

When inserting blocks into journal pages:
  - The block will inherit the "journal?" and "journalDay" attributes
  - "journalDay" will be in YYYYMMDD format (e.g., 20250404 for April 4, 2025)

Args:
    parent_block_id (str): The ID of the parent block to insert under.
    content (str): The content of the new block.
    properties (dict, optional): Properties to set on the new block.
    before (bool, optional): Whether to insert at the beginning of children. 
                            Default is False (append at the end).
    
Returns:
    dict: Information about the created block.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parent_block_idYes
contentYes
propertiesNo
beforeNo

Implementation Reference

  • MCP tool handler for 'insert_block'. Decorated with @mcp.tool(), defines input schema via signature and docstring, and implements logic by delegating to LogseqAPIClient.insert_block.
    @mcp.tool()
    def insert_block(parent_block_id: str, content: str, properties: Optional[Dict] = None, before: bool = False) -> Dict:
        """
        Inserts a new block as a child of the specified parent block.
        
        This allows for creating hierarchical content by adding children to existing blocks.
        
        IMPORTANT NOTES:
        1. All blocks are automatically formatted as bullet points in Logseq UI
        2. To create links to other pages, use double brackets: [[Page Name]]
        3. The new block will be inserted at the beginning or end of the parent's children
           depending on the 'before' parameter
        
        When inserting blocks into journal pages:
          - The block will inherit the "journal?" and "journalDay" attributes
          - "journalDay" will be in YYYYMMDD format (e.g., 20250404 for April 4, 2025)
        
        Args:
            parent_block_id (str): The ID of the parent block to insert under.
            content (str): The content of the new block.
            properties (dict, optional): Properties to set on the new block.
            before (bool, optional): Whether to insert at the beginning of children. 
                                    Default is False (append at the end).
            
        Returns:
            dict: Information about the created block.
        """
        """Insert a new block under the specified parent block."""
        return logseq_client.insert_block(parent_block_id, content, properties, before)
  • Helper method in LogseqAPIClient that performs the actual API call to Logseq's insertBlock or prependBlock endpoint.
    def insert_block(self, parent_block_id: str, content: str, properties: Dict = None, before: bool = False) -> Dict:
        """Insert a new block as a child of the specified parent block"""
        params = [parent_block_id, content]
        if properties:
            params.append(properties)
        
        # Choose the appropriate API method based on the 'before' parameter
        method = "logseq.Editor.insertBlock"
        if before:
            method = "logseq.Editor.prependBlock"
            
        response = self.call_api(method, params)
        if isinstance(response, dict) and "result" in response:
            return response.get("result")
        return response
  • Imports the insert_block tool from blocks.py, facilitating its exposure and registration when the tools module is imported.
    from .blocks import get_page_blocks, get_block, create_block, update_block, remove_block, insert_block, move_block, search_blocks
  • Lists 'insert_block' in __all__, ensuring it's exported from the tools package.
    "insert_block",
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing important behavioral traits: automatic bullet point formatting, link syntax requirements, insertion position logic, and inheritance rules for journal pages. It doesn't cover error conditions or rate limits, but provides substantial 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 well-structured with clear sections (purpose, important notes, journal specifics, Args, Returns), front-loads the core functionality, and every sentence adds value. No redundant information or wasted words despite comprehensive coverage.

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

Completeness4/5

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

For a 4-parameter mutation tool with no annotations and no output schema, the description provides excellent coverage of behavior, parameters, and usage context. The only gap is lack of explicit return value details beyond 'Information about the created block,' which would be helpful given no output schema.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining all 4 parameters in detail: parent_block_id's role, content's purpose, properties as optional attributes, and before's positioning logic with default behavior. The Args section adds clear semantic meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the specific action ('inserts a new block as a child'), identifies the resource ('parent block'), and distinguishes from siblings like 'create_block' (which likely creates standalone blocks) and 'create_page' (which creates pages rather than blocks). The hierarchical content creation context further clarifies the purpose.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('creating hierarchical content by adding children to existing blocks') and mentions journal page specifics. However, it doesn't explicitly state when NOT to use it or name alternatives like 'create_block' for non-hierarchical creation, which prevents a perfect score.

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

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

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