bear_get_note
Retrieve a Bear note's full content and metadata by its ID, including title, tags, and markdown. Optionally return only raw markdown content.
Instructions
Get a single Bear note's full content and metadata by ID. Returns the note title, tags, full markdown text, and dates. The response includes 'tags' (CloudKit index, may contain ancestor tags like 'parent' for a note tagged '#parent/child') and 'attached_tags' (leaves only). If the note is locked/private, 'locked: true' will be included in the response. Use the 'raw' option to get just the markdown without metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Note ID (uniqueIdentifier) | |
| raw | No | Return only the raw markdown content |
Implementation Reference
- mcp-server/src/tools.ts:53-83 (registration)Registration of the bear_get_note tool in the tools registry. Defines the tool name, description, input schema (id required, raw optional), annotations, and the buildArgs function that constructs the CLI arguments: ['get', id, '--json'] with optional '--raw' flag.
bear_get_note: { tool: { name: "bear_get_note", description: "Get a single Bear note's full content and metadata by ID. Returns the note title, tags, full markdown text, and dates. The response includes 'tags' (CloudKit index, may contain ancestor tags like 'parent' for a note tagged '#parent/child') and 'attached_tags' (leaves only). If the note is locked/private, 'locked: true' will be included in the response. Use the 'raw' option to get just the markdown without metadata.", inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Note ID (uniqueIdentifier)", }, raw: { type: "boolean", description: "Return only the raw markdown content", }, }, required: ["id"], }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, buildArgs: (input) => { const args = ["get", String(input.id), "--json"]; if (input.raw) args.push("--raw"); return args; }, }, - mcp-server/src/index.ts:33-91 (handler)The CallToolRequestSchema handler that dispatches tool calls. For bear_get_note, it calls handler.buildArgs(params) to produce CLI args, then executes them via execBcliWithReauth() (no stdin), parses JSON output, and returns it as the tool result.
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); } - mcp-server/src/bcli.ts:256-268 (helper)execBcliWithReauth - the execution helper that runs the bcli CLI command (e.g., 'bcli get <id> --json') and handles automatic re-authentication if the session has expired.
export async function execBcliWithReauth( args: string[], ): Promise<{ stdout: string; stderr: string }> { try { return await execBcli(args); } catch (error) { if (error instanceof AuthError) { await performReauth(); return await execBcli(args); } throw error; } } - mcp-server/src/bcli.ts:133-151 (helper)execBcli - the base execution helper that spawns the bcli binary with given args via execFile, supporting the bear_get_note tool which uses non-stdin command execution.
export function execBcli( args: string[], ): Promise<{ stdout: string; stderr: string }> { return new Promise(async (resolve, reject) => { const bcliPath = await findBcli(); execFile( bcliPath, args, { timeout: TIMEOUT_MS, maxBuffer: MAX_BUFFER }, (error, stdout, stderr) => { if (error) { reject(classifyError(stderr || error.message, error.code ? null : 1)); } else { resolve({ stdout, stderr }); } }, ); }); } - mcp-server/src/tools.ts:58-71 (schema)Input schema for bear_get_note: requires 'id' (string), optional 'raw' (boolean). Defines the validation contract for the tool.
inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Note ID (uniqueIdentifier)", }, raw: { type: "boolean", description: "Return only the raw markdown content", }, }, required: ["id"], },