Skip to main content
Glama
mikeysrecipes

Logseq MCP Tools

search_blocks

Find blocks in your Logseq graph using queries for specific pages, content terms, journal dates, or page references.

Instructions

Searches for blocks matching a query in the Logseq graph.

Examples of useful queries:
- page:"Page Name" - find all blocks on a specific page
- "search term" - find blocks containing the term
- page:"Apr 4th, 2025" - find all blocks in a journal
- [[Page Name]] - find references to a specific page

Returned blocks from journal pages will include:
- "journal?": true
- "journalDay": YYYYMMDD - The date in numeric format

Args:
    query (str): The search query.
    
Returns:
    list: A list of blocks matching the search query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The main handler function for the MCP 'search_blocks' tool. Decorated with @mcp.tool() which registers it automatically with the FastMCP server. This thin wrapper delegates to the LogseqClient's search_blocks method.
    @mcp.tool()
    def search_blocks(query: str) -> List[Dict]:
        """
        Searches for blocks matching a query in the Logseq graph.
        
        Examples of useful queries:
        - page:"Page Name" - find all blocks on a specific page
        - "search term" - find blocks containing the term
        - page:"Apr 4th, 2025" - find all blocks in a journal
        - [[Page Name]] - find references to a specific page
        
        Returned blocks from journal pages will include:
        - "journal?": true
        - "journalDay": YYYYMMDD - The date in numeric format
        
        Args:
            query (str): The search query.
            
        Returns:
            list: A list of blocks matching the search query.
        """
        """Search for blocks matching the query."""
        return logseq_client.search_blocks(query)
  • The underlying helper method in LogseqAPIClient that performs the actual API call to Logseq's 'logseq.Editor.search' endpoint, handling response normalization.
    def search_blocks(self, query: str) -> List[Dict]:
        """Search for blocks matching a query"""
        response = self.call_api("logseq.Editor.search", [query])
        if isinstance(response, list):
            return response
        return response.get("result", []) if isinstance(response, dict) else []
  • The tool is exported and made available for import in the package __init__.py, ensuring it's registered when the server module is imported and run.
    __all__ = ["get_all_pages", "get_page", "create_page", "get_page_blocks", "get_block", "create_block", "update_block", "search_blocks", "get_page_linked_references"]
  • Exported in tools/__init__.py __all__, which propagates to main __init__.py.
    "search_blocks",
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that returned blocks from journal pages include specific metadata fields ('journal?' and 'journalDay'), which is valuable behavioral context. However, it doesn't mention pagination, rate limits, permission requirements, or what happens with empty/no results.

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 efficiently structured: purpose statement first, followed by categorized examples, then parameter documentation. Every sentence adds value - the examples are particularly helpful for understanding query capabilities without being verbose.

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

Completeness4/5

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

For a single-parameter search tool with no annotations or output schema, the description provides good coverage of purpose, parameter usage, and some behavioral details. The main gap is lack of output format details beyond mentioning journal fields - no information about block structure, error cases, or result limitations.

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

Parameters5/5

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

With 0% schema description coverage (schema only has title 'Query'), the description fully compensates by explaining the query parameter with multiple concrete examples and syntax patterns. It transforms a generic 'string' parameter into a meaningful search syntax with specific use cases.

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

Purpose5/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 ('searches for blocks') and resource ('in the Logseq graph'), distinguishing it from siblings like get_block (retrieves single block) or get_page_blocks (gets all blocks from a page). It provides concrete examples of what 'blocks matching a query' means.

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

Usage Guidelines4/5

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

The description provides clear context through query examples (page-specific, term-based, journal, references), giving implicit guidance on when to use this tool. However, it doesn't explicitly state when to use alternatives like get_page_blocks for all blocks on a page without filtering, or get_page_linked_references for specific reference types.

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

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