Skip to main content
Glama

bear_attach_file

Attach a file or image to a Bear note, uploading to iCloud and embedding in markdown. Control placement: append, prepend, or insert before or after specific text.

Instructions

Attach a file or image to an existing Bear note. The file is uploaded to iCloud and embedded in the note's markdown. Supports common image formats (jpg, png, gif, webp, heic) and other file types (pdf, zip, etc.). By default the attachment is appended to the end. Use 'after' or 'before' to place it relative to text in the note, or 'prepend' to put it right after the title.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesNote ID (uniqueIdentifier)
file_pathYesAbsolute path to the file to attach
afterNoInsert after the line containing this text
beforeNoInsert before the line containing this text
prependNoInsert after the title line instead of at the end

Implementation Reference

  • The 'bear_attach_file' tool is registered in the tools record. It defines the tool name, description, inputSchema (id, file_path, after, before, prepend), and the buildArgs() function that constructs the CLI args array for the 'bcli attach' command.
    bear_attach_file: {
      tool: {
        name: "bear_attach_file",
        description:
          "Attach a file or image to an existing Bear note. The file is uploaded to iCloud and embedded in the note's markdown. Supports common image formats (jpg, png, gif, webp, heic) and other file types (pdf, zip, etc.). By default the attachment is appended to the end. Use 'after' or 'before' to place it relative to text in the note, or 'prepend' to put it right after the title.",
        inputSchema: {
          type: "object" as const,
          properties: {
            id: {
              type: "string",
              description: "Note ID (uniqueIdentifier)",
            },
            file_path: {
              type: "string",
              description:
                "Absolute path to the file to attach",
            },
            after: {
              type: "string",
              description:
                "Insert after the line containing this text",
            },
            before: {
              type: "string",
              description:
                "Insert before the line containing this text",
            },
            prepend: {
              type: "boolean",
              description:
                "Insert after the title line instead of at the end",
            },
          },
          required: ["id", "file_path"],
        },
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: false,
        },
      },
      buildArgs: (input) => {
        const args = [
          "attach",
          String(input.id),
          String(input.file_path),
          "--json",
        ];
        if (input.after) args.push("--after", String(input.after));
        if (input.before) args.push("--before", String(input.before));
        if (input.prepend) args.push("--prepend");
        return args;
      },
    },
  • The handler logic for bear_attach_file: buildArgs constructs the CLI command 'attach <id> <file_path> --json' with optional --after, --before, and --prepend flags. The actual execution is in index.ts via execBcliWithReauth.
    buildArgs: (input) => {
      const args = [
        "attach",
        String(input.id),
        String(input.file_path),
        "--json",
      ];
      if (input.after) args.push("--after", String(input.after));
      if (input.before) args.push("--before", String(input.before));
      if (input.prepend) args.push("--prepend");
      return args;
    },
  • The input schema for bear_attach_file. Requires 'id' (string) and 'file_path' (string). Optional fields: 'after' (string), 'before' (string), 'prepend' (boolean).
    inputSchema: {
      type: "object" as const,
      properties: {
        id: {
          type: "string",
          description: "Note ID (uniqueIdentifier)",
        },
        file_path: {
          type: "string",
          description:
            "Absolute path to the file to attach",
        },
        after: {
          type: "string",
          description:
            "Insert after the line containing this text",
        },
        before: {
          type: "string",
          description:
            "Insert before the line containing this text",
        },
        prepend: {
          type: "boolean",
          description:
            "Insert after the title line instead of at the end",
        },
      },
      required: ["id", "file_path"],
    },
  • The generic tool handler in index.ts that dispatches all tools including bear_attach_file. It calls handler.buildArgs(params) and then execBcliWithReauth to run the 'bcli' command.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: input } = request.params;
      const handler = tools[name];
    
      if (!handler) {
        return {
          content: [{ type: "text", text: `Unknown tool: ${name}` }],
          isError: true,
        };
      }
    
      const params = (input ?? {}) as Record<string, unknown>;
    
      // Validate bear_edit_note: need at least one edit operation
      if (name === "bear_edit_note") {
        const hasAppend = params.append_text !== undefined;
        const hasBody = params.body !== undefined;
        const hasSetFm = params.set_frontmatter !== undefined &&
          Object.keys(params.set_frontmatter as object).length > 0;
        const hasRemoveFm = Array.isArray(params.remove_frontmatter) &&
          (params.remove_frontmatter as unknown[]).length > 0;
        const hasFm = hasSetFm || hasRemoveFm;
    
        if (!hasAppend && !hasBody && !hasFm) {
          return {
            content: [
              {
                type: "text",
                text: "Provide 'append_text', 'body', 'set_frontmatter', or 'remove_frontmatter'.",
              },
            ],
            isError: true,
          };
        }
        if (hasAppend && hasBody) {
          return {
            content: [
              {
                type: "text",
                text: "Provide either 'append_text' or 'body', not both.",
              },
            ],
            isError: true,
          };
        }
      }
    
      try {
        const args = handler.buildArgs(params);
        let result: { stdout: string; stderr: string };
    
        // Check if this tool needs stdin piping
        const stdinData = handler.usesStdin?.(params) ?? null;
        if (stdinData !== null) {
          result = await execBcliWithStdinAndReauth(args, stdinData);
        } else {
          result = await execBcliWithReauth(args);
        }
    
        // Parse JSON output from bcli
        const stdout = result.stdout.trim();
        if (!stdout) {
          return {
            content: [{ type: "text", text: "Command completed successfully." }],
          };
        }
    
        // Validate it's JSON and pretty-print
        try {
          const parsed = JSON.parse(stdout);
          return {
            content: [
              { type: "text", text: JSON.stringify(parsed, null, 2) },
            ],
          };
        } catch {
          // If bcli returned non-JSON, pass it through
          return {
            content: [{ type: "text", text: stdout }],
          };
        }
      } catch (error) {
        const message =
          error instanceof BcliError ? error.message : String(error);
        return {
          content: [{ type: "text", text: message }],
          isError: true,
        };
      }
Behavior4/5

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

Discloses upload to iCloud and embedding in markdown, adding context beyond annotations which only indicate it's not read-only or destructive. No contradictions.

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?

Four sentences front-loaded with main action, each sentence adds necessary detail without fluff. Well-structured and concise.

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

Completeness4/5

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

Covers main aspects: purpose, file types, placement, and iCloud upload. Lacks error handling but sufficient for agent usage given no output schema.

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

Parameters4/5

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

Adds meaning beyond schema descriptions by explaining default behavior and relationships between placement parameters; schema coverage is 100% but description enhances understanding.

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 'attach' and resource 'file/image to Bear note', and distinguishes from sibling tools like bear_create_note or bear_edit_note.

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

Usage Guidelines4/5

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

Provides clear placement options (default appended, after, before, prepend) and explains file type support, but does not explicitly say when not to use or mention alternatives.

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/KuvopLLC/better-bear'

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