bear_context_import
Import markdown content from external sources like Jira, Slack, or API docs into the Bear context library. Each entry includes source, group, summary, and date metadata.
Instructions
Import external content into the context library. Content is written to the external/ directory with YAML front matter (source, group, summary, date). Use this to add non-Bear content like Jira tickets, Slack threads, API docs, or any markdown. The content is passed via stdin and a filename must be provided.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | Target filename in external/ (e.g., 'jira-ticket-123.md') | |
| content | Yes | Markdown content to import | |
| group | No | Group label for organizing (e.g., 'jira', 'slack', 'docs') | |
| source | No | Source description (e.g., URL, tool name) | |
| summary | No | Short summary of the content |
Implementation Reference
- mcp-server/src/tools.ts:972-1021 (registration)Registration of bear_context_import tool in the tools registry. Exports the tool definition, input schema, args builder, and stdin handler.
bear_context_import: { tool: { name: "bear_context_import", description: "Import external content into the context library. Content is written to the external/ directory with YAML front matter (source, group, summary, date). Use this to add non-Bear content like Jira tickets, Slack threads, API docs, or any markdown. The content is passed via stdin and a filename must be provided.", inputSchema: { type: "object" as const, properties: { filename: { type: "string", description: "Target filename in external/ (e.g., 'jira-ticket-123.md')", }, content: { type: "string", description: "Markdown content to import", }, group: { type: "string", description: "Group label for organizing (e.g., 'jira', 'slack', 'docs')", }, source: { type: "string", description: "Source description (e.g., URL, tool name)", }, summary: { type: "string", description: "Short summary of the content", }, }, required: ["filename", "content"], }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, }, }, buildArgs: (input) => { const args = ["context", "import", "--stdin", "--json"]; if (input.filename) args.push("--filename", String(input.filename)); if (input.group) args.push("--group", String(input.group)); if (input.source) args.push("--source", String(input.source)); if (input.summary) args.push("--summary", String(input.summary)); return args; }, usesStdin: (input) => (input.content ? String(input.content) : null), }, - mcp-server/src/tools.ts:977-1005 (schema)Input schema for bear_context_import: accepts filename (required), content (required), group, source, and summary.
inputSchema: { type: "object" as const, properties: { filename: { type: "string", description: "Target filename in external/ (e.g., 'jira-ticket-123.md')", }, content: { type: "string", description: "Markdown content to import", }, group: { type: "string", description: "Group label for organizing (e.g., 'jira', 'slack', 'docs')", }, source: { type: "string", description: "Source description (e.g., URL, tool name)", }, summary: { type: "string", description: "Short summary of the content", }, }, required: ["filename", "content"], }, - mcp-server/src/tools.ts:1012-1019 (handler)Handler logic: builds CLI args for the 'context import' subcommand and pipes content via stdin. Invokes external bcli tool.
buildArgs: (input) => { const args = ["context", "import", "--stdin", "--json"]; if (input.filename) args.push("--filename", String(input.filename)); if (input.group) args.push("--group", String(input.group)); if (input.source) args.push("--source", String(input.source)); if (input.summary) args.push("--summary", String(input.summary)); return args; }, - mcp-server/src/bcli.ts:270-283 (helper)Helper that executes bcli with stdin data (used for the content parameter) and automatic re-authentication on auth errors.
export async function execBcliWithStdinAndReauth( args: string[], input: string, ): Promise<{ stdout: string; stderr: string }> { try { return await execBcliWithStdin(args, input); } catch (error) { if (error instanceof AuthError) { await performReauth(); return await execBcliWithStdin(args, input); } throw error; } }