bear_context_fetch
Load full content of specific files from the context library by passing relative paths. Use after reading the index to fetch only relevant files.
Instructions
Load the full content of specific files from the context library. Pass relative paths like 'bear/arch-overview.md' or 'external/jira-ticket.md'. Use after reading the index to load only relevant files — never load everything.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | File paths relative to context directory (e.g., 'bear/my-note.md') |
Implementation Reference
- mcp-server/src/index.ts:29-31 (registration)The tool is registered as a MCP tool via Object.values(tools) being passed to ListToolsRequestSchema. The 'name' from the tool definition is exposed to MCP clients.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools).map((t) => t.tool), })); - mcp-server/src/tools.ts:834-863 (handler)The handler for bear_context_fetch. It defines the tool metadata (name, description, inputSchema requiring 'paths' array) and buildArgs which constructs CLI args ['context', 'fetch', '--json', ...paths] to invoke the bcli command.
bear_context_fetch: { tool: { name: "bear_context_fetch", description: "Load the full content of specific files from the context library. Pass relative paths like 'bear/arch-overview.md' or 'external/jira-ticket.md'. Use after reading the index to load only relevant files — never load everything.", inputSchema: { type: "object" as const, properties: { paths: { type: "array", items: { type: "string" }, description: "File paths relative to context directory (e.g., 'bear/my-note.md')", }, }, required: ["paths"], }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, buildArgs: (input) => { const args = ["context", "fetch", "--json"]; const paths = input.paths as string[]; args.push(...paths); return args; }, }, - mcp-server/src/tools.ts:839-849 (schema)Input schema defining that the tool takes a required 'paths' array of strings. Each path is relative to the context directory.
inputSchema: { type: "object" as const, properties: { paths: { type: "array", items: { type: "string" }, description: "File paths relative to context directory (e.g., 'bear/my-note.md')", }, }, required: ["paths"], - mcp-server/src/index.ts:81-90 (helper)Execution logic in index.ts that calls handler.buildArgs (which returns ['context', 'fetch', '--json', ...paths]) and invokes the bcli CLI tool. The JSON stdout is parsed and returned to the MCP client.
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); }