bear_context_search
Search across Bear notes, external files, and inbox for full-text matches. Returns snippets with filenames and origin labels for precise file retrieval.
Instructions
Full-text search across the entire context library (Bear notes + external files + inbox). Returns matching snippets with filenames and origin labels. Use when the index alone isn't enough to find the right file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (case-insensitive substring match) | |
| limit | No | Maximum results (default: 5) |
Implementation Reference
- mcp-server/src/tools.ts:890-894 (handler)The buildArgs function for bear_context_search that constructs the CLI arguments ['context', 'search', query, '--json'] with optional --limit.
buildArgs: (input) => { const args = ["context", "search", String(input.query), "--json"]; if (input.limit) args.push("--limit", String(input.limit)); return args; }, - mcp-server/src/tools.ts:865-889 (schema)Tool definition for bear_context_search including name, description, inputSchema (query required, limit optional), and annotations (readOnly, non-destructive, idempotent).
bear_context_search: { tool: { name: "bear_context_search", description: "Full-text search across the entire context library (Bear notes + external files + inbox). Returns matching snippets with filenames and origin labels. Use when the index alone isn't enough to find the right file.", inputSchema: { type: "object" as const, properties: { query: { type: "string", description: "Search query (case-insensitive substring match)", }, limit: { type: "number", description: "Maximum results (default: 5)", }, }, required: ["query"], }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, - mcp-server/src/index.ts:29-31 (registration)The tool is registered via ListToolsRequestSchema handler which exposes all tools including bear_context_search from the tools registry.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools).map((t) => t.tool), })); - mcp-server/src/index.ts:33-41 (registration)The CallToolRequestSchema handler dispatches to tools[name], which at runtime routes bear_context_search calls to the correct handler.
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, };