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

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