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;

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