Skip to main content
Glama
bazylhorsey
by bazylhorsey

search_notes

Find specific notes in your Obsidian vault using search queries, tag filters, and folder navigation to locate relevant information quickly.

Instructions

Search for notes in a vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFilter by folder
limitNoMaximum number of results
queryYesSearch query
tagsNoFilter by tags
vaultYesVault name

Implementation Reference

  • Defines the SearchOptions interface for input parameters to the search_notes tool.
    export interface SearchOptions {
      query: string;
      tags?: string[];
      folder?: string;
      limit?: number;
      includeContent?: boolean;
    }
  • src/index.ts:78-92 (registration)
    Registers the search_notes tool in the MCP server's list tools handler with name, description, and input schema.
    {
      name: 'search_notes',
      description: 'Search for notes in a vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
          query: { type: 'string', description: 'Search query' },
          tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' },
          folder: { type: 'string', description: 'Filter by folder' },
          limit: { type: 'number', description: 'Maximum number of results' },
        },
        required: ['vault', 'query'],
      },
    },
  • Top-level MCP tool handler for 'search_notes': validates vault, calls connector.searchNotes with parameters, returns JSON result.
    case 'search_notes': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector) {
        throw new Error(`Vault "${args?.vault}" not found`);
      }
      const result = await connector.searchNotes({
        query: args?.query as string,
        tags: args?.tags as string[] | undefined,
        folder: args?.folder as string | undefined,
        limit: args?.limit as number | undefined,
        includeContent: true,
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Core search logic for local vaults: retrieves all notes from cache, applies filters for folder/tags/query/content, limits results.
    async searchNotes(options: SearchOptions): Promise<VaultOperationResult<Note[]>> {
      try {
        const allNotes = await this.getAllNotes();
        if (!allNotes.success || !allNotes.data) {
          return allNotes;
        }
    
        let results = allNotes.data;
    
        // Filter by folder
        if (options.folder) {
          results = results.filter(note => note.path.startsWith(options.folder!));
        }
    
        // Filter by tags
        if (options.tags && options.tags.length > 0) {
          results = results.filter(note => {
            if (!note.tags) return false;
            return options.tags!.some(tag => note.tags!.includes(tag));
          });
        }
    
        // Search in title and content
        if (options.query) {
          const query = options.query.toLowerCase();
          results = results.filter(note => {
            const inTitle = note.title.toLowerCase().includes(query);
            const inContent = options.includeContent && note.content.toLowerCase().includes(query);
            return inTitle || inContent;
          });
        }
    
        // Apply limit
        if (options.limit && options.limit > 0) {
          results = results.slice(0, options.limit);
        }
    
        return { success: true, data: results };
      } catch (error) {
        return {
          success: false,
          error: `Failed to search notes: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
  • Core search logic for remote vaults: attempts server-side search via POST /search, falls back to identical client-side filtering.
    async searchNotes(options: SearchOptions): Promise<VaultOperationResult<Note[]>> {
      try {
        // Try server-side search first
        try {
          const response = await this.client.post('/search', options);
          if (response.data.notes) {
            return { success: true, data: response.data.notes };
          }
        } catch {
          // Fall back to client-side search
        }
    
        // Client-side search fallback
        const allNotes = await this.getAllNotes();
        if (!allNotes.success || !allNotes.data) {
          return allNotes;
        }
    
        let results = allNotes.data;
    
        if (options.folder) {
          results = results.filter(note => note.path.startsWith(options.folder!));
        }
    
        if (options.tags && options.tags.length > 0) {
          results = results.filter(note => {
            if (!note.tags) return false;
            return options.tags!.some(tag => note.tags!.includes(tag));
          });
        }
    
        if (options.query) {
          const query = options.query.toLowerCase();
          results = results.filter(note => {
            const inTitle = note.title.toLowerCase().includes(query);
            const inContent = options.includeContent && note.content.toLowerCase().includes(query);
            return inTitle || inContent;
          });
        }
    
        if (options.limit && options.limit > 0) {
          results = results.slice(0, options.limit);
        }
    
        return { success: true, data: results };
      } catch (error) {
        return {
          success: false,
          error: `Failed to search notes: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't cover aspects like pagination, rate limits, authentication needs, return format, or whether it's read-only (implied but not explicit).

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 wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly without unnecessary elaboration.

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?

For a search tool with 5 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error conditions, or behavioral nuances, leaving significant gaps for an agent to understand how to use it effectively.

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 5 parameters. The description adds no additional meaning beyond the schema, such as explaining how 'query' interacts with 'tags' or 'folder'. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Search for notes in a vault' clearly states the verb ('search') and resource ('notes'), but it's vague about scope and doesn't differentiate from siblings like 'dataview_query' or 'get_related_notes'. It lacks specificity about what 'search' entails (e.g., full-text, metadata).

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 'dataview_query' or 'get_related_notes'. The description doesn't mention prerequisites, exclusions, or contextual cues for selection among the many note-related tools.

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/bazylhorsey/obsidian-mcp-server'

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