Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_import_attachment

Import a base64-encoded attachment to a specified vault path in your Obsidian vault. Optionally overwrite existing files.

Instructions

Import a base64-encoded attachment into the vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
pathYesVault-relative path. Absolute paths and traversal are rejected.
dataBase64Yes
overwriteNo

Implementation Reference

  • The tool handler for 'obsidian_import_attachment'. It accepts a vault-relative path, base64-encoded data, and an overwrite flag, then calls vaults.importBinary() with a Buffer decoded from base64.
    tool(
      "obsidian_import_attachment",
      "Import a base64-encoded attachment into the vault.",
      {
        vault: vaultArg,
        path: pathArg,
        dataBase64: z.string(),
        overwrite: z.boolean().optional().default(false),
      },
      async (args) => vaults.importBinary(args.path, Buffer.from(args.dataBase64, "base64"), args.vault, { overwrite: args.overwrite }),
    );
  • Zod input schema for obsidian_import_attachment: vault (optional string), path (required string), dataBase64 (required string), overwrite (optional boolean, default false).
    {
      vault: vaultArg,
      path: pathArg,
      dataBase64: z.string(),
      overwrite: z.boolean().optional().default(false),
    },
  • src/tools.ts:1048-1058 (registration)
    The tool is registered via the local 'tool()' helper function within registerObsidianTools() in src/tools.ts, with the name 'obsidian_import_attachment'.
    tool(
      "obsidian_import_attachment",
      "Import a base64-encoded attachment into the vault.",
      {
        vault: vaultArg,
        path: pathArg,
        dataBase64: z.string(),
        overwrite: z.boolean().optional().default(false),
      },
      async (args) => vaults.importBinary(args.path, Buffer.from(args.dataBase64, "base64"), args.vault, { overwrite: args.overwrite }),
    );
  • The importBinary() method on VaultManager handles the actual binary file write. It resolves the path, checks overwrite, creates parent directories, writes atomically via atomicWriteBuffer, and returns the path and byte count.
    async importBinary(
      filePath: string,
      data: Buffer,
      vaultName?: string | null,
      options: { overwrite?: boolean } = {},
    ): Promise<{ path: string; bytes: number }> {
      this.assertWritable();
      const resolved = this.resolvePath(filePath, vaultName);
      if (!options.overwrite && fssync.existsSync(resolved.absolute)) throw new Error(`File already exists: ${resolved.relative}`);
      await fs.mkdir(path.dirname(resolved.absolute), { recursive: true });
      await atomicWriteBuffer(resolved.absolute, data);
      this.onInvalidate?.(resolved.vault.name);
      return { path: resolved.relative, bytes: data.byteLength };
    }
  • The atomicWriteBuffer helper function that writes binary data to a temp file, syncs it (on non-Windows), then atomically renames it to the target path.
    async function atomicWriteBuffer(filePath: string, data: Buffer): Promise<void> {
      const tmp = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${process.pid}.${Date.now()}.tmp`);
      await fs.writeFile(tmp, data);
      if (os.platform() !== "win32") {
        const handle = await fs.open(tmp, "r");
        try {
          await handle.sync();
        } finally {
          await handle.close();
        }
      }
      await fs.rename(tmp, filePath);
    }
Behavior3/5

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

Annotations already indicate mutation (readOnlyHint=false) and non-destructiveness (destructiveHint=false). The description adds that the attachment must be base64-encoded, which is a critical behavioral constraint. However, it omits other behaviors such as overwrite behavior, file naming, or size limits.

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?

The description is a single concise sentence with no filler. It is appropriately sized for its content, though it could be slightly expanded to cover key behaviors without becoming verbose.

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?

The tool has 4 parameters and no output schema, yet the description only states the broad purpose. It does not explain success indicators, error conditions, or how vault and overwrite affect behavior. This is insufficient for an agent to use the tool reliably.

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?

Schema description coverage is only 50%, with no descriptions for dataBase64 and overwrite. The description mentions 'base64-encoded' but does not detail the parameter format or behavior. It fails to compensate for the missing schema descriptions, leaving the agent underinformed.

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 'import' and the resource 'base64-encoded attachment into the vault,' which is distinct from sibling tools like obsidian_create_note or obsidian_list_attachments. It leaves no ambiguity about the action and target.

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. It does not mention prerequisites, contrasting tools, or scenarios where other tools like obsidian_batch_create_notes might be more appropriate.

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