Skip to main content
Glama

search_blocks

Locate specific blocks in your Logseq graph by using queries to search for terms, pages, or references, streamlining content discovery and organization.

Instructions

Searches for blocks matching a query in the Logseq graph.

Query examples:
- page:"Page Name" - blocks on a specific page
- "search term" - blocks containing the term
- [[Page Name]] - references to a specific page

Args:
    query: The search query.
    
Returns:
    List of blocks matching the search query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The MCP tool handler for search_blocks, decorated with @mcp.tool(), which implements the tool logic by calling logseq_client.search_blocks(query). Includes type hints and docstring defining the input/output schema.
    @mcp.tool()
    def search_blocks(query: str) -> List[Dict]:
        """
        Searches for blocks matching a query in the Logseq graph.
        
        Query examples:
        - page:"Page Name" - blocks on a specific page
        - "search term" - blocks containing the term
        - [[Page Name]] - references to a specific page
        
        Args:
            query: The search query.
            
        Returns:
            List of blocks matching the search query.
        """
        return logseq_client.search_blocks(query)
  • Supporting method in LogseqAPIClient that performs the actual API call to Logseq's 'logseq.Editor.search' endpoint with the query, handling response parsing.
    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 []
  • Import of the search_blocks tool from blocks.py into the tools package, exposing it for higher-level imports.
    from .blocks import get_page_blocks, get_block, create_block, update_block, remove_block, insert_block, move_block, search_blocks
  • Export of search_blocks in the package __all__, making it available when importing * from the main package.
    __all__ = ["get_all_pages", "get_page", "create_page", "get_page_blocks", "get_block", "create_block", "update_block", "search_blocks", "get_page_linked_references"]
Behavior3/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 adequately describes the core behavior (searching for blocks matching a query) and provides helpful query syntax examples, but doesn't address important behavioral aspects like whether results are paginated, sorted, or limited; what happens with no matches; or any performance considerations. The description adds value but leaves gaps in behavioral transparency.

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 perfectly structured and economical. It begins with the core purpose statement, follows with practical query examples in a bulleted format, then clearly documents the single parameter and return value. Every sentence earns its place, with no redundant or unnecessary information. The formatting with clear sections enhances readability.

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 and no output schema, the description provides excellent coverage of the core functionality, parameter usage, and return type. The query examples are particularly valuable. The main gap is the lack of information about the return format - while it states 'List of blocks matching the search query,' it doesn't specify what fields blocks contain or their structure. Given the tool's relative simplicity, this is a minor omission.

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 for the single parameter, the description fully compensates by providing rich semantic information about the 'query' parameter. It not only explains what the parameter is ('The search query') but provides three concrete examples with different syntax patterns, giving the agent practical guidance on how to construct effective queries. This goes well beyond what the bare schema provides.

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 specific action ('searches for blocks matching a query') and resource ('in the Logseq graph'), distinguishing it from sibling tools like get_block, get_page_blocks, or get_page_linked_references which retrieve specific blocks or pages without search functionality. The verb+resource combination is precise and unambiguous.

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 for when to use this tool through query examples that demonstrate different search scenarios, such as finding blocks on a specific page or containing a term. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools, though the examples imply it's for flexible searching rather than direct retrieval.

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

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

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