Skip to main content
Glama
sureshsankaran

Obsidian Tools MCP Server

search_content

Find notes containing specific text in your Obsidian vault by searching note contents with customizable options for case sensitivity and result limits.

Instructions

Search for notes containing specific text in their content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to search for in note contents
caseSensitiveNoWhether search is case-sensitive. Default: false
limitNoMaximum number of results to return. Default: 20

Implementation Reference

  • The handler function that implements the search_content tool logic: gets all notes, searches content with regex (case insensitive by default), finds up to 3 matching lines per note, limits results, returns JSON.
    async function handleSearchContent(args: {
      query: string;
      caseSensitive?: boolean;
      limit?: number;
    }): Promise<string> {
      const limit = args.limit ?? 20;
      const caseSensitive = args.caseSensitive ?? false;
      const allNotes = await getAllNotes();
      const results: { path: string; matches: string[] }[] = [];
    
      const regex = new RegExp(
        args.query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
        caseSensitive ? "g" : "gi"
      );
    
      for (const notePath of allNotes) {
        if (results.length >= limit) break;
    
        const fullPath = path.join(VAULT_PATH, notePath);
        const content = await fs.readFile(fullPath, "utf-8");
    
        if (regex.test(content)) {
          // Find matching lines
          const lines = content.split("\n");
          const matchingLines = lines
            .filter((line) => regex.test(line))
            .slice(0, 3);
    
          results.push({ path: notePath, matches: matchingLines });
        }
      }
    
      return JSON.stringify(results, null, 2);
    }
  • The input schema definition for the search_content tool, specifying query (required), caseSensitive, and limit parameters.
    name: "search_content",
    description: "Search for notes containing specific text in their content",
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Text to search for in note contents",
        },
        caseSensitive: {
          type: "boolean",
          description: "Whether search is case-sensitive. Default: false",
          default: false,
        },
        limit: {
          type: "number",
          description: "Maximum number of results to return. Default: 20",
          default: 20,
        },
      },
      required: ["query"],
    },
  • src/index.ts:901-905 (registration)
    The switch case in the main tool dispatcher that registers and calls the handleSearchContent handler for the "search_content" tool.
    case "search_content":
      result = await handleSearchContent(
        args as { query: string; caseSensitive?: boolean; limit?: number }
      );
      break;
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic function. It doesn't disclose behavioral traits such as pagination (implied by 'limit'), performance considerations, error handling, or what happens if no matches are found. For a search tool with zero annotation coverage, this is a significant gap.

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 a single, efficient sentence with zero waste—front-loaded and directly states the tool's purpose. Every word earns its place, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the complexity of a search operation with no annotations and no output schema, the description is incomplete. It lacks details on return format (e.g., list of notes with snippets), error cases, or how results are ordered. For a tool with 3 parameters and behavioral nuances, this is inadequate.

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 schema fully documents all parameters. The description adds no additional meaning beyond implying text-based search, which is already covered by the schema's 'query' description. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Search for') and resource ('notes'), specifying the search scope ('containing specific text in their content'). It distinguishes from siblings like 'search_notes' by focusing on content text rather than broader note attributes, though the distinction could be more explicit.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'search_notes' or 'list_folder'. The description implies usage for text-based content searches but lacks explicit context, prerequisites, or exclusions, leaving the agent to infer from tool names alone.

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/sureshsankaran/obsidian-tools-mcp'

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