create_block
Add a new bullet point block to a Logseq page with specified content, optional properties, and internal page links.
Instructions
Creates a new block on a page in the Logseq graph.
Note: Blocks are automatically formatted as bullet points in Logseq UI.
Use [[Page Name]] to create links to other pages.
Args:
page_name: The name of the page to create the block on.
content: The content of the new block.
properties: Optional properties to set on the new block.
Returns:
Information about the created block.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| page_name | Yes | ||
| properties | No |
Implementation Reference
- src/logseq_mcp/tools/blocks.py:45-61 (handler)The MCP tool handler for 'create_block', decorated with @mcp.tool(). It validates inputs via type hints and docstring, then delegates to LogseqAPIClient.create_block.@mcp.tool() def create_block(page_name: str, content: str, properties: Optional[Dict] = None) -> Dict: """ Creates a new block on a page in the Logseq graph. Note: Blocks are automatically formatted as bullet points in Logseq UI. Use [[Page Name]] to create links to other pages. Args: page_name: The name of the page to create the block on. content: The content of the new block. properties: Optional properties to set on the new block. Returns: Information about the created block. """ return logseq_client.create_block(page_name, content, properties)
- Core implementation in LogseqAPIClient that performs the HTTP API call to Logseq's 'logseq.Editor.appendBlockInPage' method to create the block.def create_block(self, page_name: str, content: str, properties: Optional[Dict] = None) -> Dict: """Create a new block on a page""" params = [page_name, content] if properties: params.append(properties) response = self.call_api("logseq.Editor.appendBlockInPage", params) if isinstance(response, dict) and "result" in response: return response.get("result") return response
- src/logseq_mcp/__init__.py:2-17 (registration)Imports and exports 'create_block' in the package __init__.py, making it available for use in the MCP server.from .utils.logging import log from .tools import ( get_all_pages, get_page, create_page, get_page_blocks, get_block, create_block, update_block, search_blocks, get_page_linked_references, ) import os import inspect __all__ = ["get_all_pages", "get_page", "create_page", "get_page_blocks", "get_block", "create_block", "update_block", "search_blocks", "get_page_linked_references"]
- src/logseq_mcp/tools/blocks.py:6-6 (helper)Initialization of the shared LogseqAPIClient instance used by all block tools, including create_block.logseq_client = LogseqAPIClient()