Skip to main content
Glama

search_by_frontmatter

Find notes in Obsidian by searching frontmatter property values to organize and retrieve information based on metadata criteria.

Instructions

Search notes by frontmatter property values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyYesFrontmatter property key to search for
valueYesValue to match against the property
folderNoLimit search to a specific folder

Implementation Reference

  • The implementation of the `search_by_frontmatter` tool, including registration, input schema, and execution handler.
    server.registerTool(
      "search_by_frontmatter",
      {
        description: "Search notes by frontmatter property values",
        inputSchema: {
          property: z
            .string()
            .min(1)
            .describe("Frontmatter property key to search for"),
          value: z.string().min(1).describe("Value to match against the property"),
          folder: z
            .string()
            .optional()
            .describe("Limit search to a specific folder"),
        },
      },
      async ({ property, value, folder }) => {
        try {
          const notes = await listNotes(vaultPath, folder);
          const matches: Array<{
            path: string;
            frontmatter: Record<string, unknown>;
          }> = [];
    
          for (const notePath of notes) {
            let content: string;
            try {
              content = await readNote(vaultPath, notePath);
            } catch {
              console.error(
                `Failed to read note during frontmatter search: ${notePath}`,
              );
              continue;
            }
    
            const { data: frontmatterData } = parseFrontmatter(content);
            const propValue = frontmatterData[property];
    
            if (propValue === undefined) continue;
    
            const stringified = Array.isArray(propValue)
              ? propValue.map(String)
              : [String(propValue)];
    
            const isMatch = stringified.some(
              (v) => v.toLowerCase() === value.toLowerCase(),
            );
    
            if (isMatch) {
              matches.push({ path: notePath, frontmatter: frontmatterData });
            }
          }
    
          if (matches.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No notes found with frontmatter "${property}" matching "${value}"`,
                },
              ],
            };
          }
    
          const lines: string[] = [
            `Found ${matches.length} note(s) where "${property}" matches "${value}":`,
            "",
          ];
    
          for (const match of matches) {
            lines.push(`## ${match.path}`);
            for (const [key, val] of Object.entries(match.frontmatter)) {
              lines.push(`  ${key}: ${JSON.stringify(val)}`);
            }
            lines.push("");
          }
    
          return {
            content: [{ type: "text" as const, text: lines.join("\n") }],
          };
        } catch (err) {
          console.error("search_by_frontmatter error:", err);
          return errorResult(`Error searching by frontmatter: ${err instanceof Error ? err.message : String(err)}`);
        }
      },
    );
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 only states the search action without details on permissions, rate limits, output format, or error handling. For a search tool with no annotation coverage, this is insufficient—it should describe what the search returns (e.g., list of notes) and any constraints (e.g., case sensitivity).

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: 'Search notes by frontmatter property values'. It's front-loaded with the core action and resource, with zero wasted words. This makes it easy for an agent to parse quickly and understand the tool's intent 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?

Given the tool's complexity (search operation with 3 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the search returns (e.g., note metadata or content), how results are formatted, or any limitations (e.g., partial matches). For a tool with no structured output information, the description should provide more context to guide the agent 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?

The input schema has 100% description coverage, with clear parameter definitions (property, value, folder). The description adds no additional semantic context beyond what's in the schema, such as examples or usage notes. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but the description doesn't compensate or enhance 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: 'Search notes by frontmatter property values'. It specifies the verb ('Search'), resource ('notes'), and scope ('by frontmatter property values'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish itself from sibling tools like 'search_notes' or 'search_by_tag', which might have overlapping functionality, so it misses the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'search_notes' and 'search_by_tag', it's unclear if this tool is for specific frontmatter queries or general searches. There's no mention of prerequisites, exclusions, or recommended contexts, leaving the agent to infer usage from the tool name 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/rps321321/obsidian-mcp-pro'

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