Skip to main content
Glama
ergut

MCP server for LogSeq

by ergut

create_page

Add new pages to LogSeq with specified titles and content using API integration.

Instructions

Create a new page in LogSeq.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the new page
contentYesContent of the new page

Implementation Reference

  • The CreatePageToolHandler class defines the 'create_page' tool handler, including its schema, description, and execution logic. It validates inputs, creates a LogSeq API client, calls create_page on it, and returns success message.
    class CreatePageToolHandler(ToolHandler):
        def __init__(self):
            super().__init__("create_page")
    
        def get_tool_description(self):
            return Tool(
                name=self.name,
                description="Create a new page in LogSeq.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "title": {
                            "type": "string",
                            "description": "Title of the new page"
                        },
                        "content": {
                            "type": "string",
                            "description": "Content of the new page"
                        }
                    },
                    "required": ["title", "content"]
                }
            )
    
        def run_tool(self, args: dict) -> list[TextContent]:
            if "title" not in args or "content" not in args:
                raise RuntimeError("title and content arguments required")
    
            try:
                api = logseq.LogSeq(api_key=api_key)
                api.create_page(args["title"], args["content"])
                
                return [TextContent(
                    type="text",
                    text=f"Successfully created page '{args['title']}'"
                )]
            except Exception as e:
                logger.error(f"Failed to create page: {str(e)}")
                raise
  • Registration of the CreatePageToolHandler instance in the MCP server using add_tool_handler.
    add_tool_handler(tools.CreatePageToolHandler())
  • Input schema definition for the create_page tool, specifying title and content as required string properties.
    return Tool(
        name=self.name,
        description="Create a new page in LogSeq.",
        inputSchema={
            "type": "object",
            "properties": {
                "title": {
                    "type": "string",
                    "description": "Title of the new page"
                },
                "content": {
                    "type": "string",
                    "description": "Content of the new page"
                }
            },
            "required": ["title", "content"]
        }
    )
  • The LogSeq client's create_page method that handles the actual API calls to Logseq.Editor.createPage and optionally appendBlockInPage to create the page with content.
    def create_page(self, title: str, content: str = "") -> Any:
        """Create a new LogSeq page with specified title and content."""
        url = self.get_base_url()
        logger.info(f"Creating page '{title}'")
        
        try:
            # Step 1: Create the page
            response = requests.post(
                url,
                headers=self._get_headers(),
                json={
                    "method": "logseq.Editor.createPage",
                    "args": [title, {}, {"createFirstBlock": True}]
                },
                verify=self.verify_ssl,
                timeout=self.timeout
            )
            response.raise_for_status()
            page_result = response.json()
            
            # Step 2: Add content if provided
            if content and content.strip():
                response = requests.post(
                    url,
                    headers=self._get_headers(),
                    json={
                        "method": "logseq.Editor.appendBlockInPage",
                        "args": [title, content]
                    },
                    verify=self.verify_ssl,
                    timeout=self.timeout
                )
                response.raise_for_status()
            
            return page_result
    
        except Exception as e:
            logger.error(f"Error creating page: {str(e)}")
            raise
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Create' implies a write operation, it doesn't specify whether this requires authentication, what happens if a page with the same title already exists (overwrite, error, or duplicate), or if there are rate limits. This leaves significant gaps for a mutation tool.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's appropriately sized for a simple creation tool and front-loads the essential information.

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

Completeness3/5

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

For a creation tool with 2 parameters and no output schema, the description is minimally adequate but incomplete. It lacks behavioral details (like error handling or permissions) and doesn't explain the return value, leaving the agent uncertain about what happens after invocation. The high schema coverage helps but doesn't fully compensate for missing context.

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

Parameters3/5

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

The input schema has 100% description coverage, with clear documentation for both 'title' and 'content' parameters. The description adds no additional semantic context beyond what's in the schema, such as formatting requirements or examples. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Create') and resource ('new page in LogSeq'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'update_page' which also modifies page content, nor does it specify what type of page is being created (e.g., note, document, wiki page).

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

Usage Guidelines2/5

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

No guidance is provided about when to use this tool versus alternatives like 'update_page' for modifying existing pages. The description doesn't mention prerequisites, such as whether the page title must be unique or if there are constraints on where pages can be created within LogSeq's structure.

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

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