Skip to main content
Glama
openNote.ts1.48 kB
import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { BearDB } from "../bearDB.js"; import { formatDate } from "../types.js"; export const openNoteTool: Tool = { name: "open_note", description: "Open a Bear note by title or ID", inputSchema: { type: "object", properties: { query: { type: "string", description: "Note title or ID to open" } }, required: ["query"] } }; export async function handleOpenNote(bearDB: BearDB, args: any) { const { query } = args; if (!query || typeof query !== 'string') { return { content: [{ type: "text", text: "Error: Please provide a note title or ID" }] }; } try { const note = bearDB.getNoteByTitleOrId(query); if (!note) { return { content: [{ type: "text", text: `No note found with title or ID: "${query}"` }] }; } const response = `# ${note.title} ${note.content} --- **Tags:** ${note.tags.length > 0 ? note.tags.map(t => `#${t}`).join(', ') : 'None'} **Created:** ${formatDate(note.creationDate)} **Modified:** ${formatDate(note.modificationDate)} **ID:** ${note.id}`; return { content: [{ type: "text", text: response }] }; } catch (error) { return { content: [{ type: "text", text: `Error opening note: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }

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/quanticsoul4772/bear-mcp'

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