logseq_create_page
Create new Logseq pages with customizable properties, tags, and formats. Automate journal page creation with date formatting and initial blocks for efficient knowledge management.
Instructions
Create a new page in Logseq with optional properties. Features: - Journal page creation with date formatting - Custom page properties (tags, status, etc.) - Format selection (Markdown/Org-mode) - Automatic first block creation Perfect for template-based page creation and knowledge management.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| create_first_block | No | Create initial block | |
| format | No | Page format | markdown |
| journal | No | Journal page flag | |
| page_name | Yes | Name of the page to create | |
| properties | No | Page properties |
Implementation Reference
- src/mcp_server_logseq/server.py:483-501 (handler)Handler function that executes the logseq_create_page tool: parses CreatePageParams, calls Logseq API 'logseq.Editor.createPage', formats result with format_page_result.elif name == "logseq_create_page": args = CreatePageParams(**arguments) result = make_request( "logseq.Editor.createPage", [ args.page_name, args.properties or {}, { "journal": args.journal, "format": args.format, "createFirstBlock": args.create_first_block } ] ) return [TextContent( type="text", text=format_page_result(result) )]
- Pydantic schema/model for input parameters of logseq_create_page tool, including validation for properties.class CreatePageParams(LogseqBaseModel): """Parameters for creating a new page in Logseq.""" page_name: Annotated[ str, Field(description="Name of the page to create") ] properties: Annotated[ Optional[dict], Field(default=None, description="Page properties") ] journal: Annotated[ Optional[bool], Field(default=False, description="Journal page flag") ] format: Annotated[ Optional[str], Field(default="markdown", description="Page format") ] create_first_block: Annotated[ Optional[bool], Field(default=True, description="Create initial block") ] @field_validator('properties', mode='before') @classmethod def parse_properties(cls, value): """Parse properties from JSON string if needed""" if isinstance(value, str): try: return json.loads(value) except json.JSONDecodeError: raise ValueError("Invalid JSON format for properties") return value or {}
- src/mcp_server_logseq/server.py:227-237 (registration)Tool registration in list_tools(): defines name, description, and inputSchema from CreatePageParams.Tool( name="logseq_create_page", description="""Create a new page in Logseq with optional properties. Features: - Journal page creation with date formatting - Custom page properties (tags, status, etc.) - Format selection (Markdown/Org-mode) - Automatic first block creation Perfect for template-based page creation and knowledge management.""", inputSchema=CreatePageParams.model_json_schema(), ),
- src/mcp_server_logseq/server.py:305-324 (registration)Prompt registration in list_prompts(): defines arguments for logseq_create_page.name="logseq_create_page", description="Create a new Logseq page", arguments=[ PromptArgument( name="page_name", description="Name of the page to create", required=True, ), PromptArgument( name="properties", description="Optional page properties as JSON", required=False, ), PromptArgument( name="journal", description="Set true for journal pages", required=False, ), ], ),
- Helper function to format the result of page creation for user-friendly output.def format_page_result(result: dict) -> str: """Format page creation result into readable text.""" properties = "".join( f" {key}: {value}\n" for key, value in result.get('propertiesTextValues', {}).items() ) properties_text = "\n" + properties if properties else " None" return ( f"Created page: {result.get('name')}\n" f"UUID: {result.get('uuid')}\n" f"Journal: {result.get('journal', False)}\n" f"Properties: {properties_text}" )