We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/schizoidcock/mcx'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { defineSkill } from '@mcx/core';
export default defineSkill({
name: 'overdue-report',
description: 'Generate a report of overdue invoices grouped by client',
async run({ alegra }) {
const invoices = await alegra.getInvoices({ status: 'open' });
const today = new Date();
const overdue = invoices.filter(inv => new Date(inv.dueDate) < today);
// Group by client
const byClient = overdue.reduce((acc, inv) => {
const clientName = inv.client.name;
if (!acc[clientName]) {
acc[clientName] = {
clientId: inv.client.id,
invoices: [],
totalBalance: 0,
};
}
acc[clientName].invoices.push({
id: inv.id,
number: inv.number,
dueDate: inv.dueDate,
balance: inv.balance,
daysOverdue: Math.floor((today.getTime() - new Date(inv.dueDate).getTime()) / (1000 * 60 * 60 * 24)),
});
acc[clientName].totalBalance += inv.balance;
return acc;
}, {} as Record<string, any>);
// Sort by total balance descending
const sorted = Object.entries(byClient)
.sort(([, a], [, b]) => b.totalBalance - a.totalBalance)
.map(([name, data]) => ({ clientName: name, ...data }));
return {
totalOverdue: overdue.length,
totalAmount: overdue.reduce((sum, inv) => sum + inv.balance, 0),
byClient: sorted,
generatedAt: new Date().toISOString(),
};
},
});