import { defineAdapter } from '@mcx/adapters';
// Minimal Alegra adapter for testing MCX serve
export const alegra = defineAdapter({
name: 'alegra',
description: 'Alegra API adapter',
tools: {
getInvoices: {
description: 'List invoices with optional filters',
parameters: {
status: { type: 'string', description: 'Filter by status: open, closed, void' },
limit: { type: 'number', description: 'Max results', default: 50 },
},
execute: async ({ status, limit }: { status?: string; limit?: number }) => {
// Mock implementation for testing
console.log(`[alegra] getInvoices status=${status} limit=${limit}`);
return [
{ id: '1', number: 'INV-001', status: 'open', total: 1000 },
{ id: '2', number: 'INV-002', status: 'closed', total: 2500 },
];
},
},
getContacts: {
description: 'List contacts (clients and providers)',
parameters: {
type: { type: 'string', description: 'Filter by type: client, provider' },
limit: { type: 'number', description: 'Max results', default: 50 },
},
execute: async ({ type, limit }: { type?: string; limit?: number }) => {
console.log(`[alegra] getContacts type=${type} limit=${limit}`);
return [
{ id: '1', name: 'Cliente A', type: ['client'] },
{ id: '2', name: 'Proveedor B', type: ['provider'] },
];
},
},
getPayments: {
description: 'List payments',
parameters: {
limit: { type: 'number', description: 'Max results', default: 50 },
},
execute: async ({ limit }: { limit?: number }) => {
console.log(`[alegra] getPayments limit=${limit}`);
return [
{ id: '1', date: '2026-01-15', amount: 500 },
{ id: '2', date: '2026-02-01', amount: 1000 },
];
},
},
},
});