create_label
Create custom labels with color coding to organize and categorize notes in NotesKeep. Add labels to notes for better structure and quick retrieval.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the label | |
| color | No | Label color | gray |
Implementation Reference
- src/index.ts:323-345 (handler)The handler function for the create_label tool, which performs an API request to /api/labels to create a new label.
async ({ name, color }) => { try { const data = await apiRequest("/api/labels", { method: "POST", body: JSON.stringify({ name, color }), }); return { content: [{ type: "text", text: `Label created successfully!\nID: ${data.label.id}\nName: ${data.label.name}\nColor: ${data.label.color}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating label: ${error}` }], isError: true }; } } - src/index.ts:319-322 (schema)Input validation schema for the create_label tool using Zod.
{ name: z.string().describe("Name of the label"), color: z.enum(["gray", "red", "orange", "yellow", "green", "blue", "purple", "pink"]).optional().default("gray").describe("Label color"), }, - src/index.ts:317-346 (registration)Registration of the create_label tool using server.tool.
server.tool( "create_label", { name: z.string().describe("Name of the label"), color: z.enum(["gray", "red", "orange", "yellow", "green", "blue", "purple", "pink"]).optional().default("gray").describe("Label color"), }, async ({ name, color }) => { try { const data = await apiRequest("/api/labels", { method: "POST", body: JSON.stringify({ name, color }), }); return { content: [{ type: "text", text: `Label created successfully!\nID: ${data.label.id}\nName: ${data.label.name}\nColor: ${data.label.color}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating label: ${error}` }], isError: true }; } } );