Skip to main content
Glama

insert_block

Add a new block as a child to an existing parent block in Logseq. Specify content, optional properties, and position (beginning or end) to organize hierarchical knowledge structures efficiently.

Instructions

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

Creates hierarchical content by adding children to existing blocks.
The new block is inserted at the beginning (before=True) or end (before=False)
of the parent's children.

Args:
    parent_block_id: The ID of the parent block to insert under.
    content: The content of the new block.
    properties: Optional properties to set on the new block.
    before: Whether to insert at the beginning of children (default: False).
    
Returns:
    Information about the created block.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
beforeNo
contentYes
parent_block_idYes
propertiesNo

Implementation Reference

  • MCP tool handler for 'insert_block', decorated with @mcp.tool() for automatic registration and schema generation from signature/docstring. Delegates 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.
        
        Creates hierarchical content by adding children to existing blocks.
        The new block is inserted at the beginning (before=True) or end (before=False)
        of the parent's children.
        
        Args:
            parent_block_id: The ID of the parent block to insert under.
            content: The content of the new block.
            properties: Optional properties to set on the new block.
            before: Whether to insert at the beginning of children (default: False).
            
        Returns:
            Information about the created block.
        """
        return logseq_client.insert_block(parent_block_id, content, properties, before)
  • Core implementation in LogseqAPIClient that calls the Logseq API ('logseq.Editor.insertBlock' or 'prependBlock') based on parameters.
    def insert_block(self, parent_block_id: str, content: str, properties: Optional[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
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses key behavioral traits: the tool creates new content (mutation operation), specifies insertion position logic (beginning vs end), and mentions hierarchical relationships. However, it doesn't cover permissions needed, error conditions, or rate limits.

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?

Perfectly structured with purpose statement, usage context, parameter explanations, and return value note. Every sentence earns its place: first states core function, second explains hierarchical context, third details insertion logic, Args section documents parameters efficiently, Returns section sets expectations.

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 good coverage: clear purpose, usage context, parameter semantics, and behavioral aspects like insertion position. The main gap is lack of output details (only mentions 'Information about the created block' without specifics).

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?

With 0% schema description coverage, the description compensates well by explaining all 4 parameters in the Args section. It clarifies parent_block_id's role, content's purpose, properties as optional settings, and before's positional logic with default behavior. This adds substantial 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') and resource ('as a child of the specified parent block'), distinguishing it from sibling tools like create_block (which likely creates standalone blocks) and move_block (which repositions existing blocks). The hierarchical nature is explicitly mentioned.

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 about when to use this tool ('Creates hierarchical content by adding children to existing blocks'), but doesn't explicitly mention when not to use it or name specific alternatives. It implies usage for adding child blocks to existing parents rather than creating standalone blocks.

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

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