Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_simple_search

Search across all files in your Obsidian vault to find documents containing specific text queries, returning relevant context around matches.

Instructions

Simple search for documents matching a specified text query across all files in the vault. Use this tool when you want to do a simple text search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to a simple search for in the vault.
context_lengthNoHow much context to return around the matching string (default: 300)

Implementation Reference

  • The run_tool method in SearchToolHandler class that implements the core logic of the obsidian_simple_search tool: validates input, calls the Obsidian API search, formats the results with context and match positions, and returns as JSON.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if "query" not in args:
            raise RuntimeError("query argument missing in arguments")
    
        context_length = args.get("context_length", 100)
        
        results = api.search(args["query"], context_length)
        
        formatted_results = []
        for result in results:
            formatted_matches = []
            for match in result.get('matches', []):
                context = match.get('context', '')
                match_pos = match.get('match', {})
                start = match_pos.get('start', 0)
                end = match_pos.get('end', 0)
                
                formatted_matches.append({
                    'context': context,
                    'match_position': {'start': start, 'end': end}
                })
                
            formatted_results.append({
                'filename': result.get('filename', ''),
                'score': result.get('score', 0),
                'matches': formatted_matches
            })
    
        return [
            TextContent(
                type="text",
                text=json.dumps(formatted_results, indent=2)
            )
        ]
  • The get_tool_description method defining the input schema and description for the obsidian_simple_search tool.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="""Simple search for documents matching a specified text query across all files in the vault. 
            Use this tool when you want to do a simple text search""",
            inputSchema={
                "type": "object",
                "properties": {
                    "query": {
                        "type": "string",
                        "description": "Text to a simple search for in the vault."
                    },
                    "context_length": {
                        "type": "integer",
                        "description": "How much context to return around the matching string (default: 300)",
                        "default": 300
                    }
                },
                "required": ["query"]
            }
        )
  • TOOL_MAPPING dictionary maps the tool name 'obsidian_simple_search' (via tools.TOOL_SIMPLE_SEARCH) to its handler class SearchToolHandler, used in register_tools() to instantiate and register the tool with the MCP server.
    TOOL_MAPPING = {
        tools.TOOL_LIST_FILES_IN_DIR: tools.ListFilesInDirToolHandler,
        tools.TOOL_SIMPLE_SEARCH: tools.SearchToolHandler,
        tools.TOOL_PATCH_CONTENT: tools.PatchContentToolHandler,
        tools.TOOL_PUT_CONTENT: tools.PutContentToolHandler,
        tools.TOOL_APPEND_CONTENT: tools.AppendContentToolHandler,
        tools.TOOL_DELETE_FILE: tools.DeleteFileToolHandler,
        tools.TOOL_COMPLEX_SEARCH: tools.ComplexSearchToolHandler,
        tools.TOOL_BATCH_GET_FILES: tools.BatchGetFilesToolHandler,
        tools.TOOL_PERIODIC_NOTES: tools.PeriodicNotesToolHandler,
        tools.TOOL_RECENT_PERIODIC_NOTES: tools.RecentPeriodicNotesToolHandler,
        tools.TOOL_RECENT_CHANGES: tools.RecentChangesToolHandler,
        tools.TOOL_UNDERSTAND_VAULT: tools.UnderstandVaultToolHandler,
        tools.TOOL_GET_ACTIVE_NOTE: tools.GetActiveNoteToolHandler,
        tools.TOOL_OPEN_FILES: tools.OpenFilesToolHandler,
        tools.TOOL_LIST_COMMANDS: tools.ListCommandsToolHandler,
        tools.TOOL_EXECUTE_COMMANDS: tools.ExecuteCommandsToolHandler,
    }
  • register_tools() function instantiates handlers from TOOL_MAPPING (conditionally based on INCLUDE_TOOLS env var) and adds them to tool_handlers dict, making them available via @app.list_tools() and @app.call_tool().
    def register_tools():
        """Register the selected tools with the server."""
        tools_to_include = parse_include_tools()
        
        registered_count = 0
        for tool_name in tools_to_include:
            if tool_name in TOOL_MAPPING:
                handler_class = TOOL_MAPPING[tool_name]
                handler_instance = handler_class()
                add_tool_handler(handler_instance)
                registered_count += 1
                logger.debug(f"Registered tool: {tool_name}")
        
        logger.info(f"Successfully registered {registered_count} tools")
  • SearchToolHandler class definition and __init__ that sets the tool name to 'obsidian_simple_search'.
    class SearchToolHandler(ToolHandler):
        def __init__(self):
            super().__init__(TOOL_SIMPLE_SEARCH)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the search is 'simple' and 'across all files,' but doesn't describe key behaviors such as whether it's case-sensitive, how results are returned (e.g., format, pagination), performance implications, or error handling. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly state the purpose and usage. It's front-loaded with the core functionality and avoids unnecessary details. However, the second sentence is somewhat redundant with the first, slightly reducing efficiency, but overall it's well-structured and to the point.

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

Completeness3/5

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

Given the tool's moderate complexity (search function with 2 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and usage but lacks details on behavior, output format, and differentiation from siblings. It meets the minimum viable threshold but has clear gaps that could hinder effective tool selection and invocation.

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

Parameters3/5

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

Schema description coverage is 100%, so the input schema already documents both parameters ('query' and 'context_length') with descriptions. The description adds no additional parameter semantics beyond what's in the schema, such as examples of query syntax or how context_length affects output. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

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

Purpose4/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: 'Simple search for documents matching a specified text query across all files in the vault.' It specifies the verb ('search'), resource ('documents'), and scope ('across all files in the vault'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from its sibling 'obsidian_complex_search' beyond the 'simple' qualifier, which is somewhat vague.

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

Usage Guidelines3/5

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

The description provides some guidance with 'Use this tool when you want to do a simple text search,' which implies usage for basic searches. However, it doesn't specify when to use this versus 'obsidian_complex_search' or other search-related tools, nor does it mention any prerequisites or exclusions. The guidance is implied but lacks explicit alternatives or detailed context.

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/ToKiDoO/mcp-obsidian-advanced'

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