quantix-mcp 0.4.5 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/opsx/apply.md +152 -0
- package/.claude/commands/opsx/archive.md +157 -0
- package/.claude/commands/opsx/bulk-archive.md +242 -0
- package/.claude/commands/opsx/continue.md +114 -0
- package/.claude/commands/opsx/explore.md +174 -0
- package/.claude/commands/opsx/ff.md +94 -0
- package/.claude/commands/opsx/new.md +69 -0
- package/.claude/commands/opsx/onboard.md +525 -0
- package/.claude/commands/opsx/sync.md +134 -0
- package/.claude/commands/opsx/verify.md +164 -0
- package/.claude/settings.local.json +2 -1
- package/.claude/skills/openspec-apply-change/SKILL.md +156 -0
- package/.claude/skills/openspec-archive-change/SKILL.md +114 -0
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.claude/skills/openspec-continue-change/SKILL.md +118 -0
- package/.claude/skills/openspec-explore/SKILL.md +290 -0
- package/.claude/skills/openspec-ff-change/SKILL.md +101 -0
- package/.claude/skills/openspec-new-change/SKILL.md +74 -0
- package/.claude/skills/openspec-onboard/SKILL.md +529 -0
- package/.claude/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.claude/skills/openspec-verify-change/SKILL.md +168 -0
- package/.dockerignore +8 -0
- package/.gemini/commands/opsx/apply.toml +149 -0
- package/.gemini/commands/opsx/archive.toml +154 -0
- package/.gemini/commands/opsx/bulk-archive.toml +239 -0
- package/.gemini/commands/opsx/continue.toml +111 -0
- package/.gemini/commands/opsx/explore.toml +171 -0
- package/.gemini/commands/opsx/ff.toml +91 -0
- package/.gemini/commands/opsx/new.toml +66 -0
- package/.gemini/commands/opsx/onboard.toml +522 -0
- package/.gemini/commands/opsx/sync.toml +131 -0
- package/.gemini/commands/opsx/verify.toml +161 -0
- package/.gemini/skills/openspec-apply-change/SKILL.md +156 -0
- package/.gemini/skills/openspec-archive-change/SKILL.md +114 -0
- package/.gemini/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.gemini/skills/openspec-continue-change/SKILL.md +118 -0
- package/.gemini/skills/openspec-explore/SKILL.md +290 -0
- package/.gemini/skills/openspec-ff-change/SKILL.md +101 -0
- package/.gemini/skills/openspec-new-change/SKILL.md +74 -0
- package/.gemini/skills/openspec-onboard/SKILL.md +529 -0
- package/.gemini/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.gemini/skills/openspec-verify-change/SKILL.md +168 -0
- package/.qwen/commands/opsx-apply.toml +149 -0
- package/.qwen/commands/opsx-archive.toml +154 -0
- package/.qwen/commands/opsx-bulk-archive.toml +239 -0
- package/.qwen/commands/opsx-continue.toml +111 -0
- package/.qwen/commands/opsx-explore.toml +171 -0
- package/.qwen/commands/opsx-ff.toml +91 -0
- package/.qwen/commands/opsx-new.toml +66 -0
- package/.qwen/commands/opsx-onboard.toml +522 -0
- package/.qwen/commands/opsx-sync.toml +131 -0
- package/.qwen/commands/opsx-verify.toml +161 -0
- package/.qwen/skills/openspec-apply-change/SKILL.md +156 -0
- package/.qwen/skills/openspec-archive-change/SKILL.md +114 -0
- package/.qwen/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.qwen/skills/openspec-continue-change/SKILL.md +118 -0
- package/.qwen/skills/openspec-explore/SKILL.md +290 -0
- package/.qwen/skills/openspec-ff-change/SKILL.md +101 -0
- package/.qwen/skills/openspec-new-change/SKILL.md +74 -0
- package/.qwen/skills/openspec-onboard/SKILL.md +529 -0
- package/.qwen/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.qwen/skills/openspec-verify-change/SKILL.md +168 -0
- package/AGENTS.md +117 -0
- package/Dockerfile +30 -0
- package/GEMINI.md +59 -0
- package/QWEN.md +117 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/dist/tools/transactions.d.ts.map +1 -1
- package/dist/tools/transactions.js +33 -3
- package/dist/tools/transactions.js.map +1 -1
- package/dist/types/schemas.d.ts +66 -7
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +36 -10
- package/dist/types/schemas.js.map +1 -1
- package/docker-compose.yml +9 -0
- package/openapi.yaml +212 -54
- package/openspec/README.md +33 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/design.md +60 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/proposal.md +25 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/specs/credit-card-transactions/spec.md +46 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/specs/transactions/spec.md +42 -0
- package/openspec/changes/archive/2026-04-03-separate-credit-card-transaction-tools/tasks.md +22 -0
- package/openspec/config.yaml +20 -0
- package/openspec/specs/accounts/spec.md +86 -0
- package/openspec/specs/categories/spec.md +78 -0
- package/openspec/specs/credit-card-transactions/spec.md +64 -0
- package/openspec/specs/credit-cards/spec.md +109 -0
- package/openspec/specs/data/spec.md +49 -0
- package/openspec/specs/settings/spec.md +48 -0
- package/openspec/specs/subscriptions/spec.md +85 -0
- package/openspec/specs/summary/spec.md +49 -0
- package/openspec/specs/transactions/spec.md +113 -0
- package/openspec/specs/transfers/spec.md +74 -0
- package/package.json +1 -1
- package/src/config.ts +4 -1
- package/src/index.ts +35 -5
- package/src/tools/transactions.ts +47 -3
- package/src/types/schemas.ts +40 -10
- package/tests/tools/accounts.test.ts +1 -1
- package/tests/tools/credit-cards.test.ts +1 -1
- package/tests/tools/transactions.test.ts +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Transactions Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de transações financeiras diretas (receitas e despesas) com métodos de pagamento CASH, PIX e DEBIT. Suporte a recorrência e parcelamento.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- Criação, atualização, exclusão de transações diretas
|
|
9
|
+
- Marcação como paga/não-paga
|
|
10
|
+
- Filtros por mês, conta, categoria, tipo, datas e status de pagamento
|
|
11
|
+
- Recorrência com 3 frequências (WEEKLY, MONTHLY, YEARLY)
|
|
12
|
+
|
|
13
|
+
O que está **fora do escopo**:
|
|
14
|
+
- Transações de cartão de crédito (domínio: credit-card-transactions)
|
|
15
|
+
- Transferências entre contas (domínio: transfers)
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
### Requirement: Create direct transaction
|
|
20
|
+
The system SHALL allow creating a new income or expense transaction with type, name, amount, date, paymentMethod (CASH, PIX, or DEBIT), and accountId.
|
|
21
|
+
|
|
22
|
+
#### Scenario: Successful direct transaction creation
|
|
23
|
+
- **WHEN** the user provides `type`, `name`, `amount`, `date`, `paymentMethod` (CASH, PIX, or DEBIT), and `accountId`
|
|
24
|
+
- **THEN** the system creates the transaction via `POST /transactions` and returns it
|
|
25
|
+
|
|
26
|
+
#### Scenario: Validation rejects credit card fields
|
|
27
|
+
- **WHEN** the user attempts to provide `creditCardId`, `targetDueMonth`, or `purchaseDate`
|
|
28
|
+
- **THEN** the Zod schema rejects the input as those fields are not part of the direct transaction schema
|
|
29
|
+
|
|
30
|
+
#### Scenario: Validation rejects CREDIT payment method
|
|
31
|
+
- **WHEN** the user provides `paymentMethod` as "CREDIT"
|
|
32
|
+
- **THEN** the Zod schema rejects the input as the enum only allows CASH, PIX, DEBIT
|
|
33
|
+
|
|
34
|
+
### Requirement: Update direct transaction
|
|
35
|
+
The system SHALL allow updating a direct payment transaction. For recurring transactions, the user MAY specify an update mode: SINGLE (only this), PENDING (this and future pending), or ALL (all in series).
|
|
36
|
+
|
|
37
|
+
#### Scenario: Successful direct transaction update
|
|
38
|
+
- **WHEN** the user provides a valid transaction ID and one or more updateable fields
|
|
39
|
+
- **THEN** the system updates via `PATCH /transactions/:id` and returns the modified transaction
|
|
40
|
+
|
|
41
|
+
#### Scenario: Recurring transaction update mode
|
|
42
|
+
- **WHEN** the user provides `mode` as SINGLE, PENDING, or ALL
|
|
43
|
+
- **THEN** the update is applied according to the mode
|
|
44
|
+
|
|
45
|
+
#### Scenario: Validation rejects credit card fields
|
|
46
|
+
- **WHEN** the user attempts to provide `creditCardId`, `targetDueMonth`, or `purchaseDate`
|
|
47
|
+
- **THEN** the Zod schema rejects the input
|
|
48
|
+
|
|
49
|
+
### Requirement: Delete transaction
|
|
50
|
+
The system SHALL allow deleting a transaction by its ID. For recurring transactions, the user MAY specify a deletion mode.
|
|
51
|
+
|
|
52
|
+
#### Scenario: Successful deletion
|
|
53
|
+
- **WHEN** the user deletes a transaction with a valid ID
|
|
54
|
+
- **THEN** the system confirms the deletion
|
|
55
|
+
|
|
56
|
+
#### Scenario: Recurring transaction deletion mode
|
|
57
|
+
- **WHEN** the user provides `mode` as SINGLE, PENDING, or ALL
|
|
58
|
+
- **THEN** the deletion applies according to the mode
|
|
59
|
+
|
|
60
|
+
### Requirement: Mark transaction as paid
|
|
61
|
+
The system SHALL allow marking a transaction as paid via `PATCH /transactions/:id/pay`.
|
|
62
|
+
|
|
63
|
+
#### Scenario: Transaction marked as paid
|
|
64
|
+
- **WHEN** the user provides a valid transaction ID
|
|
65
|
+
- **THEN** the transaction's `paid` field is set to true
|
|
66
|
+
|
|
67
|
+
### Requirement: Mark transaction as unpaid
|
|
68
|
+
The system SHALL allow marking a transaction as unpaid via `PATCH /transactions/:id/unpay`.
|
|
69
|
+
|
|
70
|
+
#### Scenario: Transaction marked as unpaid
|
|
71
|
+
- **WHEN** the user provides a valid transaction ID
|
|
72
|
+
- **THEN** the transaction's `paid` field is set to false
|
|
73
|
+
|
|
74
|
+
### Requirement: List transactions
|
|
75
|
+
The system SHALL return transactions with optional filters: month, accountId, categoryId, creditCardId, type, startDate, endDate, paid.
|
|
76
|
+
|
|
77
|
+
#### Scenario: List all transactions
|
|
78
|
+
- **WHEN** the user requests transactions without filters
|
|
79
|
+
- **THEN** the system returns all transactions
|
|
80
|
+
|
|
81
|
+
#### Scenario: List transactions filtered by month
|
|
82
|
+
- **WHEN** the user provides `month` in YYYY-MM format
|
|
83
|
+
- **THEN** the system returns only transactions within that month
|
|
84
|
+
|
|
85
|
+
#### Scenario: List transactions filtered by date range
|
|
86
|
+
- **WHEN** the user provides `startDate` and `endDate`
|
|
87
|
+
- **THEN** the system returns transactions within that range (inclusive)
|
|
88
|
+
|
|
89
|
+
#### Scenario: List transactions filtered by payment status
|
|
90
|
+
- **WHEN** the user provides `paid` as true or false
|
|
91
|
+
- **THEN** the system returns only paid or unpaid transactions respectively
|
|
92
|
+
|
|
93
|
+
### Requirement: Get transaction by ID
|
|
94
|
+
The system SHALL return a specific transaction with its related data (category, credit card, account, subscription).
|
|
95
|
+
|
|
96
|
+
#### Scenario: Transaction found
|
|
97
|
+
- **WHEN** the user requests a transaction with a valid ID
|
|
98
|
+
- **THEN** the system returns the transaction with related entities
|
|
99
|
+
|
|
100
|
+
#### Scenario: Transaction not found
|
|
101
|
+
- **WHEN** the user requests a transaction with a non-existent ID
|
|
102
|
+
- **THEN** the system returns a 404 error
|
|
103
|
+
|
|
104
|
+
### Requirement: Direct transaction recurrence
|
|
105
|
+
The recurrence for direct transactions SHALL support only 3 frequencies: WEEKLY, MONTHLY, YEARLY.
|
|
106
|
+
|
|
107
|
+
#### Scenario: Valid recurrence frequencies
|
|
108
|
+
- **WHEN** the user provides a recurrence with WEEKLY, MONTHLY, or YEARLY
|
|
109
|
+
- **THEN** the request is accepted
|
|
110
|
+
|
|
111
|
+
#### Scenario: Invalid recurrence frequency
|
|
112
|
+
- **WHEN** the user provides BIWEEKLY, BIMONTHLY, QUARTERLY, SEMIANNUALLY, or ANNUALLY
|
|
113
|
+
- **THEN** the Zod schema rejects the input
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Transfers Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Transferências de saldo entre contas financeiras do próprio usuário. Uma transferência debita de uma conta de origem e credita em uma conta de destino.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- CRUD completo de transferências
|
|
9
|
+
- Filtros por conta, mês e intervalo de datas
|
|
10
|
+
|
|
11
|
+
O que está **fora do escopo**:
|
|
12
|
+
- Criação de contas (domínio: accounts)
|
|
13
|
+
- Transações de despesas/receitas (domínio: transactions)
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
### Requirement: Create transfer
|
|
18
|
+
The system SHALL allow creating a transfer between two accounts with source account ID, destination account ID, amount (minimum 0.01), and date (YYYY-MM-DD).
|
|
19
|
+
|
|
20
|
+
#### Scenario: Successful transfer creation
|
|
21
|
+
- **WHEN** the user provides `sourceAccountId`, `destinationAccountId`, `amount`, and `date`
|
|
22
|
+
- **THEN** the system creates the transfer and debits/credits both accounts accordingly
|
|
23
|
+
|
|
24
|
+
#### Scenario: Validation rejects zero or negative amount
|
|
25
|
+
- **WHEN** the user provides an `amount` less than 0.01
|
|
26
|
+
- **THEN** the Zod schema rejects the input
|
|
27
|
+
|
|
28
|
+
#### Scenario: Validation rejects invalid date format
|
|
29
|
+
- **WHEN** the user provides a `date` not matching YYYY-MM-DD
|
|
30
|
+
- **THEN** the Zod schema rejects the input
|
|
31
|
+
|
|
32
|
+
### Requirement: List transfers
|
|
33
|
+
The system SHALL return transfers with optional filters by account ID, month (YYYY-MM), start date, and end date.
|
|
34
|
+
|
|
35
|
+
#### Scenario: List all transfers
|
|
36
|
+
- **WHEN** the user requests transfers without filters
|
|
37
|
+
- **THEN** the system returns all transfers
|
|
38
|
+
|
|
39
|
+
#### Scenario: List transfers filtered by account
|
|
40
|
+
- **WHEN** the user provides `accountId`
|
|
41
|
+
- **THEN** the system returns only transfers involving that account
|
|
42
|
+
|
|
43
|
+
#### Scenario: List transfers filtered by month
|
|
44
|
+
- **WHEN** the user provides `month` in YYYY-MM format
|
|
45
|
+
- **THEN** the system returns only transfers within that month
|
|
46
|
+
|
|
47
|
+
#### Scenario: List transfers filtered by date range
|
|
48
|
+
- **WHEN** the user provides `startDate` and `endDate`
|
|
49
|
+
- **THEN** the system returns only transfers within that date range (inclusive)
|
|
50
|
+
|
|
51
|
+
### Requirement: Get transfer by ID
|
|
52
|
+
The system SHALL return a specific transfer by its ID.
|
|
53
|
+
|
|
54
|
+
#### Scenario: Transfer found
|
|
55
|
+
- **WHEN** the user requests a transfer with a valid ID
|
|
56
|
+
- **THEN** the system returns the transfer details
|
|
57
|
+
|
|
58
|
+
#### Scenario: Transfer not found
|
|
59
|
+
- **WHEN** the user requests a transfer with a non-existent ID
|
|
60
|
+
- **THEN** the system returns a 404 error
|
|
61
|
+
|
|
62
|
+
### Requirement: Update transfer
|
|
63
|
+
The system SHALL allow updating a transfer's source account, destination account, amount, and/or date.
|
|
64
|
+
|
|
65
|
+
#### Scenario: Successful update
|
|
66
|
+
- **WHEN** the user provides a valid transfer ID and one or more updateable fields
|
|
67
|
+
- **THEN** the system updates and returns the modified transfer
|
|
68
|
+
|
|
69
|
+
### Requirement: Delete transfer
|
|
70
|
+
The system SHALL allow deleting a transfer by its ID.
|
|
71
|
+
|
|
72
|
+
#### Scenario: Successful deletion
|
|
73
|
+
- **WHEN** the user deletes a transfer with a valid ID
|
|
74
|
+
- **THEN** the system confirms the deletion
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -6,6 +6,7 @@ const envSchema = z.object({
|
|
|
6
6
|
QUANTIX_API_KEY: z.string().min(1, "QUANTIX_API_KEY is required"),
|
|
7
7
|
MCPPORT: z.string().optional().default('3001'),
|
|
8
8
|
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
9
|
+
TRANSPORT: z.enum(['stdio', 'http']).default('stdio'),
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
const processEnv = {
|
|
@@ -13,6 +14,7 @@ const processEnv = {
|
|
|
13
14
|
QUANTIX_API_KEY: process.env.QUANTIX_API_KEY,
|
|
14
15
|
MCPPORT: process.env.MCPPORT,
|
|
15
16
|
NODE_ENV: process.env.NODE_ENV,
|
|
17
|
+
TRANSPORT: process.env.TRANSPORT,
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
// Parse and validate environment variables
|
|
@@ -32,5 +34,6 @@ export const config = parsedEnv.success ? parsedEnv.data : {
|
|
|
32
34
|
QUANTIX_API_URL: process.env.QUANTIX_API_URL || 'https://api.quantix.example.com',
|
|
33
35
|
QUANTIX_API_KEY: process.env.QUANTIX_API_KEY || 'your_api_key_here',
|
|
34
36
|
MCPPORT: process.env.MCPPORT || '3001',
|
|
35
|
-
NODE_ENV: (process.env.NODE_ENV as 'development' | 'production' | 'test') || 'development'
|
|
37
|
+
NODE_ENV: (process.env.NODE_ENV as 'development' | 'production' | 'test') || 'development',
|
|
38
|
+
TRANSPORT: (process.env.TRANSPORT as 'stdio' | 'http') || 'stdio',
|
|
36
39
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
4
|
-
import
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
import express, { type Request, type Response } from 'express';
|
|
6
6
|
import { config } from './config.js';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
9
7
|
import { registerCategoryTools } from './tools/categories.js';
|
|
10
8
|
import { registerCreditCardTools } from './tools/credit-cards.js';
|
|
11
9
|
import { registerTransactionTools } from './tools/transactions.js';
|
|
@@ -47,11 +45,43 @@ export function getServer() {
|
|
|
47
45
|
return mcpServer;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
async function
|
|
48
|
+
async function startStdio() {
|
|
51
49
|
const transport = new StdioServerTransport();
|
|
52
50
|
const mcpServer = getServer();
|
|
53
51
|
await mcpServer.connect(transport);
|
|
54
|
-
console.
|
|
52
|
+
console.error('Quantix MCP server running in stdio mode');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function startHttp() {
|
|
56
|
+
const app = express();
|
|
57
|
+
app.use(express.json());
|
|
58
|
+
|
|
59
|
+
const port = parseInt(config.MCPPORT, 10);
|
|
60
|
+
|
|
61
|
+
app.post('/mcp', async (req: Request, res: Response) => {
|
|
62
|
+
const transport = new StreamableHTTPServerTransport({});
|
|
63
|
+
const mcpServer = getServer();
|
|
64
|
+
// Cast needed: exactOptionalPropertyTypes causes onclose incompatibility with Transport interface
|
|
65
|
+
await mcpServer.connect(transport as never);
|
|
66
|
+
await transport.handleRequest(req, res, req.body);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
app.get('/health', (_req: Request, res: Response) => {
|
|
70
|
+
res.json({ status: 'ok', transport: 'http' });
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
app.listen(port, () => {
|
|
74
|
+
console.error(`Quantix MCP server running in HTTP mode on port ${port}`);
|
|
75
|
+
console.error(`Endpoint: http://0.0.0.0:${port}/mcp`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function main() {
|
|
80
|
+
if (config.TRANSPORT === 'http') {
|
|
81
|
+
await startHttp();
|
|
82
|
+
} else {
|
|
83
|
+
await startStdio();
|
|
84
|
+
}
|
|
55
85
|
}
|
|
56
86
|
|
|
57
87
|
main().catch(error => {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CreateTransactionInput,
|
|
5
|
+
GetTransactionsInput,
|
|
6
|
+
UpdateTransactionInput,
|
|
7
|
+
CreateCreditCardTransactionInput,
|
|
8
|
+
UpdateCreditCardTransactionInput
|
|
9
|
+
} from '../types/schemas.js';
|
|
4
10
|
import { apiClient } from '../services/apiClient.js';
|
|
5
11
|
import { handleToolError } from '../utils/toolHelpers.js';
|
|
6
12
|
|
|
@@ -9,7 +15,7 @@ export function registerTransactionTools(server: McpServer) {
|
|
|
9
15
|
'create_transaction',
|
|
10
16
|
{
|
|
11
17
|
title: 'Create Transaction',
|
|
12
|
-
description: 'Record a new income or expense (DEBIT
|
|
18
|
+
description: 'Record a new income or expense using direct payment methods (CASH, PIX, or DEBIT only). For credit card purchases, use create_credit_transaction instead.',
|
|
13
19
|
inputSchema: CreateTransactionInput
|
|
14
20
|
},
|
|
15
21
|
async (args) => {
|
|
@@ -77,7 +83,7 @@ export function registerTransactionTools(server: McpServer) {
|
|
|
77
83
|
'update_transaction',
|
|
78
84
|
{
|
|
79
85
|
title: 'Update Transaction',
|
|
80
|
-
description: 'Update a transaction',
|
|
86
|
+
description: 'Update a transaction using direct payment methods (CASH, PIX, or DEBIT only). For credit card transactions, use update_credit_transaction instead.',
|
|
81
87
|
inputSchema: UpdateTransactionInput
|
|
82
88
|
},
|
|
83
89
|
async ({ id, mode, ...data }) => {
|
|
@@ -153,4 +159,42 @@ export function registerTransactionTools(server: McpServer) {
|
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
);
|
|
162
|
+
|
|
163
|
+
server.registerTool(
|
|
164
|
+
'create_credit_transaction',
|
|
165
|
+
{
|
|
166
|
+
title: 'Create Credit Card Transaction',
|
|
167
|
+
description: 'Record a new credit card purchase. The due date is automatically calculated based on the purchase date and the card closing day. Use targetDueMonth to specify a particular billing month.',
|
|
168
|
+
inputSchema: CreateCreditCardTransactionInput
|
|
169
|
+
},
|
|
170
|
+
async (args) => {
|
|
171
|
+
try {
|
|
172
|
+
const transaction = await apiClient.post('/transactions/credit', args);
|
|
173
|
+
return {
|
|
174
|
+
content: [{ type: 'text', text: `Credit card transaction created: ${JSON.stringify(transaction, null, 2)}` }]
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return handleToolError(error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
server.registerTool(
|
|
183
|
+
'update_credit_transaction',
|
|
184
|
+
{
|
|
185
|
+
title: 'Update Credit Card Transaction',
|
|
186
|
+
description: 'Update a credit card transaction. If purchaseDate or targetDueMonth is changed, the due date is recalculated.',
|
|
187
|
+
inputSchema: UpdateCreditCardTransactionInput
|
|
188
|
+
},
|
|
189
|
+
async ({ id, ...data }) => {
|
|
190
|
+
try {
|
|
191
|
+
const transaction = await apiClient.patch(`/transactions/credit/${id}`, data);
|
|
192
|
+
return {
|
|
193
|
+
content: [{ type: 'text', text: `Credit card transaction updated: ${JSON.stringify(transaction, null, 2)}` }]
|
|
194
|
+
};
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return handleToolError(error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
);
|
|
156
200
|
}
|
package/src/types/schemas.ts
CHANGED
|
@@ -158,11 +158,9 @@ export const CreateTransactionInput = z.object({
|
|
|
158
158
|
amount: z.number().nonnegative().describe("Transaction amount (required — must ask the user if not provided, do not assume or default)"),
|
|
159
159
|
date: z.string().describe("ISO date string YYYY-MM-DD"),
|
|
160
160
|
categoryId: z.string().describe("ID da categoria associada (use a ferramenta get_categories para encontrar o ID correto)").optional(),
|
|
161
|
-
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "
|
|
162
|
-
|
|
163
|
-
accountId: z.string().describe("ID da conta bancária (obrigatório se o método de pagamento NÃO for CREDIT; use get_accounts para encontrar o ID)").optional(),
|
|
161
|
+
paymentMethod: z.enum(["CASH", "PIX", "DEBIT"]).describe("Método de pagamento direto (CASH, PIX ou DEBIT — para cartão de crédito, use create_credit_transaction)").optional(),
|
|
162
|
+
accountId: z.string().describe("ID da conta bancária (use get_accounts para encontrar o ID)").optional(),
|
|
164
163
|
installments: z.number().int().min(1).optional(),
|
|
165
|
-
targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
|
|
166
164
|
isPaid: z.boolean().describe("Indica se a transação já foi paga ou recebida (use este campo em vez de 'paid')").optional(),
|
|
167
165
|
recurrence: z.object({
|
|
168
166
|
frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]),
|
|
@@ -178,15 +176,12 @@ export const UpdateTransactionInput = z.object({
|
|
|
178
176
|
type: z.enum(["INCOME", "EXPENSE"]).optional(),
|
|
179
177
|
name: z.string().optional(),
|
|
180
178
|
amount: z.number().nonnegative().optional(),
|
|
181
|
-
date: z.string().describe("ISO date string YYYY-MM-DD").optional()
|
|
179
|
+
date: z.string().describe("ISO date string YYYY-MM-DD").optional(),
|
|
182
180
|
categoryId: z.string().describe("ID da categoria associada (use a ferramenta get_categories para encontrar o ID correto)").optional(),
|
|
183
|
-
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "
|
|
184
|
-
|
|
185
|
-
accountId: z.string().describe("ID da conta bancária (obrigatório se o método de pagamento NÃO for CREDIT; use get_accounts para encontrar o ID)").optional(),
|
|
181
|
+
paymentMethod: z.enum(["CASH", "PIX", "DEBIT"]).describe("Método de pagamento direto (CASH, PIX ou DEBIT — para cartão de crédito, use update_credit_transaction)").optional(),
|
|
182
|
+
accountId: z.string().describe("ID da conta bancária (use get_accounts para encontrar o ID)").optional(),
|
|
186
183
|
installments: z.number().int().min(1).optional(),
|
|
187
|
-
targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
|
|
188
184
|
isPaid: z.boolean().optional(),
|
|
189
|
-
purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Purchase date (CREDIT paymentMethod only), YYYY-MM-DD").optional(),
|
|
190
185
|
recurrence: z.object({
|
|
191
186
|
frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]).optional(),
|
|
192
187
|
interval: z.number().int().min(1).optional(),
|
|
@@ -195,6 +190,41 @@ export const UpdateTransactionInput = z.object({
|
|
|
195
190
|
}).optional()
|
|
196
191
|
});
|
|
197
192
|
|
|
193
|
+
// --- Credit Card Transaction Tool Inputs ---
|
|
194
|
+
|
|
195
|
+
export const CreditCardRecurrenceSchema = z.object({
|
|
196
|
+
frequency: z.enum(["WEEKLY", "BIWEEKLY", "MONTHLY", "BIMONTHLY", "QUARTERLY", "SEMIANNUALLY", "ANNUALLY"]),
|
|
197
|
+
interval: z.number().int().min(1).default(1).optional(),
|
|
198
|
+
startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Start date for recurrence (defaults to purchase date)").optional(),
|
|
199
|
+
endDate: z.string().optional(),
|
|
200
|
+
occurrences: z.number().int().min(2).describe("Number of occurrences (optional)").optional()
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export const CreateCreditCardTransactionInput = z.object({
|
|
204
|
+
name: z.string().describe("Name or description of the transaction"),
|
|
205
|
+
amount: z.number().min(0).describe("Total amount of the transaction (required — must ask the user if not provided, do not assume or default)"),
|
|
206
|
+
purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Purchase date in YYYY-MM-DD format").describe("Actual purchase date (the day you bought the item)"),
|
|
207
|
+
creditCardId: z.string().describe("ID of the credit card to charge (use get_credit_cards to find the ID)"),
|
|
208
|
+
categoryId: z.string().describe("ID of the associated category (use get_categories to find the ID)").optional(),
|
|
209
|
+
installments: z.number().int().min(1).describe("Number of installments (optional)").optional(),
|
|
210
|
+
targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/, "Target month in YYYY-MM format").describe("Target month for due date (optional)").optional(),
|
|
211
|
+
isPaid: z.boolean().describe("Whether the transaction has been paid").optional(),
|
|
212
|
+
recurrence: CreditCardRecurrenceSchema.optional()
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
export const UpdateCreditCardTransactionInput = z.object({
|
|
216
|
+
id: z.string().describe("Credit card transaction ID"),
|
|
217
|
+
name: z.string().describe("Name or description of the transaction").optional(),
|
|
218
|
+
amount: z.number().min(0).describe("Total amount of the transaction").optional(),
|
|
219
|
+
purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Purchase date in YYYY-MM-DD format").describe("Actual purchase date").optional(),
|
|
220
|
+
creditCardId: z.string().describe("ID of the credit card").optional(),
|
|
221
|
+
categoryId: z.string().describe("ID of the associated category").optional(),
|
|
222
|
+
installments: z.number().int().min(1).describe("Number of installments").optional(),
|
|
223
|
+
targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/, "Target month in YYYY-MM format").describe("Target month for due date").optional(),
|
|
224
|
+
isPaid: z.boolean().optional(),
|
|
225
|
+
recurrence: CreditCardRecurrenceSchema.optional()
|
|
226
|
+
});
|
|
227
|
+
|
|
198
228
|
export const CreateAccountInput = z.object({
|
|
199
229
|
name: z.string(),
|
|
200
230
|
type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]),
|
|
@@ -38,7 +38,7 @@ describe('Account Tools', () => {
|
|
|
38
38
|
|
|
39
39
|
it('should register all account tools', () => {
|
|
40
40
|
registerAccountTools(mockServer);
|
|
41
|
-
expect(mockServer.registerTool).toHaveBeenCalledTimes(
|
|
41
|
+
expect(mockServer.registerTool).toHaveBeenCalledTimes(6);
|
|
42
42
|
expect(registeredTools['create_account']).toBeDefined();
|
|
43
43
|
expect(registeredTools['get_accounts']).toBeDefined();
|
|
44
44
|
expect(registeredTools['get_account']).toBeDefined();
|
|
@@ -38,7 +38,7 @@ describe('Credit Card Tools', () => {
|
|
|
38
38
|
|
|
39
39
|
it('should register all credit card tools', () => {
|
|
40
40
|
registerCreditCardTools(mockServer);
|
|
41
|
-
expect(mockServer.registerTool).toHaveBeenCalledTimes(
|
|
41
|
+
expect(mockServer.registerTool).toHaveBeenCalledTimes(10);
|
|
42
42
|
expect(registeredTools['create_credit_card']).toBeDefined();
|
|
43
43
|
expect(registeredTools['get_credit_cards']).toBeDefined();
|
|
44
44
|
expect(registeredTools['get_statement']).toBeDefined();
|
|
@@ -38,7 +38,7 @@ describe('Transaction Tools', () => {
|
|
|
38
38
|
|
|
39
39
|
it('should register transaction tools', () => {
|
|
40
40
|
registerTransactionTools(mockServer);
|
|
41
|
-
expect(mockServer.registerTool).toHaveBeenCalledTimes(
|
|
41
|
+
expect(mockServer.registerTool).toHaveBeenCalledTimes(9); // create, get_all, get_one, update, pay, unpay, delete, create_credit, update_credit
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
describe('create_transaction', () => {
|