bear_edit_note
Edit existing Bear notes by appending text, replacing body, or modifying YAML front matter fields. Combine front matter edits or use body/append options.
Instructions
Edit an existing Bear note. Provide 'append_text' to add text, 'body' to replace content, or 'set_frontmatter'/'remove_frontmatter' to edit YAML front matter fields. Front matter edits can be combined with each other but not with body/append.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Note ID (uniqueIdentifier) | |
| append_text | No | Text to append to the end of the note | |
| body | No | New content to replace the entire note body | |
| after | No | Insert appended text after the line containing this text (use with append_text) | |
| replace_section | No | Replace content under this heading (replaces until next heading of same or higher level) | |
| section_content | No | New content for the section (use with replace_section) | |
| set_frontmatter | No | Front matter fields to set or update (key-value pairs) | |
| remove_frontmatter | No | Front matter field keys to remove |
Implementation Reference
- mcp-server/src/tools.ts:200-309 (handler)The main handler for bear_edit_note — includes the tool definition (name, description, inputSchema, annotations), the buildArgs function that constructs CLI arguments for the bcli binary (supporting front matter edits, section replacement, append, and full body replacement via stdin), and the usesStdin function that pipes body content through stdin.
bear_edit_note: { tool: { name: "bear_edit_note", description: "Edit an existing Bear note. Provide 'append_text' to add text, 'body' to replace content, or 'set_frontmatter'/'remove_frontmatter' to edit YAML front matter fields. Front matter edits can be combined with each other but not with body/append.", inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Note ID (uniqueIdentifier)", }, append_text: { type: "string", description: "Text to append to the end of the note", }, body: { type: "string", description: "New content to replace the entire note body", }, after: { type: "string", description: "Insert appended text after the line containing this text (use with append_text)", }, replace_section: { type: "string", description: "Replace content under this heading (replaces until next heading of same or higher level)", }, section_content: { type: "string", description: "New content for the section (use with replace_section)", }, set_frontmatter: { type: "object", description: "Front matter fields to set or update (key-value pairs)", additionalProperties: { type: "string" }, }, remove_frontmatter: { type: "array", items: { type: "string" }, description: "Front matter field keys to remove", }, }, required: ["id"], }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, }, }, buildArgs: (input) => { // Front matter editing mode const hasFm = (input.set_frontmatter && Object.keys(input.set_frontmatter as object).length > 0) || (Array.isArray(input.remove_frontmatter) && input.remove_frontmatter.length > 0); if (hasFm && !input.append_text && !input.body) { const args = ["edit", String(input.id), "--json"]; if (input.set_frontmatter && typeof input.set_frontmatter === "object") { const fm = input.set_frontmatter as Record<string, string>; args.push( "--set-fm", ...Object.entries(fm).map(([k, v]) => `${k}=${v}`), ); } if (Array.isArray(input.remove_frontmatter)) { args.push( "--remove-fm", ...input.remove_frontmatter.map(String), ); } return args; } // Section replacement mode if (input.replace_section) { const args = ["edit", String(input.id), "--replace-section", String(input.replace_section), "--json"]; if (input.section_content) args.push("--section-content", String(input.section_content)); return args; } if (input.append_text) { const args = [ "edit", String(input.id), "--append", String(input.append_text), "--json", ]; if (input.after) args.push("--after", String(input.after)); return args; } // --stdin case handled separately via usesStdin return ["edit", String(input.id), "--stdin", "--json"]; }, usesStdin: (input) => { if (input.body && !input.append_text) { return String(input.body); } return null; }, }, - mcp-server/src/tools.ts:205-249 (schema)Input schema for bear_edit_note: requires 'id' (string), with optional fields append_text, body, after, replace_section, section_content, set_frontmatter (object), remove_frontmatter (array of strings).
inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Note ID (uniqueIdentifier)", }, append_text: { type: "string", description: "Text to append to the end of the note", }, body: { type: "string", description: "New content to replace the entire note body", }, after: { type: "string", description: "Insert appended text after the line containing this text (use with append_text)", }, replace_section: { type: "string", description: "Replace content under this heading (replaces until next heading of same or higher level)", }, section_content: { type: "string", description: "New content for the section (use with replace_section)", }, set_frontmatter: { type: "object", description: "Front matter fields to set or update (key-value pairs)", additionalProperties: { type: "string" }, }, remove_frontmatter: { type: "array", items: { type: "string" }, description: "Front matter field keys to remove", }, }, required: ["id"], }, - mcp-server/src/tools.ts:9-9 (registration)The tool is registered as part of the exported 'tools' Record on line 9, with the key 'bear_edit_note' at line 200.
export const tools: Record<string, ToolHandler> = { - mcp-server/src/index.ts:46-78 (helper)Validation logic in the server's CallToolRequestSchema handler — checks that at least one edit operation is provided and that append_text and body are not both supplied for bear_edit_note.
// 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, }; } }