create_note
Generate and store notes with a title and content using an automation tool designed for streamlined note creation on an enterprise-grade platform.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Note content | |
| title | Yes | Note title |
Implementation Reference
- src/tools/create_note.ts:23-64 (handler)Main handler function for the 'create_note' tool. It validates input title and content, generates a unique ID, stores the note in the global 'notes' object, and returns a success message with the note ID or an error response.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 }; } };
- src/tools/create_note.ts:6-21 (schema)JSON schema defining the input parameters for the 'create_note' tool: 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"] };
- src/tools/create_note.ts:2-3 (helper)Type definition for Note and global storage object 'notes' used to persist created notes, shared with other handlers like ResourceHandler and PromptHandler.type Note = { title: string; content: string }; export const notes: { [id: string]: Note } = {};
- src/tools/create_note.ts:67-70 (helper)Destroy function called during tool reload or shutdown to release resources.export async function destroy() { // Release resources, stop timers, disconnect, etc. console.log("Destroy create_note"); }
- src/handler/ToolHandler.ts:117-130 (registration)Dynamic registration of 'create_note' tool (derived from filename) during loadTools(): imports handler, schema, destroy; adds to tools list and handlers map.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) {