87 lines
2.5 KiB
TypeScript

/**
* ActiveCampaign Note Tools
*/
import { ActiveCampaignClient } from '../client/index.js';
import { Note } from '../types/index.js';
export function createNoteTools(client: ActiveCampaignClient) {
return {
ac_list_notes: {
description: 'List all notes',
inputSchema: {
type: 'object',
properties: {
reltype: { type: 'string', description: 'Related type (Deal, Contact, etc.)' },
relid: { type: 'string', description: 'Related ID' },
limit: { type: 'number', description: 'Max results', default: 20 },
},
},
handler: async (params: any) => {
const notes = await client.paginate<Note>('/notes', params, params.limit || 20);
return { notes, count: notes.length };
},
},
ac_get_note: {
description: 'Get a note by ID',
inputSchema: {
type: 'object',
properties: {
id: { type: 'string', description: 'Note ID' },
},
required: ['id'],
},
handler: async (params: { id: string }) => {
return client.get<{ note: Note }>(`/notes/${params.id}`);
},
},
ac_create_note: {
description: 'Create a new note',
inputSchema: {
type: 'object',
properties: {
note: { type: 'string', description: 'Note content' },
reltype: { type: 'string', description: 'Related type (Deal, Contact, Subscriber, etc.)' },
relid: { type: 'string', description: 'Related entity ID' },
},
required: ['note'],
},
handler: async (params: Note) => {
return client.post<{ note: Note }>('/notes', { note: params });
},
},
ac_update_note: {
description: 'Update a note',
inputSchema: {
type: 'object',
properties: {
id: { type: 'string', description: 'Note ID' },
note: { type: 'string', description: 'Note content' },
},
required: ['id', 'note'],
},
handler: async (params: Note & { id: string }) => {
const { id, ...note } = params;
return client.put<{ note: Note }>(`/notes/${id}`, { note });
},
},
ac_delete_note: {
description: 'Delete a note',
inputSchema: {
type: 'object',
properties: {
id: { type: 'string', description: 'Note ID' },
},
required: ['id'],
},
handler: async (params: { id: string }) => {
return client.delete(`/notes/${params.id}`);
},
},
};
}