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

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