Skip to main content
Glama
yuchi-chang

obsidian-mcp

by yuchi-chang

Get note metadata

obsidian_get_metadata
Read-only

Retrieve metadata for an Obsidian note, including frontmatter, tags, links, and file stats, returned as JSON.

Instructions

Returns metadata for a note (frontmatter, tags, links, file stats) as JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoVault name to target. Optional — defaults to the most recently focused vault.
fileNoNote name resolved as a wikilink (e.g. 'My Note'). Provide either `file` or `path`.
pathNoVault-root-relative path to the note (e.g. 'Folder/My Note.md'). Provide either `file` or `path`.

Implementation Reference

  • Input schema for obsidian_get_metadata – accepts optional vault, and either file (wikilink) or path (vault-relative path).
      name: "obsidian_get_metadata",
      title: "Get note metadata",
      description:
        "Returns metadata for a note (frontmatter, tags, links, file stats) as JSON.",
      inputSchema: { ...VaultArg, ...FileTargetArg },
      annotations: { readOnlyHint: true, openWorldHint: false },
      handler: async ({ vault, file, path }) => {
        requireFileTarget({ file, path });
        return runJson("file", { vault, params: { file, path } });
      },
    },
  • Handler function for obsidian_get_metadata – validates that file or path is provided, then delegates to runJson which invokes the Obsidian CLI's 'file' command to fetch metadata (frontmatter, tags, links, file stats) as JSON.
    handler: async ({ vault, file, path }) => {
      requireFileTarget({ file, path });
      return runJson("file", { vault, params: { file, path } });
    },
  • Shared schema fragment VaultArg – optional vault name parameter reused across tools.
    const VaultArg = {
      vault: z
        .string()
        .optional()
        .describe(
          "Vault name to target. Optional — defaults to the most recently focused vault.",
        ),
    };
  • Shared schema fragment FileTargetArg – reusable file or path parameter for targeting notes.
    const FileTargetArg = {
      file: z
        .string()
        .optional()
        .describe(
          "Note name resolved as a wikilink (e.g. 'My Note'). Provide either `file` or `path`.",
        ),
      path: z
        .string()
        .optional()
        .describe(
          "Vault-root-relative path to the note (e.g. 'Folder/My Note.md'). Provide either `file` or `path`.",
        ),
    };
  • requireFileTarget validation helper – throws if neither file nor path is provided.
    function requireFileTarget(input: { file?: string; path?: string }) {
      if (!input.file && !input.path) {
        throw new Error(
          "Either `file` (wikilink name) or `path` (vault-relative path) must be provided.",
        );
      }
    }
  • runJson helper – executes an Obsidian CLI command with JSON output and parses the result.
    async function runJson(
      command: string,
      opts: Parameters<typeof runObsidian>[1] = {},
    ): Promise<McpToolResult> {
      try {
        const result = await runObsidian(command, { ...opts, format: opts.format ?? "json" });
        const parsed = parseJsonOrText(result.stdout);
        const text =
          typeof parsed === "string"
            ? parsed
            : JSON.stringify(parsed, null, 2);
        return textResult(text || "(no output)", parsed);
      } catch (err) {
        return errorResult(err);
      }
    }
  • src/index.ts:40-51 (registration)
    Tool registration in index.ts – each tool in the tools array is registered with the MCP server via server.registerTool.
    for (const tool of tools) {
      server.registerTool(
        tool.name,
        {
          title: tool.title,
          description: tool.description,
          inputSchema: tool.inputSchema,
          annotations: tool.annotations,
        },
        buildHandler(server, tool),
      );
    }
Behavior3/5

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

Annotations already provide readOnlyHint: true. The description confirms a read operation without adding extra behavioral context such as side effects, auth needs, or rate limits. The description does not contradict annotations.

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 clear sentence, front-loaded with the core purpose, and contains no unnecessary words.

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

Completeness5/5

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

Given the tool's low complexity, full schema coverage, and no output schema, the description sufficiently covers what the tool does and what it returns (metadata as JSON including specific fields).

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?

Input schema has 100% description coverage for its 3 parameters (vault, file, path). The description adds no further meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the verb 'Returns', the resource 'metadata for a note', and specifics: 'frontmatter, tags, links, file stats' and format 'as JSON'. It distinguishes itself from siblings like obsidian_read_note (content) and obsidian_get_properties (only properties) by listing the full metadata scope.

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

Usage Guidelines3/5

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

The description lacks explicit guidance on when to use this tool versus alternatives like obsidian_get_properties or obsidian_get_links. It implies usage by listing what it returns, but does not state exclusions or provide context for selection.

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/yuchi-chang/obsidian-mcp'

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