Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_rag_query

Read-only

Perform semantic search and question-answering on your Obsidian vault using a local retrieval-augmented generation pipeline.

Instructions

Run the local obsidian-rag CLI for true semantic retrieval/LLM answering. Requires rag to be installed and indexed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionYes
kNo
folderNo
tagNo
sourceNo
ragVaultNoOptional obsidian-rag vault registry name; independent from this MCP vault name.
sessionNo
rawNo
multiNo
forceNo
timeoutMsNo

Implementation Reference

  • src/tools.ts:289-340 (registration)
    Registration, schema, and handler for the 'obsidian_rag_query' tool. Uses the tool() helper (line 41-60) to register with the MCP server. The schema defines inputs: question, k, folder, tag, source, ragVault, session, raw, multi, force, timeoutMs. The handler builds CLI args and executes 'config.ragCommand' (default 'rag', configurable via OBSIDIAN_RAG_COMMAND env var) via execFileAsync, returning stdout as the answer.
    tool(
      "obsidian_rag_query",
      "Run the local obsidian-rag CLI for true semantic retrieval/LLM answering. Requires rag to be installed and indexed.",
      {
        question: z.string(),
        k: z.number().int().min(1).max(15).optional().default(5),
        folder: z.string().optional(),
        tag: z.string().optional(),
        source: z.string().optional(),
        ragVault: z.string().optional().describe("Optional obsidian-rag vault registry name; independent from this MCP vault name."),
        session: z.string().optional(),
        raw: z.boolean().optional().default(false),
        multi: z.boolean().optional().default(false),
        force: z.boolean().optional().default(false),
        timeoutMs: z.number().int().min(5000).max(300000).optional().default(180000),
      },
      async (args) => {
        const cliArgs = ["query", "-k", String(args.k), "--plain"];
        if (args.folder) cliArgs.push("--folder", args.folder);
        if (args.tag) cliArgs.push("--tag", args.tag);
        if (args.source) cliArgs.push("--source", args.source);
        if (args.ragVault) cliArgs.push("--vault", args.ragVault);
        if (args.session) cliArgs.push("--session", args.session);
        if (args.raw) cliArgs.push("--raw");
        if (args.multi) cliArgs.push("--multi");
        if (args.force) cliArgs.push("--force");
        cliArgs.push(args.question);
        try {
          const { stdout, stderr } = await execFileAsync(config.ragCommand, cliArgs, {
            timeout: args.timeoutMs,
            maxBuffer: 10 * 1024 * 1024,
            env: { ...process.env, NO_COLOR: "1" },
          });
          return { ok: true, command: config.ragCommand, args: cliArgs, answer: stdout.trim(), stderr: stderr.trim() || undefined };
        } catch (error) {
          const err = error as Error & { stdout?: string; stderr?: string; code?: string | number };
          const notFound = err.code === "ENOENT";
          return {
            ok: false,
            command: config.ragCommand,
            args: cliArgs,
            error: notFound
              ? `RAG command '${config.ragCommand}' not found. Install obsidian-rag and ensure it is in PATH, or set OBSIDIAN_RAG_COMMAND to the full path.`
              : err.message,
            code: err.code,
            stdout: err.stdout?.trim(),
            stderr: err.stderr?.trim(),
          };
        }
      },
      { readOnlyHint: true, idempotentHint: false },
    );
  • Zod schema for obsidian_rag_query: question (string), k (1-15, default 5), folder/tag/source/ragVault/session (optional strings), raw/multi/force (optional booleans, default false), timeoutMs (5000-300000, default 180000).
    {
      question: z.string(),
      k: z.number().int().min(1).max(15).optional().default(5),
      folder: z.string().optional(),
      tag: z.string().optional(),
      source: z.string().optional(),
      ragVault: z.string().optional().describe("Optional obsidian-rag vault registry name; independent from this MCP vault name."),
      session: z.string().optional(),
      raw: z.boolean().optional().default(false),
      multi: z.boolean().optional().default(false),
      force: z.boolean().optional().default(false),
      timeoutMs: z.number().int().min(5000).max(300000).optional().default(180000),
    },
  • Handler that constructs CLI args list: ['query', '-k', k, '--plain'] plus optional flags, then calls execFileAsync with config.ragCommand. On success returns {ok:true, command, args, answer, stderr}. On failure returns {ok:false, command, args, error, code, stdout, stderr}. Handles ENOENT with a user-friendly install message.
    async (args) => {
      const cliArgs = ["query", "-k", String(args.k), "--plain"];
      if (args.folder) cliArgs.push("--folder", args.folder);
      if (args.tag) cliArgs.push("--tag", args.tag);
      if (args.source) cliArgs.push("--source", args.source);
      if (args.ragVault) cliArgs.push("--vault", args.ragVault);
      if (args.session) cliArgs.push("--session", args.session);
      if (args.raw) cliArgs.push("--raw");
      if (args.multi) cliArgs.push("--multi");
      if (args.force) cliArgs.push("--force");
      cliArgs.push(args.question);
      try {
        const { stdout, stderr } = await execFileAsync(config.ragCommand, cliArgs, {
          timeout: args.timeoutMs,
          maxBuffer: 10 * 1024 * 1024,
          env: { ...process.env, NO_COLOR: "1" },
        });
        return { ok: true, command: config.ragCommand, args: cliArgs, answer: stdout.trim(), stderr: stderr.trim() || undefined };
      } catch (error) {
        const err = error as Error & { stdout?: string; stderr?: string; code?: string | number };
        const notFound = err.code === "ENOENT";
        return {
          ok: false,
          command: config.ragCommand,
          args: cliArgs,
          error: notFound
            ? `RAG command '${config.ragCommand}' not found. Install obsidian-rag and ensure it is in PATH, or set OBSIDIAN_RAG_COMMAND to the full path.`
            : err.message,
          code: err.code,
          stdout: err.stdout?.trim(),
          stderr: err.stderr?.trim(),
        };
      }
    },
  • The 'tool' helper function that wraps server.tool() with annotations and jsonResult formatting. All tools including obsidian_rag_query use this helper for registration.
    const tool = <S extends ToolShape>(
      name: string,
      description: string,
      schema: S,
      handler: (args: z.objectOutputType<S, z.ZodTypeAny>) => Promise<unknown> | unknown,
      annotations: { readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean } = {},
    ) => {
      (server.tool as any)(
        name,
        description,
        schema,
        {
          readOnlyHint: annotations.readOnlyHint ?? false,
          destructiveHint: annotations.destructiveHint ?? false,
          idempotentHint: annotations.idempotentHint ?? false,
          openWorldHint: false,
        },
        async (args: unknown) => jsonResult(await handler(args as z.objectOutputType<S, z.ZodTypeAny>), pretty),
      );
    };
  • src/tools.ts:38-60 (registration)
    registerObsidianTools function that registers all tools on the MCP server, including the tool() helper wrapper definition.
    export function registerObsidianTools(server: McpServer, vaults: VaultManager, config: ObsidianMcpConfig): void {
      vaults.onInvalidate = invalidateNotesCache;
      const pretty = config.pretty;
      const tool = <S extends ToolShape>(
        name: string,
        description: string,
        schema: S,
        handler: (args: z.objectOutputType<S, z.ZodTypeAny>) => Promise<unknown> | unknown,
        annotations: { readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean } = {},
      ) => {
        (server.tool as any)(
          name,
          description,
          schema,
          {
            readOnlyHint: annotations.readOnlyHint ?? false,
            destructiveHint: annotations.destructiveHint ?? false,
            idempotentHint: annotations.idempotentHint ?? false,
            openWorldHint: false,
          },
          async (args: unknown) => jsonResult(await handler(args as z.objectOutputType<S, z.ZodTypeAny>), pretty),
        );
      };
Behavior3/5

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

Annotations already indicate read-only behavior. The description adds that it requires an external CLI to be installed, which is important context. However, it does not disclose potential timeouts, response format, or other side effects beyond the prerequisite.

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

Conciseness4/5

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

Two concise sentences with no wasted words. Could benefit from more structured information but remains efficient.

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 11 parameters and no output schema, the description lacks detail on return values, parameter usage, and interaction with sibling tools. It feels incomplete for a complex tool.

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

Parameters2/5

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

With only 9% schema description coverage, the description should explain key parameters like k, folder, tag, raw, multi, etc. It does not add meaning beyond the parameter names. The 'question' role is implied but not detailed.

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 it runs the obsidian-rag CLI for semantic retrieval and LLM answering, which distinguishes it from other search tools. However, it does not explicitly name sibling tools or differentiate them.

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 mentions the prerequisite (rag installed and indexed) but provides no guidance on when to use this over alternatives like obsidian_search or obsidian_smart_search. Usage is implied but not explicit.

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

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