Skip to main content
Glama

create_note

Create and save new notes with titles and content using this automation tool for organizing information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesNote title
contentYesNote content

Implementation Reference

  • The handler function that implements the core logic of the 'create_note' tool: parses arguments, validates title and content lengths, generates a sequential ID, stores the note in the global 'notes' object, and returns a formatted response or error.
    export default async (request: any) => { try { const title = String(request.params.arguments?.title); const content = String(request.params.arguments?.content); if (!title || !content) { throw new Error("Title and content are required"); } if (title.length > 100) { throw new Error("Title must be less than 100 characters"); } if (content.length > 1000) { throw new Error("Content must be less than 1000 characters"); } const id = String(Object.keys(notes).length + 1); notes[id] = { title, content }; return { content: [ { type: "text", text: JSON.stringify({ message: `Created note ${id}: ${title}`, id: id }, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify(`Error creating note: ${error.message}`, null, 2), }, ], isError: true }; } };
  • The JSON schema defining the input parameters for the 'create_note' tool, including required 'title' and 'content' strings.
    export const schema = { name: "create_note", description: "Create a new note", type: "object", properties: { title: { type: "string", description: "Note title", }, content: { type: "string", description: "Note content", }, }, required: ["title", "content"] };
  • Dynamic registration code in loadTools function that imports the create_note module (based on filename), extracts the default handler, schema, and destroy function, and registers them in global tools and handlers maps using the filename 'create_note' as the tool name.
    const importPath = 'file://' + toolPath + (reload ? `?update=${Date.now()}` : ''); const { default: tool, schema, destroy } = await import(importPath); const toolName = path.parse(toolPath).name; // 注册工具 tools.push({ name: toolName, description: tool.description, inputSchema: schema, destroy: destroy }); // 注册处理函数 handlers[toolName] = async (request: ToolRequest) => { return await tool(request); }; } catch (error) {
  • Global in-memory storage object for notes created by the tool, shared with other handlers like ResourceHandler and PromptHandler.
    type Note = { title: string; content: string }; export const notes: { [id: string]: Note } = {};
  • Cleanup function called during tool unload or reload to release resources.
    export async function destroy() { // Release resources, stop timers, disconnect, etc. console.log("Destroy create_note"); }

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/xiaoguomeiyitian/ToolBox'

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