bear_sync
Trigger incremental or full sync of Bear notes from iCloud to ensure up-to-date data, though auto-sync typically handles cache staleness.
Instructions
Trigger a sync of Bear notes from iCloud. Normally an incremental sync fetching only changes. Use 'full' to force a complete re-sync. Most read operations auto-sync when the cache is stale, so manual sync is rarely needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | Force a full re-sync instead of incremental |
Implementation Reference
- mcp-server/src/tools.ts:335-360 (schema)Definition of the 'bear_sync' tool including its schema (input properties for 'full' boolean), description, and annotations. The buildArgs function constructs CLI args ['sync', '--json'] and optionally adds '--full' if the input.full flag is set.
bear_sync: { tool: { name: "bear_sync", description: "Trigger a sync of Bear notes from iCloud. Normally an incremental sync fetching only changes. Use 'full' to force a complete re-sync. Most read operations auto-sync when the cache is stale, so manual sync is rarely needed.", inputSchema: { type: "object" as const, properties: { full: { type: "boolean", description: "Force a full re-sync instead of incremental", }, }, }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, }, }, buildArgs: (input) => { const args = ["sync", "--json"]; if (input.full) args.push("--full"); return args; }, }, - mcp-server/src/index.ts:29-31 (registration)All tools including bear_sync are registered via ListToolsRequestSchema handler which maps all tool definitions from tools.ts into MCP tool list.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools).map((t) => t.tool), })); - mcp-server/src/index.ts:33-42 (registration)CallToolRequestSchema handler looks up the tool by name from the tools object and invokes its buildArgs function, which for bear_sync builds the 'sync --json' 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, }; } - mcp-server/src/bcli.ts:256-268 (helper)execBcliWithReauth is the helper that executes the bcli command built by bear_sync's buildArgs (i.e., 'bcli sync --json' with optional '--full'), with automatic reauthentication on auth errors.
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; } }