Skip to main content
Glama
ergut

MCP server for LogSeq

by ergut

list_pages

Retrieve all pages from a LogSeq graph, with an option to filter out journal entries for focused content management.

Instructions

Lists all pages in a LogSeq graph.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_journalsNoWhether to include journal/daily notes in the list

Implementation Reference

  • ListPagesToolHandler class: implements the core logic for the list_pages tool. Handles arguments, calls LogSeq API to list pages, filters journal pages based on include_journals param, formats and sorts the page list, and returns formatted text output.
    class ListPagesToolHandler(ToolHandler):
        def __init__(self):
            super().__init__("list_pages")
    
        def get_tool_description(self):
            return Tool(
                name=self.name,
                description="Lists all pages in a LogSeq graph.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "include_journals": {
                            "type": "boolean",
                            "description": "Whether to include journal/daily notes in the list",
                            "default": False
                        }
                    },
                    "required": []
                }
            )
        
        def run_tool(self, args: dict) -> list[TextContent]:
            include_journals = args.get("include_journals", False)
            
            try:
                api = logseq.LogSeq(api_key=api_key)
                result = api.list_pages()
                
                # Format pages for display
                pages_info = []
                for page in result:
                    # Skip if it's a journal page and we don't want to include those
                    is_journal = page.get('journal?', False)
                    if is_journal and not include_journals:
                        continue
                    
                    # Get page information
                    name = page.get('originalName') or page.get('name', '<unknown>')
                    
                    # Build page info string
                    info_parts = [f"- {name}"]
                    if is_journal:
                        info_parts.append("[journal]")
                        
                    pages_info.append(" ".join(info_parts))
                
                # Sort alphabetically by page name
                pages_info.sort()
                
                # Build response
                count_msg = f"\nTotal pages: {len(pages_info)}"
                journal_msg = " (excluding journal pages)" if not include_journals else " (including journal pages)"
                
                response = "LogSeq Pages:\n\n" + "\n".join(pages_info) + count_msg + journal_msg
                
                return [TextContent(type="text", text=response)]
                
            except Exception as e:
                logger.error(f"Failed to list pages: {str(e)}")
                raise
  • Tool schema definition for list_pages: defines optional boolean input 'include_journals' with default False.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Lists all pages in a LogSeq graph.",
            inputSchema={
                "type": "object",
                "properties": {
                    "include_journals": {
                        "type": "boolean",
                        "description": "Whether to include journal/daily notes in the list",
                        "default": False
                    }
                },
                "required": []
            }
        )
  • Registration of the ListPagesToolHandler instance in the MCP server during tool handler setup.
    add_tool_handler(tools.ListPagesToolHandler())
  • Underlying LogSeq API method list_pages(): makes HTTP POST to LogSeq's logseq.Editor.getAllPages RPC to retrieve all pages.
    def list_pages(self) -> Any:
        """List all pages in the LogSeq graph."""
        url = self.get_base_url()
        logger.info("Listing pages")
        
        try:
            response = requests.post(
                url,
                headers=self._get_headers(),
                json={
                    "method": "logseq.Editor.getAllPages",
                    "args": []
                },
                verify=self.verify_ssl,
                timeout=self.timeout
            )
            response.raise_for_status()
            return response.json()
    
        except Exception as e:
            logger.error(f"Error listing pages: {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 the full burden of behavioral disclosure. It states the tool lists pages but doesn't mention any behavioral traits such as pagination, rate limits, permissions required, or what the output format looks like. This leaves significant gaps for a tool that presumably returns a list of resources.

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 purpose without any wasted words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the output contains (e.g., page names, metadata, or structure), which is critical for a list operation. For a tool with no structured behavioral hints, this leaves the agent under-informed.

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 the parameter 'include_journals' clearly documented. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without compensating value.

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 tool's purpose with a specific verb ('Lists') and resource ('all pages in a LogSeq graph'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'search' or 'get_page_content', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search' (for filtered results) or 'get_page_content' (for detailed page data). It lacks any context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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