notes.js•2.71 kB
export const noteTools = [
{
name: "list_notes",
description: "List notes with optional filtering and pagination",
inputSchema: {
type: "object",
properties: {
filter: { type: "string", description: "Filter query (JSON string)" },
orderBy: { type: "string", description: "Order by field" },
limit: { type: "number", description: "Number of results (max 100)" },
depth: { type: "number", description: "Query depth for relations" },
startingAfter: { type: "string", description: "Cursor for pagination" },
endingBefore: { type: "string", description: "Cursor for pagination" }
}
}
},
{
name: "create_note",
description: "Create a new note in Twenty CRM",
inputSchema: {
type: "object",
properties: {
title: { type: "string", description: "Note title" },
body: { type: "string", description: "Note body/content" },
position: { type: "number", description: "Position" }
}
}
},
{
name: "get_note",
description: "Get details of a specific note by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Note ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_note",
description: "Update an existing note's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Note ID" },
title: { type: "string" },
body: { type: "string" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_note",
description: "Delete a note from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Note ID" }
},
required: ["id"]
}
}
];
export async function executeNoteTool(toolName, params, apiClient) {
switch (toolName) {
case "list_notes":
return await apiClient.makeRequest("/notes", "GET", null, params);
case "create_note":
return await apiClient.makeRequest("/notes", "POST", params);
case "get_note":
return await apiClient.makeRequest(`/notes/${params.id}`, "GET", null, { depth: params.depth });
case "update_note":
const { id: noteId, ...noteData } = params;
return await apiClient.makeRequest(`/notes/${noteId}`, "PUT", noteData);
case "delete_note":
return await apiClient.makeRequest(`/notes/${params.id}`, "DELETE");
default:
throw new Error(`Unknown note tool: ${toolName}`);
}
}