quantix-mcp 0.4.6 → 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/settings.local.json +2 -1
- package/.dockerignore +8 -0
- package/Dockerfile +30 -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/docker-compose.yml +9 -0
- package/openspec/README.md +33 -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/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/.openspec.yaml +0 -0
- /package/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/design.md +0 -0
- /package/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/proposal.md +0 -0
- /package/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/specs/credit-card-transactions/spec.md +0 -0
- /package/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/specs/transactions/spec.md +0 -0
- /package/openspec/changes/{separate-credit-card-transaction-tools → archive/2026-04-03-separate-credit-card-transaction-tools}/tasks.md +0 -0
package/.dockerignore
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Build stage
|
|
2
|
+
FROM node:22-alpine AS builder
|
|
3
|
+
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
COPY package*.json ./
|
|
7
|
+
RUN npm ci
|
|
8
|
+
|
|
9
|
+
COPY tsconfig.json ./
|
|
10
|
+
COPY src/ ./src/
|
|
11
|
+
|
|
12
|
+
RUN npm run build
|
|
13
|
+
|
|
14
|
+
# Production stage
|
|
15
|
+
FROM node:22-alpine AS runner
|
|
16
|
+
|
|
17
|
+
WORKDIR /app
|
|
18
|
+
|
|
19
|
+
COPY package*.json ./
|
|
20
|
+
RUN npm ci --omit=dev
|
|
21
|
+
|
|
22
|
+
COPY --from=builder /app/dist ./dist
|
|
23
|
+
|
|
24
|
+
ENV TRANSPORT=http
|
|
25
|
+
ENV MCPPORT=3001
|
|
26
|
+
ENV NODE_ENV=production
|
|
27
|
+
|
|
28
|
+
EXPOSE 3001
|
|
29
|
+
|
|
30
|
+
CMD ["node", "dist/index.js"]
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAgCvB,eAAO,MAAM,MAAM;;;;;;CAMlB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -5,12 +5,14 @@ const envSchema = z.object({
|
|
|
5
5
|
QUANTIX_API_KEY: z.string().min(1, "QUANTIX_API_KEY is required"),
|
|
6
6
|
MCPPORT: z.string().optional().default('3001'),
|
|
7
7
|
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
8
|
+
TRANSPORT: z.enum(['stdio', 'http']).default('stdio'),
|
|
8
9
|
});
|
|
9
10
|
const processEnv = {
|
|
10
11
|
QUANTIX_API_URL: process.env.QUANTIX_API_URL,
|
|
11
12
|
QUANTIX_API_KEY: process.env.QUANTIX_API_KEY,
|
|
12
13
|
MCPPORT: process.env.MCPPORT,
|
|
13
14
|
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
+
TRANSPORT: process.env.TRANSPORT,
|
|
14
16
|
};
|
|
15
17
|
// Parse and validate environment variables
|
|
16
18
|
const parsedEnv = envSchema.safeParse(processEnv);
|
|
@@ -26,6 +28,7 @@ export const config = parsedEnv.success ? parsedEnv.data : {
|
|
|
26
28
|
QUANTIX_API_URL: process.env.QUANTIX_API_URL || 'https://api.quantix.example.com',
|
|
27
29
|
QUANTIX_API_KEY: process.env.QUANTIX_API_KEY || 'your_api_key_here',
|
|
28
30
|
MCPPORT: process.env.MCPPORT || '3001',
|
|
29
|
-
NODE_ENV: process.env.NODE_ENV || 'development'
|
|
31
|
+
NODE_ENV: process.env.NODE_ENV || 'development',
|
|
32
|
+
TRANSPORT: process.env.TRANSPORT || 'stdio',
|
|
30
33
|
};
|
|
31
34
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,iCAAiC,CAAC;IACtE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACjE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,iCAAiC,CAAC;IACtE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACjE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAC9E,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;CACtD,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG;IACjB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;IAC5C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;IAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC9B,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;CACjC,CAAC;AAEF,2CAA2C;AAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAElD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5E,yEAAyE;IACzE,kFAAkF;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QAClC,8DAA8D;IAClE,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,iCAAiC;IACjF,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,mBAAmB;IACnE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM;IACtC,QAAQ,EAAG,OAAO,CAAC,GAAG,CAAC,QAAkD,IAAI,aAAa;IAC1F,SAAS,EAAG,OAAO,CAAC,GAAG,CAAC,SAA8B,IAAI,OAAO;CACpE,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAsBpE,wBAAgB,SAAS,cAsBxB"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +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 { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
5
|
import express, {} from 'express';
|
|
5
6
|
import { config } from './config.js';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
7
|
import { registerCategoryTools } from './tools/categories.js';
|
|
9
8
|
import { registerCreditCardTools } from './tools/credit-cards.js';
|
|
10
9
|
import { registerTransactionTools } from './tools/transactions.js';
|
|
@@ -39,11 +38,38 @@ export function getServer() {
|
|
|
39
38
|
registerSubscriptionTools(mcpServer);
|
|
40
39
|
return mcpServer;
|
|
41
40
|
}
|
|
42
|
-
async function
|
|
41
|
+
async function startStdio() {
|
|
43
42
|
const transport = new StdioServerTransport();
|
|
44
43
|
const mcpServer = getServer();
|
|
45
44
|
await mcpServer.connect(transport);
|
|
46
|
-
console.
|
|
45
|
+
console.error('Quantix MCP server running in stdio mode');
|
|
46
|
+
}
|
|
47
|
+
async function startHttp() {
|
|
48
|
+
const app = express();
|
|
49
|
+
app.use(express.json());
|
|
50
|
+
const port = parseInt(config.MCPPORT, 10);
|
|
51
|
+
app.post('/mcp', async (req, res) => {
|
|
52
|
+
const transport = new StreamableHTTPServerTransport({});
|
|
53
|
+
const mcpServer = getServer();
|
|
54
|
+
// Cast needed: exactOptionalPropertyTypes causes onclose incompatibility with Transport interface
|
|
55
|
+
await mcpServer.connect(transport);
|
|
56
|
+
await transport.handleRequest(req, res, req.body);
|
|
57
|
+
});
|
|
58
|
+
app.get('/health', (_req, res) => {
|
|
59
|
+
res.json({ status: 'ok', transport: 'http' });
|
|
60
|
+
});
|
|
61
|
+
app.listen(port, () => {
|
|
62
|
+
console.error(`Quantix MCP server running in HTTP mode on port ${port}`);
|
|
63
|
+
console.error(`Endpoint: http://0.0.0.0:${port}/mcp`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function main() {
|
|
67
|
+
if (config.TRANSPORT === 'http') {
|
|
68
|
+
await startHttp();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
await startStdio();
|
|
72
|
+
}
|
|
47
73
|
}
|
|
48
74
|
main().catch(error => {
|
|
49
75
|
console.error('Server error:', error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# OpenSpec — Quantix MCP Server
|
|
2
|
+
|
|
3
|
+
Especificações comportamentais do sistema, organizadas por domínio.
|
|
4
|
+
|
|
5
|
+
## Estrutura
|
|
6
|
+
|
|
7
|
+
### specs/
|
|
8
|
+
Source of truth — como o sistema atualmente se comporta.
|
|
9
|
+
|
|
10
|
+
| Domínio | Descrição | # Requirements |
|
|
11
|
+
|---------|-----------|:-:|
|
|
12
|
+
| [accounts](specs/accounts/spec.md) | Contas financeiras (CRUD + saldo) | 6 |
|
|
13
|
+
| [categories](specs/categories/spec.md) | Categorias de classificação (CRUD) | 5 |
|
|
14
|
+
| [credit-cards](specs/credit-cards/spec.md) | Cartões de crédito (CRUD + extratos + antecipação) | 10 |
|
|
15
|
+
| [credit-card-transactions](specs/credit-card-transactions/spec.md) | Transações de cartão de crédito (criar/atualizar) | 3 |
|
|
16
|
+
| [data](specs/data/spec.md) | Exportação e importação de backup | 3 |
|
|
17
|
+
| [settings](specs/settings/spec.md) | Configurações globais (usuário, idioma, moeda) | 3 |
|
|
18
|
+
| [subscriptions](specs/subscriptions/spec.md) | Assinaturas e pagamentos recorrentes | 8 |
|
|
19
|
+
| [summary](specs/summary/spec.md) | Resumo financeiro consolidado | 4 |
|
|
20
|
+
| [transactions](specs/transactions/spec.md) | Transações diretas (CASH, PIX, DEBIT) | 8 |
|
|
21
|
+
| [transfers](specs/transfers/spec.md) | Transferências entre contas | 5 |
|
|
22
|
+
|
|
23
|
+
**Total: 10 domínios, ~55 requirements**
|
|
24
|
+
|
|
25
|
+
### changes/
|
|
26
|
+
Modificações propostas. Cada change vive em sua própria pasta até ser mergeada.
|
|
27
|
+
|
|
28
|
+
## Convenções
|
|
29
|
+
|
|
30
|
+
- Requisitos usam keywords RFC 2119 (SHALL, MUST, SHOULD, MAY)
|
|
31
|
+
- Cenários seguem formato **WHEN**/**THEN**
|
|
32
|
+
- Specs descrevem **comportamento**, não implementação
|
|
33
|
+
- Delta specs vivem em `changes/<name>/specs/` e são syncadas para `specs/` ao arquivar
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Accounts Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de contas financeiras (contas bancárias, carteiras, poupanças, investimentos). Cada conta possui um saldo inicial e um saldo calculado baseado nas transações.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- CRUD completo de contas financeiras
|
|
9
|
+
- Consulta de saldo individual por conta
|
|
10
|
+
- Tipos de conta: BANK_ACCOUNT, WALLET, SAVINGS_ACCOUNT, INVESTMENT_ACCOUNT, OTHER
|
|
11
|
+
|
|
12
|
+
O que está **fora do escopo**:
|
|
13
|
+
- Transferências entre contas (domínio: transfers)
|
|
14
|
+
- Cálculo de saldo agregado (domínio: summary)
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
### Requirement: Create account
|
|
19
|
+
The system SHALL allow creating a new financial account with a name, type, and optional initial balance. The system SHALL assign a unique ID and set `currentBalance` equal to `initialBalance` upon creation.
|
|
20
|
+
|
|
21
|
+
#### Scenario: Create account with initial balance
|
|
22
|
+
- **WHEN** the user provides `name`, `type`, and `initialBalance`
|
|
23
|
+
- **THEN** the system creates the account with `currentBalance` equal to `initialBalance` and returns the full account object
|
|
24
|
+
|
|
25
|
+
#### Scenario: Create account without initial balance
|
|
26
|
+
- **WHEN** the user provides `name` and `type` but no `initialBalance`
|
|
27
|
+
- **THEN** the system creates the account with `initialBalance` defaulting to 0
|
|
28
|
+
|
|
29
|
+
#### Scenario: Validation rejects invalid type
|
|
30
|
+
- **WHEN** the user provides a `type` not in the allowed enum
|
|
31
|
+
- **THEN** the input is rejected by the Zod schema
|
|
32
|
+
|
|
33
|
+
### Requirement: List all accounts
|
|
34
|
+
The system SHALL return all financial accounts with their current balances.
|
|
35
|
+
|
|
36
|
+
#### Scenario: List accounts when some exist
|
|
37
|
+
- **WHEN** the user requests the account list
|
|
38
|
+
- **THEN** the system returns an array of all accounts with their `currentBalance`
|
|
39
|
+
|
|
40
|
+
#### Scenario: List accounts when none exist
|
|
41
|
+
- **WHEN** no accounts have been created
|
|
42
|
+
- **THEN** the system returns an empty array
|
|
43
|
+
|
|
44
|
+
### Requirement: Get account by ID
|
|
45
|
+
The system SHALL return the details of a specific account by its ID.
|
|
46
|
+
|
|
47
|
+
#### Scenario: Account found
|
|
48
|
+
- **WHEN** the user requests an account with a valid ID
|
|
49
|
+
- **THEN** the system returns the account details
|
|
50
|
+
|
|
51
|
+
#### Scenario: Account not found
|
|
52
|
+
- **WHEN** the user requests an account with an ID that does not exist
|
|
53
|
+
- **THEN** the system returns a 404 error
|
|
54
|
+
|
|
55
|
+
### Requirement: Update account
|
|
56
|
+
The system SHALL allow updating an existing account's name, type, and initial balance.
|
|
57
|
+
|
|
58
|
+
#### Scenario: Successful update
|
|
59
|
+
- **WHEN** the user provides a valid account ID and one or more updateable fields
|
|
60
|
+
- **THEN** the system updates the account and returns the updated object
|
|
61
|
+
|
|
62
|
+
#### Scenario: Account not found on update
|
|
63
|
+
- **WHEN** the user attempts to update a non-existent account
|
|
64
|
+
- **THEN** the system returns a 404 error
|
|
65
|
+
|
|
66
|
+
### Requirement: Delete account
|
|
67
|
+
The system SHALL allow deleting an account by its ID.
|
|
68
|
+
|
|
69
|
+
#### Scenario: Successful deletion
|
|
70
|
+
- **WHEN** the user deletes an account with a valid ID
|
|
71
|
+
- **THEN** the system confirms the deletion
|
|
72
|
+
|
|
73
|
+
#### Scenario: Account not found on deletion
|
|
74
|
+
- **WHEN** the user attempts to delete a non-existent account
|
|
75
|
+
- **THEN** the system returns a 404 error
|
|
76
|
+
|
|
77
|
+
### Requirement: Get account balance
|
|
78
|
+
The system SHALL return the current balance for a specific account.
|
|
79
|
+
|
|
80
|
+
#### Scenario: Balance retrieved successfully
|
|
81
|
+
- **WHEN** the user requests the balance of an existing account
|
|
82
|
+
- **THEN** the system returns the `accountId`, `currentBalance`, and `calculatedAt` timestamp
|
|
83
|
+
|
|
84
|
+
#### Scenario: Account not found for balance
|
|
85
|
+
- **WHEN** the user requests the balance of a non-existent account
|
|
86
|
+
- **THEN** the system returns a 404 error
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Categories Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de categorias de classificação para transações financeiras. Cada categoria é do tipo INCOME (receita) ou EXPENSE (despesa) e pode ter uma cor associada.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- CRUD completo de categorias
|
|
9
|
+
- Validação de tipo (INCOME/EXPENSE) e cor hexadecimal
|
|
10
|
+
|
|
11
|
+
O que está **fora do escopo**:
|
|
12
|
+
- Atribuição de categorias a transações (domínio: transactions)
|
|
13
|
+
- Hierarquia ou subcategorias
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
### Requirement: Create category
|
|
18
|
+
The system SHALL allow creating a new category with a name, type (INCOME or EXPENSE), and optional hex color.
|
|
19
|
+
|
|
20
|
+
#### Scenario: Create category with color
|
|
21
|
+
- **WHEN** the user provides `name`, `type`, and a valid hex color (e.g., `#FF5733`)
|
|
22
|
+
- **THEN** the system creates the category and returns it with the assigned ID
|
|
23
|
+
|
|
24
|
+
#### Scenario: Create category without color
|
|
25
|
+
- **WHEN** the user provides `name` and `type` but no color
|
|
26
|
+
- **THEN** the system creates the category with `color` as undefined/null
|
|
27
|
+
|
|
28
|
+
#### Scenario: Validation rejects invalid color format
|
|
29
|
+
- **WHEN** the user provides a color that is not a valid 6-digit hex
|
|
30
|
+
- **THEN** the Zod schema rejects the input
|
|
31
|
+
|
|
32
|
+
#### Scenario: Validation rejects invalid type
|
|
33
|
+
- **WHEN** the user provides a `type` not in INCOME/EXPENSE
|
|
34
|
+
- **THEN** the Zod schema rejects the input
|
|
35
|
+
|
|
36
|
+
### Requirement: List all categories
|
|
37
|
+
The system SHALL return all categories.
|
|
38
|
+
|
|
39
|
+
#### Scenario: Categories exist
|
|
40
|
+
- **WHEN** the user requests the category list
|
|
41
|
+
- **THEN** the system returns an array of all categories
|
|
42
|
+
|
|
43
|
+
#### Scenario: No categories exist
|
|
44
|
+
- **WHEN** no categories have been created
|
|
45
|
+
- **THEN** the system returns an empty array
|
|
46
|
+
|
|
47
|
+
### Requirement: Get category by ID
|
|
48
|
+
The system SHALL return a specific category by its ID.
|
|
49
|
+
|
|
50
|
+
#### Scenario: Category found
|
|
51
|
+
- **WHEN** the user requests a category with a valid ID
|
|
52
|
+
- **THEN** the system returns the category details
|
|
53
|
+
|
|
54
|
+
#### Scenario: Category not found
|
|
55
|
+
- **WHEN** the user requests a category with a non-existent ID
|
|
56
|
+
- **THEN** the system returns a 404 error
|
|
57
|
+
|
|
58
|
+
### Requirement: Update category
|
|
59
|
+
The system SHALL allow updating a category's name and/or color.
|
|
60
|
+
|
|
61
|
+
#### Scenario: Successful update
|
|
62
|
+
- **WHEN** the user provides a valid category ID and one or more fields to update
|
|
63
|
+
- **THEN** the system updates and returns the modified category
|
|
64
|
+
|
|
65
|
+
#### Scenario: Category not found on update
|
|
66
|
+
- **WHEN** the user attempts to update a non-existent category
|
|
67
|
+
- **THEN** the system returns a 404 error
|
|
68
|
+
|
|
69
|
+
### Requirement: Delete category
|
|
70
|
+
The system SHALL allow deleting a category by its ID.
|
|
71
|
+
|
|
72
|
+
#### Scenario: Successful deletion
|
|
73
|
+
- **WHEN** the user deletes a category with a valid ID
|
|
74
|
+
- **THEN** the system confirms the deletion
|
|
75
|
+
|
|
76
|
+
#### Scenario: Category not found on deletion
|
|
77
|
+
- **WHEN** the user attempts to delete a non-existent category
|
|
78
|
+
- **THEN** the system returns a 404 error
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Credit Card Transactions Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de transações de cartão de crédito, incluindo compras à vista e parceladas, com cálculo automático de data de vencimento baseado no dia de fechamento do cartão.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- Criação de transações de cartão via `POST /transactions/credit`
|
|
9
|
+
- Atualização de transações de cartão via `PATCH /transactions/credit/:id`
|
|
10
|
+
- Cálculo automático de data de vencimento
|
|
11
|
+
- Parcelamento com datas de vencimento distribuídas
|
|
12
|
+
- Recorrência com 7 frequências (WEEKLY, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SEMIANNUALLY, ANNUALLY)
|
|
13
|
+
|
|
14
|
+
O que está **fora do escopo**:
|
|
15
|
+
- Gestão de cartões de crédito em si (domínio: credit-cards)
|
|
16
|
+
- Extratos e pagamento de fatura (domínio: credit-cards)
|
|
17
|
+
- Transações diretas CASH/PIX/DEBIT (domínio: transactions)
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
### Requirement: Create credit card transaction
|
|
22
|
+
The system SHALL allow creating a credit card transaction via `POST /transactions/credit` with name, amount, purchaseDate, creditCardId, and optional fields (categoryId, installments, targetDueMonth, isPaid, recurrence).
|
|
23
|
+
|
|
24
|
+
#### Scenario: Successful creation
|
|
25
|
+
- **WHEN** the user provides `name`, `amount`, `purchaseDate`, and `creditCardId`
|
|
26
|
+
- **THEN** the system creates the transaction and the due date is calculated from the card's closing day
|
|
27
|
+
|
|
28
|
+
#### Scenario: Creation with installments
|
|
29
|
+
- **WHEN** the user provides `installments` > 1
|
|
30
|
+
- **THEN** the transaction is split into installments with due dates calculated from the card closing day
|
|
31
|
+
|
|
32
|
+
#### Scenario: Creation with target due month
|
|
33
|
+
- **WHEN** the user provides `targetDueMonth` in YYYY-MM format
|
|
34
|
+
- **THEN** the first installment's due date is set to the target month
|
|
35
|
+
|
|
36
|
+
#### Scenario: Creation with recurrence
|
|
37
|
+
- **WHEN** the user provides `recurrence` with one of the 7 supported frequencies (WEEKLY, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SEMIANNUALLY, ANNUALLY)
|
|
38
|
+
- **THEN** the system includes the recurrence object in the request body
|
|
39
|
+
|
|
40
|
+
### Requirement: Update credit card transaction
|
|
41
|
+
The system SHALL allow updating a credit card transaction via `PATCH /transactions/credit/:id`. If `purchaseDate` or `targetDueMonth` is changed, the due date SHALL be recalculated.
|
|
42
|
+
|
|
43
|
+
#### Scenario: Successful update
|
|
44
|
+
- **WHEN** the user provides a valid transaction ID and one or more updateable fields
|
|
45
|
+
- **THEN** the system updates and returns the modified transaction
|
|
46
|
+
|
|
47
|
+
#### Scenario: Recalculation of due date
|
|
48
|
+
- **WHEN** the user changes `purchaseDate` or `targetDueMonth`
|
|
49
|
+
- **THEN** the due date is recalculated by the API
|
|
50
|
+
|
|
51
|
+
#### Scenario: Update with recurrence
|
|
52
|
+
- **WHEN** the user modifies the `recurrence` field
|
|
53
|
+
- **THEN** the recurrence object is updated with one of the 7 supported frequencies
|
|
54
|
+
|
|
55
|
+
### Requirement: Credit card transaction input schema
|
|
56
|
+
The input schema for credit card transaction tools SHALL include: `name` (required), `amount` (required, min 0), `purchaseDate` (required, YYYY-MM-DD), `creditCardId` (required), `categoryId` (optional), `installments` (optional, min 1), `targetDueMonth` (optional, YYYY-MM), `isPaid` (optional, default false), `recurrence` (optional, CreditCardRecurrenceDto with 7 frequencies).
|
|
57
|
+
|
|
58
|
+
#### Scenario: Validation rejects missing required fields
|
|
59
|
+
- **WHEN** any of `name`, `amount`, `purchaseDate`, or `creditCardId` is missing
|
|
60
|
+
- **THEN** the MCP SDK rejects the input with a validation error
|
|
61
|
+
|
|
62
|
+
#### Scenario: Validation rejects invalid frequency
|
|
63
|
+
- **WHEN** the user provides a recurrence frequency not in the 7 supported values
|
|
64
|
+
- **THEN** the input is rejected by the Zod schema
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Credit Cards Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de cartões de crédito, incluindo CRUD, consultas de extrato (statement), pagamento de fatura, reabertura de fatura e antecipação de parcelas.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- CRUD de cartões de crédito (nome, bandeira, limite, dia de fechamento, dia de vencimento)
|
|
9
|
+
- Consulta de extrato mensal (`/credit-cards/{id}/statement`)
|
|
10
|
+
- Pagamento de fatura (`pay-statement`)
|
|
11
|
+
- Reabertura de fatura (`reopen-statement`)
|
|
12
|
+
- Status de pagamento da fatura (`statement-status`)
|
|
13
|
+
- Antecipação de parcelas (`anticipations`)
|
|
14
|
+
|
|
15
|
+
O que está **fora do escopo**:
|
|
16
|
+
- Transações de cartão de crédito (domínio: credit-card-transactions)
|
|
17
|
+
- Criação de parcelamento manual (domínio: credit-card-transactions)
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
### Requirement: Create credit card
|
|
22
|
+
The system SHALL allow creating a new credit card with name, optional brand, limit amount, closing day (1-31), and due day (1-31).
|
|
23
|
+
|
|
24
|
+
#### Scenario: Create credit card with all fields
|
|
25
|
+
- **WHEN** the user provides `name`, `brand`, `limitAmount`, `closingDay`, and `dueDay`
|
|
26
|
+
- **THEN** the system creates the card with an `availableLimit` equal to `limitAmount`
|
|
27
|
+
|
|
28
|
+
#### Scenario: Validation rejects closing day outside range
|
|
29
|
+
- **WHEN** the user provides a `closingDay` less than 1 or greater than 31
|
|
30
|
+
- **THEN** the Zod schema rejects the input
|
|
31
|
+
|
|
32
|
+
#### Scenario: Validation rejects due day outside range
|
|
33
|
+
- **WHEN** the user provides a `dueDay` less than 1 or greater than 31
|
|
34
|
+
- **THEN** the Zod schema rejects the input
|
|
35
|
+
|
|
36
|
+
### Requirement: List all credit cards
|
|
37
|
+
The system SHALL return all credit cards with their available limits.
|
|
38
|
+
|
|
39
|
+
#### Scenario: Cards exist
|
|
40
|
+
- **WHEN** the user requests the credit card list
|
|
41
|
+
- **THEN** the system returns an array of all cards with `availableLimit`
|
|
42
|
+
|
|
43
|
+
### Requirement: Get credit card by ID
|
|
44
|
+
The system SHALL return a specific credit card by its ID.
|
|
45
|
+
|
|
46
|
+
#### Scenario: Card found
|
|
47
|
+
- **WHEN** the user requests a card with a valid ID
|
|
48
|
+
- **THEN** the system returns the card details including `availableLimit`
|
|
49
|
+
|
|
50
|
+
#### Scenario: Card not found
|
|
51
|
+
- **WHEN** the user requests a card with a non-existent ID
|
|
52
|
+
- **THEN** the system returns a 404 error
|
|
53
|
+
|
|
54
|
+
### Requirement: Update credit card
|
|
55
|
+
The system SHALL allow updating a credit card's name, brand, limit, closing day, and/or due day.
|
|
56
|
+
|
|
57
|
+
#### Scenario: Successful update
|
|
58
|
+
- **WHEN** the user provides a valid card ID and one or more updateable fields
|
|
59
|
+
- **THEN** the system updates and returns the modified card
|
|
60
|
+
|
|
61
|
+
### Requirement: Delete credit card
|
|
62
|
+
The system SHALL allow deleting a credit card by its ID.
|
|
63
|
+
|
|
64
|
+
#### Scenario: Successful deletion
|
|
65
|
+
- **WHEN** the user deletes a card with a valid ID
|
|
66
|
+
- **THEN** the system confirms the deletion
|
|
67
|
+
|
|
68
|
+
### Requirement: Get statement
|
|
69
|
+
The system SHALL return the credit card statement for a specific month, including all transactions, total amount, and available limit.
|
|
70
|
+
|
|
71
|
+
#### Scenario: Statement retrieved
|
|
72
|
+
- **WHEN** the user provides a valid card ID and a month in YYYY-MM format
|
|
73
|
+
- **THEN** the system returns the statement with transactions, total, and available limit
|
|
74
|
+
|
|
75
|
+
#### Scenario: Card not found for statement
|
|
76
|
+
- **WHEN** the user requests a statement for a non-existent card
|
|
77
|
+
- **THEN** the system returns a 404 error
|
|
78
|
+
|
|
79
|
+
### Requirement: Pay statement
|
|
80
|
+
The system SHALL mark all transactions in a credit card statement as paid, debiting from a specified payment account.
|
|
81
|
+
|
|
82
|
+
#### Scenario: Statement paid successfully
|
|
83
|
+
- **WHEN** the user provides `cardId`, `month`, and `paymentAccountId`
|
|
84
|
+
- **THEN** all transactions in the statement are marked as paid and the system confirms the payment
|
|
85
|
+
|
|
86
|
+
### Requirement: Reopen statement
|
|
87
|
+
The system SHALL reopen a credit card statement by marking all transactions as unpaid.
|
|
88
|
+
|
|
89
|
+
#### Scenario: Statement reopened
|
|
90
|
+
- **WHEN** the user provides `cardId` and `month`
|
|
91
|
+
- **THEN** all transactions in the statement are marked as unpaid
|
|
92
|
+
|
|
93
|
+
### Requirement: Get statement status
|
|
94
|
+
The system SHALL return the payment status of a credit card statement for a specific month.
|
|
95
|
+
|
|
96
|
+
#### Scenario: Status retrieved
|
|
97
|
+
- **WHEN** the user provides `cardId` and `month`
|
|
98
|
+
- **THEN** the system returns the `isPaid` status for that month
|
|
99
|
+
|
|
100
|
+
### Requirement: Create anticipation
|
|
101
|
+
The system SHALL allow creating a credit card anticipation (advance payment toward a future statement). The system SHALL create a linked pair: an INCOME transaction on the credit card side and an EXPENSE transaction on the account side.
|
|
102
|
+
|
|
103
|
+
#### Scenario: Anticipation created
|
|
104
|
+
- **WHEN** the user provides `cardId`, `name`, `amount`, `purchaseDate`, `targetDueMonth`, `accountId`, and optional `categoryId`
|
|
105
|
+
- **THEN** the system creates the linked INCOME/EXPENSE transaction pair and returns the result
|
|
106
|
+
|
|
107
|
+
#### Scenario: Validation rejects amount below minimum
|
|
108
|
+
- **WHEN** the user provides an `amount` less than 0.01
|
|
109
|
+
- **THEN** the Zod schema rejects the input
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Data Import/Export Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Backup e restauração de todos os dados do usuário (configurações, categorias, contas, cartões de crédito, regras de recorrência, transações) via exportação e importação JSON.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- Exportação completa de todos os dados (`GET /export`)
|
|
9
|
+
- Importação em modo `reset` (limpa dados existentes) ou `increment` (adiciona sem duplicar)
|
|
10
|
+
- Validação de formato e versão do export
|
|
11
|
+
|
|
12
|
+
O que está **fora do escopo**:
|
|
13
|
+
- Exportação parcial por domínio ou data
|
|
14
|
+
- Migração entre versões de formato de export
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
### Requirement: Export all data
|
|
19
|
+
The system SHALL return all user data as a complete backup in JSON format, including settings, categories, accounts, credit cards, recurrence rules, and transactions.
|
|
20
|
+
|
|
21
|
+
#### Scenario: Successful export
|
|
22
|
+
- **WHEN** the user requests an export
|
|
23
|
+
- **THEN** the system returns a JSON object with `version`, `exportedAt`, and a `data` object containing all domains
|
|
24
|
+
|
|
25
|
+
#### Scenario: Export includes version metadata
|
|
26
|
+
- **WHEN** the user receives the export
|
|
27
|
+
- **THEN** the response includes `version` (e.g., "1.0") and `exportedAt` (ISO timestamp)
|
|
28
|
+
|
|
29
|
+
### Requirement: Import data in reset mode
|
|
30
|
+
The system SHALL allow importing a previously exported backup in `reset` mode, which clears all existing data before importing.
|
|
31
|
+
|
|
32
|
+
#### Scenario: Reset import clears and replaces data
|
|
33
|
+
- **WHEN** the user imports with `mode: "reset"` and valid export data
|
|
34
|
+
- **THEN** the system clears existing records and imports all data from the backup
|
|
35
|
+
|
|
36
|
+
#### Scenario: Validation rejects wrong version
|
|
37
|
+
- **WHEN** the user provides a `version` that does not match "1.0"
|
|
38
|
+
- **THEN** the input is rejected
|
|
39
|
+
|
|
40
|
+
### Requirement: Import data in increment mode
|
|
41
|
+
The system SHALL allow importing a backup in `increment` mode, which adds new records and skips any IDs that already exist.
|
|
42
|
+
|
|
43
|
+
#### Scenario: Increment import skips duplicates
|
|
44
|
+
- **WHEN** the user imports with `mode: "increment"` and the backup contains IDs that already exist
|
|
45
|
+
- **THEN** the system skips existing IDs and only imports new records
|
|
46
|
+
|
|
47
|
+
#### Scenario: Increment import adds new records
|
|
48
|
+
- **WHEN** the user imports with `mode: "increment"` and the backup contains new IDs
|
|
49
|
+
- **THEN** the system adds all new records to the existing data
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Settings Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Configurações globais do sistema, incluindo nome do usuário, idioma e moeda padrão. Existe apenas um registro de configurações por usuário.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- Criação (apenas se não existir), leitura e atualização de configurações
|
|
9
|
+
- Validação de idioma (pt-BR, en-US) e moeda (BRL, USD, EUR, GBP, JPY, CAD, AUD, CHF)
|
|
10
|
+
|
|
11
|
+
O que está **fora do escopo**:
|
|
12
|
+
- Preferências por feature ou módulo
|
|
13
|
+
- Configurações de notificação ou autenticação
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
### Requirement: Create settings
|
|
18
|
+
The system SHALL allow creating global settings with user name, language, and currency. Creation SHALL fail if settings already exist.
|
|
19
|
+
|
|
20
|
+
#### Scenario: Settings created successfully
|
|
21
|
+
- **WHEN** the user provides `userName`, `language` (pt-BR or en-US), and `currency` (e.g., BRL)
|
|
22
|
+
- **THEN** the system creates the settings with `createdAt` and returns them
|
|
23
|
+
|
|
24
|
+
#### Scenario: Validation rejects invalid language
|
|
25
|
+
- **WHEN** the user provides a `language` not in [pt-BR, en-US]
|
|
26
|
+
- **THEN** the Zod schema rejects the input
|
|
27
|
+
|
|
28
|
+
#### Scenario: Validation rejects invalid currency
|
|
29
|
+
- **WHEN** the user provides a `currency` not in [BRL, USD, EUR, GBP, JPY, CAD, AUD, CHF]
|
|
30
|
+
- **THEN** the Zod schema rejects the input
|
|
31
|
+
|
|
32
|
+
### Requirement: Get settings
|
|
33
|
+
The system SHALL return the current global settings.
|
|
34
|
+
|
|
35
|
+
#### Scenario: Settings exist
|
|
36
|
+
- **WHEN** the user requests the settings
|
|
37
|
+
- **THEN** the system returns the settings object
|
|
38
|
+
|
|
39
|
+
#### Scenario: Settings do not exist
|
|
40
|
+
- **WHEN** no settings have been created
|
|
41
|
+
- **THEN** the system returns an empty or null response (or 404)
|
|
42
|
+
|
|
43
|
+
### Requirement: Update settings
|
|
44
|
+
The system SHALL allow updating existing settings fields (userName, language, currency). The update SHALL use PUT (full replace).
|
|
45
|
+
|
|
46
|
+
#### Scenario: Successful update
|
|
47
|
+
- **WHEN** the user provides one or more settings fields to update
|
|
48
|
+
- **THEN** the system updates the settings and returns the modified object with updated `updatedAt` timestamp
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Subscriptions Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Gerenciamento de assinaturas e pagamentos recorrentes vinculados a cartões de crédito (ex: Netflix, Spotify). Cada assinatura gera transações automáticas no cartão no dia de faturamento configurado.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- CRUD de assinaturas (nome, valor, dia de faturamento, cartão, categoria)
|
|
9
|
+
- Ativação/desativação (soft delete) e reativação
|
|
10
|
+
- Exclusão permanente (hard delete)
|
|
11
|
+
- Listagem de assinaturas ativas
|
|
12
|
+
|
|
13
|
+
O que está **fora do escopo**:
|
|
14
|
+
- Geração automática de transações (comportamento do backend da API)
|
|
15
|
+
- Transações de cartão avulsas (domínio: credit-card-transactions)
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
### Requirement: Create subscription
|
|
20
|
+
The system SHALL allow creating a new subscription with a name, amount, billing day (1-31), credit card ID, and optional category ID.
|
|
21
|
+
|
|
22
|
+
#### Scenario: Create subscription with all fields
|
|
23
|
+
- **WHEN** the user provides `name`, `amount`, `billingDay`, `creditCardId`, and `categoryId`
|
|
24
|
+
- **THEN** the system creates the subscription as active and returns it with assigned ID
|
|
25
|
+
|
|
26
|
+
#### Scenario: Validation rejects billing day outside range
|
|
27
|
+
- **WHEN** the user provides a `billingDay` less than 1 or greater than 31
|
|
28
|
+
- **THEN** the Zod schema rejects the input
|
|
29
|
+
|
|
30
|
+
### Requirement: List all subscriptions
|
|
31
|
+
The system SHALL return all subscriptions regardless of active status.
|
|
32
|
+
|
|
33
|
+
#### Scenario: Subscriptions exist
|
|
34
|
+
- **WHEN** the user requests the subscription list
|
|
35
|
+
- **THEN** the system returns an array of all subscriptions
|
|
36
|
+
|
|
37
|
+
### Requirement: List active subscriptions
|
|
38
|
+
The system SHALL return only active subscriptions.
|
|
39
|
+
|
|
40
|
+
#### Scenario: Active subscriptions exist
|
|
41
|
+
- **WHEN** the user requests active subscriptions
|
|
42
|
+
- **THEN** the system returns only subscriptions where `active` is true
|
|
43
|
+
|
|
44
|
+
### Requirement: Get subscription by ID
|
|
45
|
+
The system SHALL return a specific subscription by its ID.
|
|
46
|
+
|
|
47
|
+
#### Scenario: Subscription found
|
|
48
|
+
- **WHEN** the user requests a subscription with a valid ID
|
|
49
|
+
- **THEN** the system returns the subscription details
|
|
50
|
+
|
|
51
|
+
#### Scenario: Subscription not found
|
|
52
|
+
- **WHEN** the user requests a subscription with a non-existent ID
|
|
53
|
+
- **THEN** the system returns a 404 error
|
|
54
|
+
|
|
55
|
+
### Requirement: Update subscription
|
|
56
|
+
The system SHALL allow updating a subscription's name, amount, billing day, credit card ID, category ID, and/or active status.
|
|
57
|
+
|
|
58
|
+
#### Scenario: Successful update
|
|
59
|
+
- **WHEN** the user provides a valid subscription ID and one or more updateable fields
|
|
60
|
+
- **THEN** the system updates and returns the modified subscription
|
|
61
|
+
|
|
62
|
+
### Requirement: Deactivate subscription
|
|
63
|
+
The system SHALL allow deactivating (soft delete) a subscription by its ID.
|
|
64
|
+
|
|
65
|
+
#### Scenario: Successful deactivation
|
|
66
|
+
- **WHEN** the user deactivates a subscription with a valid ID
|
|
67
|
+
- **THEN** the subscription's `active` field is set to false
|
|
68
|
+
|
|
69
|
+
#### Scenario: Subscription not found on deactivation
|
|
70
|
+
- **WHEN** the user attempts to deactivate a non-existent subscription
|
|
71
|
+
- **THEN** the system returns a 404 error
|
|
72
|
+
|
|
73
|
+
### Requirement: Permanently delete subscription
|
|
74
|
+
The system SHALL allow permanently deleting (hard delete) a subscription by its ID.
|
|
75
|
+
|
|
76
|
+
#### Scenario: Successful permanent deletion
|
|
77
|
+
- **WHEN** the user permanently deletes a subscription with a valid ID
|
|
78
|
+
- **THEN** the subscription is removed from the database
|
|
79
|
+
|
|
80
|
+
### Requirement: Reactivate subscription
|
|
81
|
+
The system SHALL allow reactivating a previously deactivated subscription.
|
|
82
|
+
|
|
83
|
+
#### Scenario: Successful reactivation
|
|
84
|
+
- **WHEN** the user reactivates a deactivated subscription
|
|
85
|
+
- **THEN** the subscription's `active` field is set to true
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Summary Specification
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Resumo financeiro consolidado de um período, incluindo receitas, despesas, saldos de contas, totais de cartão de crédito e detalhamento por categoria.
|
|
5
|
+
|
|
6
|
+
## Scope
|
|
7
|
+
O que está **incluído** nesta spec:
|
|
8
|
+
- Resumo por mês (YYYY-MM) ou intervalo customizado (startDate + endDate em YYYY-MM-DD)
|
|
9
|
+
- Totais de receita e despesa (pagos e pendentes)
|
|
10
|
+
- Saldo total e por conta
|
|
11
|
+
- Despesas de cartão de crédito e detalhamento por categoria
|
|
12
|
+
|
|
13
|
+
O que está **fora do escopo**:
|
|
14
|
+
- Geração de extratos individuais de cartão (domínio: credit-cards)
|
|
15
|
+
- Listagem de transações individuais (domínio: transactions)
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
### Requirement: Get summary by month
|
|
20
|
+
The system SHALL return a financial summary for a given month in YYYY-MM format, including income, expenses, balance, credit card totals, and category breakdowns.
|
|
21
|
+
|
|
22
|
+
#### Scenario: Monthly summary retrieved
|
|
23
|
+
- **WHEN** the user provides `month` in YYYY-MM format
|
|
24
|
+
- **THEN** the system returns income, expenses, balance, credit card expenses, expenses/income by category, and account balances for that month
|
|
25
|
+
|
|
26
|
+
#### Scenario: Monthly summary for month with no data
|
|
27
|
+
- **WHEN** the user requests a summary for a month with no transactions
|
|
28
|
+
- **THEN** the system returns zeros for all numeric fields
|
|
29
|
+
|
|
30
|
+
### Requirement: Get summary by date range
|
|
31
|
+
The system SHALL return a financial summary for a custom date range defined by `startDate` and `endDate` (both in YYYY-MM-DD format).
|
|
32
|
+
|
|
33
|
+
#### Scenario: Range summary retrieved
|
|
34
|
+
- **WHEN** the user provides both `startDate` and `endDate`
|
|
35
|
+
- **THEN** the system returns the aggregated financial data for that period
|
|
36
|
+
|
|
37
|
+
### Requirement: Validation requires period parameters
|
|
38
|
+
The system SHALL require either `month` OR both `startDate` and `endDate`.
|
|
39
|
+
|
|
40
|
+
#### Scenario: No parameters provided
|
|
41
|
+
- **WHEN** the user provides neither `month` nor `startDate`+`endDate`
|
|
42
|
+
- **THEN** the API returns a 400 error
|
|
43
|
+
|
|
44
|
+
### Requirement: Pending income and expenses included
|
|
45
|
+
The summary SHALL include both paid and pending amounts separately.
|
|
46
|
+
|
|
47
|
+
#### Scenario: Pending transactions exist
|
|
48
|
+
- **WHEN** the period contains unpaid income or expense transactions
|
|
49
|
+
- **THEN** the summary includes `pendingIncome` and `pendingExpenses` fields
|
|
@@ -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 => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|