bear_health_check
Run a Bear notes health check to find duplicate titles, empty notes, trash issues, sync conflicts, orphaned tags, untagged notes, and oversized notes. Use results to clean up or diagnose sync issues.
Instructions
Run a health check on the Bear notes library. Reports duplicate titles, empty notes, notes stuck in trash, sync conflicts, orphaned tags, untagged notes, and oversized notes. Use this to identify cleanup opportunities or diagnose sync issues.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp-server/src/tools.ts:728-744 (registration)Registration of bear_health_check tool in the tools map. Defines tool name, description, empty inputSchema, annotations, and buildArgs (which builds CLI args ['health', '--json']).
bear_health_check: { tool: { name: "bear_health_check", description: "Run a health check on the Bear notes library. Reports duplicate titles, empty notes, notes stuck in trash, sync conflicts, orphaned tags, untagged notes, and oversized notes. Use this to identify cleanup opportunities or diagnose sync issues.", inputSchema: { type: "object" as const, properties: {}, }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, buildArgs: () => ["health", "--json"], }, - mcp-server/src/index.ts:33-90 (handler)Generic handler in index.ts that routes all tool calls. For bear_health_check, it calls handler.buildArgs(params) (producing ['health', '--json']) and then executes via execBcliWithReauth. The JSON output from the bcli health command is parsed and returned 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); }