Skip to main content
Glama

add_text

Modify Bear notes by appending, prepending, or replacing text. Specify the note ID or title, input the text, and choose the modification mode to update content directly in Bear MCP Server.

Instructions

Append or prepend text to an existing note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoNote unique identifier
modeNoHow to add the text (default: append)
textYesText to add
titleNoNote title (ignored if id is provided)

Implementation Reference

  • src/index.ts:479-505 (registration)
    Registration of the 'add_text' tool in the listTools handler, including name, description, and input schema definition.
    { name: "add_text", description: "Append or prepend text to an existing note", inputSchema: { type: "object", properties: { id: { type: "string", description: "Note unique identifier", }, title: { type: "string", description: "Note title (ignored if id is provided)", }, text: { type: "string", description: "Text to add", }, mode: { type: "string", enum: ["append", "prepend", "replace", "replace_all"], description: "How to add the text (default: append)", }, }, required: ["text"], }, },
  • Input schema definition for the 'add_text' tool, specifying parameters like id, title, text, and mode.
    inputSchema: { type: "object", properties: { id: { type: "string", description: "Note unique identifier", }, title: { type: "string", description: "Note title (ignored if id is provided)", }, text: { type: "string", description: "Text to add", }, mode: { type: "string", enum: ["append", "prepend", "replace", "replace_all"], description: "How to add the text (default: append)", }, }, required: ["text"], },
  • Handler implementation for 'add_text' tool in the CallToolRequestSchema switch statement. Prepares Bear URL parameters and calls executeBearURL to invoke Bear's add-text action, then formats response.
    case "add_text": { const params: BearParams = { text: String(args.text), }; if (args.id) params.id = String(args.id); if (args.title) params.title = String(args.title); if (args.mode) params.mode = String(args.mode); const response = await executeBearURL("add-text", params, true); if (response && response.identifier) { return { content: [ { type: "text", text: `Text added successfully to note: ${response.title || "Untitled"} (ID: ${response.identifier})`, }, ], }; } else { return { content: [ { type: "text", text: "Text added to note in Bear", }, ], }; } }
  • Shared helper function executeBearURL that constructs and executes the Bear app x-callback-url for the 'add-text' action via AppleScript, with optional callback response handling.
    async function executeBearURL(action: string, params: BearParams, expectResponse: boolean = false, requiresToken: boolean = false): Promise<BearResponse | null> { const callbackHandler = new BearCallbackHandler(); try { // Add token if required and available if (requiresToken) { const token = getCurrentToken(); if (token) { params.token = token; } else { throw new Error("Token required but not available. Use set_bear_token to configure."); } } // Always use show_window=no to prevent Bear from opening if (!params.hasOwnProperty('show_window')) { params.show_window = "no"; } // Start callback server if we expect a response if (expectResponse) { await callbackHandler.startServer(); params["x-success"] = `http://127.0.0.1:${CALLBACK_PORT}/bear-callback`; params["x-error"] = `http://127.0.0.1:${CALLBACK_PORT}/bear-callback`; } // Build the URL const url = new URL(`${BEAR_URL_SCHEME}/${action}`); Object.entries(params).forEach(([key, value]) => { if (value !== undefined) { url.searchParams.append(key, value); } }); console.error(`[DEBUG] Opening Bear URL: ${url.toString()}`); // Use AppleScript to open the URL (more reliable than 'open' command) const script = `open location "${url.toString()}"`; try { execSync(`osascript -e '${script}'`, { stdio: 'pipe' }); } catch (execError) { console.error(`[DEBUG] Error executing AppleScript:`, execError); throw new Error(`Failed to open Bear URL: ${execError}`); } // Wait for callback if expected if (expectResponse) { try { const response = await callbackHandler.waitForCallback(); // Check for errors in response if (response.errorCode || response['error-Code'] || response.errorMessage) { const errorCode = response.errorCode || response['error-Code'] || 'unknown'; const errorMessage = response.errorMessage || response.errorMessage || 'Unknown error'; throw new Error(`Bear API Error ${errorCode}: ${errorMessage}`); } return response; } catch (error) { console.error(`[DEBUG] Callback error:`, error); throw error; } } return null; } finally { // Always stop the server callbackHandler.stopServer(); } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/philgetzen/bear-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server