Skip to main content
Glama

obsidian_search

Read-onlyIdempotent

Search your Obsidian vault using JsonLogic queries to find notes by content, tags, patterns, or complex criteria for Zettelkasten workflows.

Instructions

Search vault using powerful JsonLogic queries.

Essential for Zettelkasten workflow: find notes by patterns, content, tags, or complex criteria.
Uses JsonLogic for flexible and powerful searches across your vault.

Args:
    params (SearchInput): Contains:
        - query (Dict): JsonLogic query object

Returns:
    str: List of matching files

Common Examples:
    1. Find all markdown files:
       {'glob': ['*.md', {'var': 'path'}]}

    2. Search for text in content (case-insensitive):
       {'in': ['search term', {'lower': [{'var': 'content'}]}]}

    3. Find files by name pattern:
       {'glob': ['*zettel*', {'var': 'path'}]}

    4. Combine conditions (files with "system" in content):
       {'and': [
           {'glob': ['*.md', {'var': 'path'}]},
           {'in': ['system', {'lower': [{'var': 'content'}]}]}
       ]}

JsonLogic Documentation: https://jsonlogic.com/
Available variables: 'path' (file path), 'content' (file content), 'stat' (file stats)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main execution handler for the 'obsidian_search' tool. It takes a JsonLogic query, sends it to the Obsidian API via obsidian_client.post('/search/'), processes the results into a formatted list of matching files, handles truncation and errors.
    async def search_vault(params: SearchInput) -> str:
        """Search vault using powerful JsonLogic queries.
    
        Essential for Zettelkasten workflow: find notes by patterns, content, tags, or complex criteria.
        Uses JsonLogic for flexible and powerful searches across your vault.
    
        Args:
            params (SearchInput): Contains:
                - query (Dict): JsonLogic query object
    
        Returns:
            str: List of matching files
    
        Common Examples:
            1. Find all markdown files:
               {'glob': ['*.md', {'var': 'path'}]}
    
            2. Search for text in content (case-insensitive):
               {'in': ['search term', {'lower': [{'var': 'content'}]}]}
    
            3. Find files by name pattern:
               {'glob': ['*zettel*', {'var': 'path'}]}
    
            4. Combine conditions (files with "system" in content):
               {'and': [
                   {'glob': ['*.md', {'var': 'path'}]},
                   {'in': ['system', {'lower': [{'var': 'content'}]}]}
               ]}
    
        JsonLogic Documentation: https://jsonlogic.com/
        Available variables: 'path' (file path), 'content' (file content), 'stat' (file stats)
        """
        try:
            # Use special content type for JsonLogic queries
            result = await obsidian_client.post(
                "/search/",
                params.query,  # Send query directly, not wrapped
                content_type="application/vnd.olrapi.jsonlogic+json"
            )
    
            # API returns array of {filename, result} objects
            if not result or not isinstance(result, list):
                return "No files matched the search criteria."
    
            # Filter for successful matches
            matches = [item["filename"] for item in result if item.get("result")]
    
            if not matches:
                return "No files matched the search criteria."
    
            output = [f"# Search Results\n"]
            output.append(f"Found {len(matches)} matching files\n")
    
            for filepath in matches:
                output.append(f"- đź“„ {filepath}")
    
            response = "\n".join(output)
            return truncate_response(response, "search results")
            
        except ObsidianAPIError as e:
            return json.dumps({
                "error": str(e),
                "success": False
            }, indent=2)
  • Pydantic input model defining the parameters for the obsidian_search tool: a JsonLogic query dictionary.
    class SearchInput(BaseModel):
        """Input for vault searches using JsonLogic queries."""
        model_config = ConfigDict(extra='forbid')
    
        query: Dict[str, Any] = Field(
            description="JsonLogic query object for searching vault. Examples: {'glob': ['*.md', {'var': 'path'}]} for all markdown files, {'in': ['search term', {'lower': [{'var': 'content'}]}]} for text search"
        )
  • MCP tool registration decorator that binds the name 'obsidian_search' to the search_vault handler function with appropriate annotations.
    @mcp.tool(
        name="obsidian_search",
        annotations={
            "title": "Search Vault",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
Behavior4/5

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

Annotations already provide key behavioral hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true), indicating a safe, non-destructive operation. The description adds valuable context beyond this: it specifies the search scope ('across your vault'), mentions the use of JsonLogic for flexibility, and provides documentation links and available variables ('path', 'content', 'stat'), enhancing transparency without contradicting annotations.

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 well-structured and appropriately sized. It front-loads the core purpose, follows with usage context, details parameters with examples, and concludes with documentation. Every sentence adds value—no redundancy or fluff—making it efficient and easy to parse for an AI agent.

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

Completeness5/5

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

Given the tool's complexity (query-based searching), low schema coverage (0%), and presence of an output schema (returns a list of matching files), the description is highly complete. It covers purpose, usage, parameter details with examples, behavioral context, and external resources, leaving no gaps for the agent to understand and invoke the tool correctly.

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?

The input schema has 0% description coverage, so the description fully compensates by detailing the parameter semantics. It explains that 'params' contains a 'query' field as a JsonLogic object, provides multiple examples with syntax and use cases, lists available variables, and includes a documentation link, adding significant meaning beyond the minimal schema.

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: 'Search vault using powerful JsonLogic queries.' It specifies the verb ('search'), resource ('vault'), and method ('JsonLogic queries'), distinguishing it from sibling tools like 'obsidian_list_files_in_vault' or 'obsidian_get_file_contents' by emphasizing query-based searching rather than simple listing or content retrieval.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'Essential for Zettelkasten workflow: find notes by patterns, content, tags, or complex criteria.' It distinguishes when to use this tool (for complex, query-based searches) versus alternatives like 'obsidian_list_files_in_dir' (directory listing) or 'obsidian_get_file_contents' (direct content access), and includes common examples to illustrate use cases.

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/Shepherd-Creative/obsidian-mcp'

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