bear_context_set_prefix
Change the tag prefix for context notes, retagging all existing notes with the new prefix while preserving sub-tags. Solves aligning qualifier tags with a broader naming scheme.
Instructions
Change the context library's tag prefix and re-tag every Bear note that currently uses the old prefix. Sub-tags are preserved — #context/research becomes #<new>/research. Updates both the markdown body and the CloudKit tag index, and persists the new prefix to the context config. Useful when aligning the qualifier tag with a broader naming scheme like Johnny Decimal (e.g. '10-projects'). Run bear_context_sync afterwards to refresh the library.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new_prefix | Yes | New tag prefix without the leading #. Example: '10-projects'. |
Implementation Reference
- mcp-server/src/tools.ts:1159-1165 (handler)buildArgs function that builds the CLI arguments for the 'bear_context_set_prefix' tool. It returns ['context', 'set-prefix', String(input.new_prefix), '--json'] which calls the bcli command to change the context library's tag prefix.
buildArgs: (input) => [ "context", "set-prefix", String(input.new_prefix), "--json", ], }, - mcp-server/src/tools.ts:1142-1152 (schema)Input schema for bear_context_set_prefix, defining a required 'new_prefix' string parameter (the new tag prefix without leading #).
inputSchema: { type: "object" as const, properties: { new_prefix: { type: "string", description: "New tag prefix without the leading #. Example: '10-projects'.", }, }, required: ["new_prefix"], }, - mcp-server/src/tools.ts:1137-1165 (registration)Registration of the 'bear_context_set_prefix' tool in the tools registry. It's a key in the `tools` Record exported from tools.ts, containing both the tool metadata and the buildArgs function.
bear_context_set_prefix: { tool: { name: "bear_context_set_prefix", description: "Change the context library's tag prefix and re-tag every Bear note that currently uses the old prefix. Sub-tags are preserved — `#context/research` becomes `#<new>/research`. Updates both the markdown body and the CloudKit tag index, and persists the new prefix to the context config. Useful when aligning the qualifier tag with a broader naming scheme like Johnny Decimal (e.g. '10-projects'). Run `bear_context_sync` afterwards to refresh the library.", inputSchema: { type: "object" as const, properties: { new_prefix: { type: "string", description: "New tag prefix without the leading #. Example: '10-projects'.", }, }, required: ["new_prefix"], }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, }, }, buildArgs: (input) => [ "context", "set-prefix", String(input.new_prefix), "--json", ], }, - mcp-server/src/index.ts:29-31 (registration)The MCP server registers all tools (including bear_context_set_prefix) by exporting their Tool definitions via ListToolsRequestSchema and invoking them via CallToolRequestSchema.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.values(tools).map((t) => t.tool), }));