Skip to main content
Glama

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",

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