UNPKG

actual-mcp

Version:

Actual Budget MCP server exposing API functionality

29 lines 1.22 kB
import { z, toJSONSchema } from 'zod'; import { success, errorFromCatch } from '../../utils/response.js'; import { deleteTransaction } from '../../actual-api.js'; const DeleteTransactionArgsSchema = z.object({ id: z.string().describe('Required. The ID of the transaction to delete'), }); export const schema = { name: 'delete-transaction', description: 'Delete a transaction by its ID. This action is permanent and cannot be undone.', inputSchema: toJSONSchema(DeleteTransactionArgsSchema), }; export async function handler(args) { try { const validatedArgs = DeleteTransactionArgsSchema.parse(args); const result = await deleteTransaction(validatedArgs.id); // API returns array of deleted transactions - empty means nothing was found if (Array.isArray(result) && result.length === 0) { return { content: [{ type: 'text', text: `Transaction ${validatedArgs.id} not found or already deleted` }], isError: true, }; } return success(`Successfully deleted transaction ${validatedArgs.id}`); } catch (error) { return errorFromCatch(error); } } //# sourceMappingURL=index.js.map