Skip to main content
Glama
HenriqueCSouzza

Obsidian MCP Local

search_notes

Search Markdown notes in your Obsidian vault by specifying a query to find notes with matching content, enabling targeted retrieval of information across your notes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The core search logic: walks all markdown files, performs substring matching on path/frontmatter/content, scores results (path match=+4, frontmatter=+2, content=+1), sorts by score, and returns top 20 matches with excerpts.
    export async function searchNotes(query: string) {
      const q = query.trim().toLowerCase();
    
      if (!q) return [];
    
      const files = await walkMarkdownFiles(VAULT_ROOT);
      const matches: Array<{ path: string; score: number; excerpt: string }> = [];
    
      for (const fullPath of files) {
        const raw = await fs.readFile(fullPath, "utf-8");
        const parsed = matter(raw);
        const relativePath = toRelativeVaultPath(fullPath);
    
        const haystack =
          `${relativePath}\n${JSON.stringify(parsed.data)}\n${parsed.content}`.toLowerCase();
        const idx = haystack.indexOf(q);
    
        if (idx >= 0) {
          const contentLower = parsed.content.toLowerCase();
          const contentIdx = contentLower.indexOf(q);
          const excerpt =
            contentIdx >= 0
              ? parsed.content
                  .slice(
                    Math.max(0, contentIdx - 120),
                    Math.min(parsed.content.length, contentIdx + 220),
                  )
                  .trim()
              : "";
    
          let score = 1;
          if (relativePath.toLowerCase().includes(q)) score += 4;
          if (JSON.stringify(parsed.data).toLowerCase().includes(q)) score += 2;
          if (contentIdx >= 0) score += 1;
    
          matches.push({ path: relativePath, score, excerpt });
        }
      }
    
      return matches
        .sort((a, b) => b.score - a.score || a.path.localeCompare(b.path))
        .slice(0, 20);
    }
  • The MCP tool handler: registers 'search_notes' with a 'query' string input, calls the vault searchNotes function, and returns text content with JSON results.
    export function register(server: McpServer): void {
      server.registerTool(
        "search_notes",
        { inputSchema: { query: z.string().min(1) } },
        async ({ query }) => {
          const results = await searchNotes(query);
          return {
            content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
          };
        },
      );
  • Input schema for the search_notes tool: requires a non-empty string 'query' parameter validated via Zod.
    { inputSchema: { query: z.string().min(1) } },
  • src/server.ts:14-14 (registration)
    Registration: calls searchNotes.register(server) to add the tool to the MCP server.
    searchNotes.register(server);
  • Helper: walkMarkdownFiles recursively walks the vault directory (skipping .obsidian, .git, node_modules) and returns all .md file paths.
    export async function walkMarkdownFiles(dir: string): Promise<string[]> {
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/HenriqueCSouzza/obsidian-mcp-local'

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