quantix-mcp 0.3.7 → 0.4.3
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/.github/agents/copilot-instructions.md +32 -32
- package/.github/copilot-instructions.md +17 -17
- package/.github/workflows/publish.yaml +28 -28
- package/.opencode/command/speckit.analyze.md +184 -184
- package/.opencode/command/speckit.checklist.md +294 -294
- package/.opencode/command/speckit.clarify.md +181 -181
- package/.opencode/command/speckit.constitution.md +84 -84
- package/.opencode/command/speckit.implement.md +135 -135
- package/.opencode/command/speckit.plan.md +89 -89
- package/.opencode/command/speckit.specify.md +258 -258
- package/.opencode/command/speckit.tasks.md +137 -137
- package/.opencode/command/speckit.taskstoissues.md +30 -30
- package/.specify/memory/constitution.md +58 -58
- package/.specify/templates/constitution-template.md +50 -50
- package/.vscode/launch.json +14 -14
- package/CLAUDE.md +70 -64
- package/GEMINI.md +58 -0
- package/README.md +176 -176
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/accounts.d.ts.map +1 -1
- package/dist/tools/accounts.js +55 -34
- package/dist/tools/accounts.js.map +1 -1
- package/dist/tools/categories.d.ts.map +1 -1
- package/dist/tools/categories.js +46 -20
- package/dist/tools/categories.js.map +1 -1
- package/dist/tools/credit-cards.d.ts.map +1 -1
- package/dist/tools/credit-cards.js +104 -33
- package/dist/tools/credit-cards.js.map +1 -1
- package/dist/tools/data.d.ts.map +1 -1
- package/dist/tools/data.js +19 -8
- package/dist/tools/data.js.map +1 -1
- package/dist/tools/settings.d.ts.map +1 -1
- package/dist/tools/settings.js +28 -12
- package/dist/tools/settings.js.map +1 -1
- package/dist/tools/subscriptions.d.ts +3 -0
- package/dist/tools/subscriptions.d.ts.map +1 -0
- package/dist/tools/subscriptions.js +128 -0
- package/dist/tools/subscriptions.js.map +1 -0
- package/dist/tools/summary.d.ts.map +1 -1
- package/dist/tools/summary.js +17 -11
- package/dist/tools/summary.js.map +1 -1
- package/dist/tools/transactions.d.ts.map +1 -1
- package/dist/tools/transactions.js +85 -50
- package/dist/tools/transactions.js.map +1 -1
- package/dist/tools/transfers.d.ts +3 -0
- package/dist/tools/transfers.d.ts.map +1 -0
- package/dist/tools/transfers.js +107 -0
- package/dist/tools/transfers.js.map +1 -0
- package/dist/types/schemas.d.ts +65 -0
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +69 -3
- package/dist/types/schemas.js.map +1 -1
- package/dist/utils/toolHelpers.d.ts +7 -0
- package/dist/utils/toolHelpers.d.ts.map +1 -0
- package/dist/utils/toolHelpers.js +11 -0
- package/dist/utils/toolHelpers.js.map +1 -0
- package/openapi.yaml +2279 -1828
- package/package.json +41 -41
- package/specs/001-mcp-api-integration/checklists/requirements.md +34 -34
- package/specs/001-mcp-api-integration/contracts/openapi.yaml +635 -635
- package/specs/001-mcp-api-integration/data-model.md +106 -106
- package/specs/001-mcp-api-integration/plan.md +73 -73
- package/specs/001-mcp-api-integration/quickstart.md +74 -74
- package/specs/001-mcp-api-integration/research.md +58 -58
- package/specs/001-mcp-api-integration/spec.md +119 -119
- package/specs/001-mcp-api-integration/tasks.md +64 -64
- package/src/config.ts +36 -36
- package/src/index.ts +60 -47
- package/src/services/apiClient.ts +49 -49
- package/src/tools/accounts.ts +122 -111
- package/src/tools/categories.ts +102 -81
- package/src/tools/credit-cards.ts +203 -147
- package/src/tools/data.ts +45 -36
- package/src/tools/settings.ts +64 -51
- package/src/tools/subscriptions.ts +159 -0
- package/src/tools/summary.ts +29 -24
- package/src/tools/transactions.ts +156 -128
- package/src/tools/transfers.ts +122 -0
- package/src/types/schemas.ts +304 -235
- package/src/utils/toolHelpers.ts +11 -0
- package/tests/benchmark.test.d.ts +1 -1
- package/tests/benchmark.test.js +32 -32
- package/tests/benchmark.test.ts +38 -38
- package/tests/server.test.d.ts +1 -1
- package/tests/server.test.js +12 -12
- package/tests/server.test.ts +14 -14
- package/tests/setup.d.ts +3 -3
- package/tests/setup.js +16 -16
- package/tests/setup.ts +20 -20
- package/tests/tools/accounts.test.ts +159 -118
- package/tests/tools/categories.test.d.ts +1 -1
- package/tests/tools/categories.test.js +62 -62
- package/tests/tools/categories.test.ts +120 -78
- package/tests/tools/credit-cards.test.d.ts +1 -1
- package/tests/tools/credit-cards.test.js +70 -70
- package/tests/tools/credit-cards.test.ts +131 -89
- package/tests/tools/data.test.ts +100 -0
- package/tests/tools/settings.test.ts +116 -0
- package/tests/tools/subscriptions.test.ts +173 -0
- package/tests/tools/summary.test.d.ts +1 -1
- package/tests/tools/summary.test.js +35 -35
- package/tests/tools/summary.test.ts +63 -42
- package/tests/tools/transactions.test.d.ts +1 -1
- package/tests/tools/transactions.test.js +66 -66
- package/tests/tools/transactions.test.ts +133 -82
- package/tests/tools/transfers.test.ts +141 -0
- package/tsconfig.json +52 -52
- package/vitest.config.d.ts +2 -2
- package/vitest.config.js +13 -13
- package/vitest.config.ts +14 -14
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
# Data Model & Schema Mapping
|
|
2
|
-
|
|
3
|
-
**Feature**: MCP Server for Quantix API Integration
|
|
4
|
-
**Source**: [contracts/openapi.yaml](./contracts/openapi.yaml)
|
|
5
|
-
|
|
6
|
-
## Domain Entities
|
|
7
|
-
|
|
8
|
-
### Category
|
|
9
|
-
- **Fields**:
|
|
10
|
-
- `id`: string (UUID)
|
|
11
|
-
- `name`: string
|
|
12
|
-
- `type`: enum ("INCOME", "EXPENSE")
|
|
13
|
-
- `createdAt`: datetime
|
|
14
|
-
- **Zod Schema**:
|
|
15
|
-
```typescript
|
|
16
|
-
z.object({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
name: z.string(),
|
|
19
|
-
type: z.enum(["INCOME", "EXPENSE"]),
|
|
20
|
-
createdAt: z.string().datetime()
|
|
21
|
-
})
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Transaction
|
|
25
|
-
- **Fields**:
|
|
26
|
-
- `id`: string
|
|
27
|
-
- `type`: enum ("INCOME", "EXPENSE")
|
|
28
|
-
- `name`: string
|
|
29
|
-
- `amount`: number (min 0)
|
|
30
|
-
- `date`: string (YYYY-MM-DD)
|
|
31
|
-
- `categoryId`: string (optional)
|
|
32
|
-
- `paymentMethod`: enum ("CASH", "PIX", "DEBIT", "CREDIT") (optional)
|
|
33
|
-
- `creditCardId`: string (optional, required if CREDIT)
|
|
34
|
-
- `paid`: boolean (default false)
|
|
35
|
-
- **Zod Schema**:
|
|
36
|
-
```typescript
|
|
37
|
-
z.object({
|
|
38
|
-
id: z.string(),
|
|
39
|
-
type: z.enum(["INCOME", "EXPENSE"]),
|
|
40
|
-
name: z.string(),
|
|
41
|
-
amount: z.number().min(0),
|
|
42
|
-
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
43
|
-
categoryId: z.string().optional(),
|
|
44
|
-
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
|
|
45
|
-
creditCardId: z.string().optional(),
|
|
46
|
-
paid: z.boolean().default(false)
|
|
47
|
-
})
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### CreditCard
|
|
51
|
-
- **Fields**:
|
|
52
|
-
- `id`: string
|
|
53
|
-
- `name`: string
|
|
54
|
-
- `limitAmount`: number
|
|
55
|
-
- `closingDay`: integer (1-31)
|
|
56
|
-
- `dueDay`: integer (1-31)
|
|
57
|
-
- **Zod Schema**:
|
|
58
|
-
```typescript
|
|
59
|
-
z.object({
|
|
60
|
-
id: z.string(),
|
|
61
|
-
name: z.string(),
|
|
62
|
-
limitAmount: z.number().min(0),
|
|
63
|
-
closingDay: z.number().int().min(1).max(31),
|
|
64
|
-
dueDay: z.number().int().min(1).max(31)
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Tool Input Schemas
|
|
69
|
-
|
|
70
|
-
These schemas define the arguments for the MCP tools.
|
|
71
|
-
|
|
72
|
-
### `create_category`
|
|
73
|
-
```typescript
|
|
74
|
-
z.object({
|
|
75
|
-
name: z.string(),
|
|
76
|
-
type: z.enum(["INCOME", "EXPENSE"])
|
|
77
|
-
})
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### `create_transaction`
|
|
81
|
-
```typescript
|
|
82
|
-
z.object({
|
|
83
|
-
type: z.enum(["INCOME", "EXPENSE"]),
|
|
84
|
-
name: z.string(),
|
|
85
|
-
amount: z.number().positive(),
|
|
86
|
-
date: z.string().describe("ISO date string YYYY-MM-DD"),
|
|
87
|
-
categoryId: z.string().optional(),
|
|
88
|
-
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
|
|
89
|
-
creditCardId: z.string().optional()
|
|
90
|
-
})
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### `get_transactions`
|
|
94
|
-
```typescript
|
|
95
|
-
z.object({
|
|
96
|
-
month: z.string().regex(/^\d{4}-\d{2}$/).describe("Format: YYYY-MM")
|
|
97
|
-
})
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### `pay_statement`
|
|
101
|
-
```typescript
|
|
102
|
-
z.object({
|
|
103
|
-
cardId: z.string(),
|
|
104
|
-
month: z.string().regex(/^\d{4}-\d{2}$/)
|
|
105
|
-
})
|
|
106
|
-
```
|
|
1
|
+
# Data Model & Schema Mapping
|
|
2
|
+
|
|
3
|
+
**Feature**: MCP Server for Quantix API Integration
|
|
4
|
+
**Source**: [contracts/openapi.yaml](./contracts/openapi.yaml)
|
|
5
|
+
|
|
6
|
+
## Domain Entities
|
|
7
|
+
|
|
8
|
+
### Category
|
|
9
|
+
- **Fields**:
|
|
10
|
+
- `id`: string (UUID)
|
|
11
|
+
- `name`: string
|
|
12
|
+
- `type`: enum ("INCOME", "EXPENSE")
|
|
13
|
+
- `createdAt`: datetime
|
|
14
|
+
- **Zod Schema**:
|
|
15
|
+
```typescript
|
|
16
|
+
z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
name: z.string(),
|
|
19
|
+
type: z.enum(["INCOME", "EXPENSE"]),
|
|
20
|
+
createdAt: z.string().datetime()
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Transaction
|
|
25
|
+
- **Fields**:
|
|
26
|
+
- `id`: string
|
|
27
|
+
- `type`: enum ("INCOME", "EXPENSE")
|
|
28
|
+
- `name`: string
|
|
29
|
+
- `amount`: number (min 0)
|
|
30
|
+
- `date`: string (YYYY-MM-DD)
|
|
31
|
+
- `categoryId`: string (optional)
|
|
32
|
+
- `paymentMethod`: enum ("CASH", "PIX", "DEBIT", "CREDIT") (optional)
|
|
33
|
+
- `creditCardId`: string (optional, required if CREDIT)
|
|
34
|
+
- `paid`: boolean (default false)
|
|
35
|
+
- **Zod Schema**:
|
|
36
|
+
```typescript
|
|
37
|
+
z.object({
|
|
38
|
+
id: z.string(),
|
|
39
|
+
type: z.enum(["INCOME", "EXPENSE"]),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
amount: z.number().min(0),
|
|
42
|
+
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
43
|
+
categoryId: z.string().optional(),
|
|
44
|
+
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
|
|
45
|
+
creditCardId: z.string().optional(),
|
|
46
|
+
paid: z.boolean().default(false)
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### CreditCard
|
|
51
|
+
- **Fields**:
|
|
52
|
+
- `id`: string
|
|
53
|
+
- `name`: string
|
|
54
|
+
- `limitAmount`: number
|
|
55
|
+
- `closingDay`: integer (1-31)
|
|
56
|
+
- `dueDay`: integer (1-31)
|
|
57
|
+
- **Zod Schema**:
|
|
58
|
+
```typescript
|
|
59
|
+
z.object({
|
|
60
|
+
id: z.string(),
|
|
61
|
+
name: z.string(),
|
|
62
|
+
limitAmount: z.number().min(0),
|
|
63
|
+
closingDay: z.number().int().min(1).max(31),
|
|
64
|
+
dueDay: z.number().int().min(1).max(31)
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Tool Input Schemas
|
|
69
|
+
|
|
70
|
+
These schemas define the arguments for the MCP tools.
|
|
71
|
+
|
|
72
|
+
### `create_category`
|
|
73
|
+
```typescript
|
|
74
|
+
z.object({
|
|
75
|
+
name: z.string(),
|
|
76
|
+
type: z.enum(["INCOME", "EXPENSE"])
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `create_transaction`
|
|
81
|
+
```typescript
|
|
82
|
+
z.object({
|
|
83
|
+
type: z.enum(["INCOME", "EXPENSE"]),
|
|
84
|
+
name: z.string(),
|
|
85
|
+
amount: z.number().positive(),
|
|
86
|
+
date: z.string().describe("ISO date string YYYY-MM-DD"),
|
|
87
|
+
categoryId: z.string().optional(),
|
|
88
|
+
paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
|
|
89
|
+
creditCardId: z.string().optional()
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `get_transactions`
|
|
94
|
+
```typescript
|
|
95
|
+
z.object({
|
|
96
|
+
month: z.string().regex(/^\d{4}-\d{2}$/).describe("Format: YYYY-MM")
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### `pay_statement`
|
|
101
|
+
```typescript
|
|
102
|
+
z.object({
|
|
103
|
+
cardId: z.string(),
|
|
104
|
+
month: z.string().regex(/^\d{4}-\d{2}$/)
|
|
105
|
+
})
|
|
106
|
+
```
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
# Implementation Plan: MCP Server for Quantix API Integration
|
|
2
|
-
|
|
3
|
-
**Branch**: `001-mcp-api-integration` | **Date**: 2026-01-31 | **Spec**: [spec.md](spec.md)
|
|
4
|
-
**Input**: Feature specification from `/specs/001-mcp-api-integration/spec.md`
|
|
5
|
-
|
|
6
|
-
## Summary
|
|
7
|
-
|
|
8
|
-
Implement 12 MCP tools to expose the Quantix Personal Finance Manager API capabilities (Categories, Credit Cards, Transactions, Summaries).
|
|
9
|
-
The solution will extend the existing Express-based MCP server in `src/index.ts`, adding Zod validation for all inputs and handling API authentication via `QUANTIX_API_KEY`.
|
|
10
|
-
|
|
11
|
-
## Technical Context
|
|
12
|
-
|
|
13
|
-
**Language/Version**: TypeScript 5.9 (Node.js)
|
|
14
|
-
**Primary Dependencies**: `@modelcontextprotocol/sdk`, `express`, `zod`, `fetch` (native Node 18+)
|
|
15
|
-
**Storage**: N/A (Stateless proxy to external API)
|
|
16
|
-
**Testing**: Vitest (Proposed, currently missing in `package.json`)
|
|
17
|
-
**Target Platform**: MCP Clients (e.g., Claude Desktop) connecting via SSE/HTTP
|
|
18
|
-
**Project Type**: Backend / API Proxy
|
|
19
|
-
**Performance Goals**: Low latency proxy (adding <20ms overhead)
|
|
20
|
-
**Constraints**: Must match OpenAPI 3.0 schema strictly for tools.
|
|
21
|
-
**Scale/Scope**: 12 Tools, ~5-6 Service modules.
|
|
22
|
-
|
|
23
|
-
## Constitution Check
|
|
24
|
-
|
|
25
|
-
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
|
26
|
-
|
|
27
|
-
* **Principle 1 (Library-First)**: We will organize tools into modules (`src/tools/`) rather than a monolithic `index.ts`.
|
|
28
|
-
* **Principle 3 (Test-First)**: We need to introduce a testing framework (`vitest`) as none exists.
|
|
29
|
-
* **Principle 4 (Integration Testing)**: We will create tests that mock the external API to verify tool behavior.
|
|
30
|
-
|
|
31
|
-
**Governance**: The `constitution.md` appears to be a template. Proceeding with standard best practices.
|
|
32
|
-
|
|
33
|
-
## Project Structure
|
|
34
|
-
|
|
35
|
-
### Documentation (this feature)
|
|
36
|
-
|
|
37
|
-
```text
|
|
38
|
-
specs/001-mcp-api-integration/
|
|
39
|
-
├── plan.md # This file
|
|
40
|
-
├── research.md # Phase 0 output
|
|
41
|
-
├── data-model.md # Phase 1 output
|
|
42
|
-
├── quickstart.md # Phase 1 output
|
|
43
|
-
└── contracts/ # Phase 1 output (Copy of openapi.yaml)
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Source Code (repository root)
|
|
47
|
-
|
|
48
|
-
```text
|
|
49
|
-
src/
|
|
50
|
-
├── index.ts # Entry point (server setup)
|
|
51
|
-
├── config.ts # Env var loading
|
|
52
|
-
├── tools/ # New directory for tool definitions
|
|
53
|
-
│ ├── categories.ts # Category tools
|
|
54
|
-
│ ├── credit-cards.ts # Credit Card tools
|
|
55
|
-
│ ├── transactions.ts # Transaction tools
|
|
56
|
-
│ └── summary.ts # Summary tools
|
|
57
|
-
├── services/ # New directory for API client
|
|
58
|
-
│ └── apiClient.ts # Typed fetch wrapper for Quantix API
|
|
59
|
-
└── types/ # Shared types / Zod schemas
|
|
60
|
-
└── schemas.ts # Zod schemas matching OpenAPI
|
|
61
|
-
|
|
62
|
-
tests/ # New directory
|
|
63
|
-
├── tools/
|
|
64
|
-
│ └── transactions.test.ts
|
|
65
|
-
└── services/
|
|
66
|
-
└── apiClient.test.ts
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Structure Decision**: Modular approach separating Tool Registration (UI layer) from API Logic (Service layer) and Schemas (Model layer).
|
|
70
|
-
|
|
71
|
-
## Complexity Tracking
|
|
72
|
-
|
|
73
|
-
N/A
|
|
1
|
+
# Implementation Plan: MCP Server for Quantix API Integration
|
|
2
|
+
|
|
3
|
+
**Branch**: `001-mcp-api-integration` | **Date**: 2026-01-31 | **Spec**: [spec.md](spec.md)
|
|
4
|
+
**Input**: Feature specification from `/specs/001-mcp-api-integration/spec.md`
|
|
5
|
+
|
|
6
|
+
## Summary
|
|
7
|
+
|
|
8
|
+
Implement 12 MCP tools to expose the Quantix Personal Finance Manager API capabilities (Categories, Credit Cards, Transactions, Summaries).
|
|
9
|
+
The solution will extend the existing Express-based MCP server in `src/index.ts`, adding Zod validation for all inputs and handling API authentication via `QUANTIX_API_KEY`.
|
|
10
|
+
|
|
11
|
+
## Technical Context
|
|
12
|
+
|
|
13
|
+
**Language/Version**: TypeScript 5.9 (Node.js)
|
|
14
|
+
**Primary Dependencies**: `@modelcontextprotocol/sdk`, `express`, `zod`, `fetch` (native Node 18+)
|
|
15
|
+
**Storage**: N/A (Stateless proxy to external API)
|
|
16
|
+
**Testing**: Vitest (Proposed, currently missing in `package.json`)
|
|
17
|
+
**Target Platform**: MCP Clients (e.g., Claude Desktop) connecting via SSE/HTTP
|
|
18
|
+
**Project Type**: Backend / API Proxy
|
|
19
|
+
**Performance Goals**: Low latency proxy (adding <20ms overhead)
|
|
20
|
+
**Constraints**: Must match OpenAPI 3.0 schema strictly for tools.
|
|
21
|
+
**Scale/Scope**: 12 Tools, ~5-6 Service modules.
|
|
22
|
+
|
|
23
|
+
## Constitution Check
|
|
24
|
+
|
|
25
|
+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
|
26
|
+
|
|
27
|
+
* **Principle 1 (Library-First)**: We will organize tools into modules (`src/tools/`) rather than a monolithic `index.ts`.
|
|
28
|
+
* **Principle 3 (Test-First)**: We need to introduce a testing framework (`vitest`) as none exists.
|
|
29
|
+
* **Principle 4 (Integration Testing)**: We will create tests that mock the external API to verify tool behavior.
|
|
30
|
+
|
|
31
|
+
**Governance**: The `constitution.md` appears to be a template. Proceeding with standard best practices.
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
### Documentation (this feature)
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
specs/001-mcp-api-integration/
|
|
39
|
+
├── plan.md # This file
|
|
40
|
+
├── research.md # Phase 0 output
|
|
41
|
+
├── data-model.md # Phase 1 output
|
|
42
|
+
├── quickstart.md # Phase 1 output
|
|
43
|
+
└── contracts/ # Phase 1 output (Copy of openapi.yaml)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Source Code (repository root)
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
src/
|
|
50
|
+
├── index.ts # Entry point (server setup)
|
|
51
|
+
├── config.ts # Env var loading
|
|
52
|
+
├── tools/ # New directory for tool definitions
|
|
53
|
+
│ ├── categories.ts # Category tools
|
|
54
|
+
│ ├── credit-cards.ts # Credit Card tools
|
|
55
|
+
│ ├── transactions.ts # Transaction tools
|
|
56
|
+
│ └── summary.ts # Summary tools
|
|
57
|
+
├── services/ # New directory for API client
|
|
58
|
+
│ └── apiClient.ts # Typed fetch wrapper for Quantix API
|
|
59
|
+
└── types/ # Shared types / Zod schemas
|
|
60
|
+
└── schemas.ts # Zod schemas matching OpenAPI
|
|
61
|
+
|
|
62
|
+
tests/ # New directory
|
|
63
|
+
├── tools/
|
|
64
|
+
│ └── transactions.test.ts
|
|
65
|
+
└── services/
|
|
66
|
+
└── apiClient.test.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Structure Decision**: Modular approach separating Tool Registration (UI layer) from API Logic (Service layer) and Schemas (Model layer).
|
|
70
|
+
|
|
71
|
+
## Complexity Tracking
|
|
72
|
+
|
|
73
|
+
N/A
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
# Quickstart: Quantix MCP Server
|
|
2
|
-
|
|
3
|
-
This guide explains how to configure and run the Quantix MCP server integration.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Node.js 18+
|
|
8
|
-
- A running instance of the Quantix API (or access to Staging/Prod)
|
|
9
|
-
- An API Key for Quantix
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
1. Install dependencies:
|
|
14
|
-
```bash
|
|
15
|
-
npm install
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
2. Build the project:
|
|
19
|
-
```bash
|
|
20
|
-
npm run build
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Configuration
|
|
24
|
-
|
|
25
|
-
Set the following environment variables. You can add them to a `.env` file or export them in your shell.
|
|
26
|
-
|
|
27
|
-
| Variable | Description | Example |
|
|
28
|
-
|----------|-------------|---------|
|
|
29
|
-
| `QUANTIX_API_URL` | Base URL of the Quantix API | `https://api.quantix.example.com` |
|
|
30
|
-
| `QUANTIX_API_KEY` | Your authentication key | `sk_live_12345` |
|
|
31
|
-
| `MPC_PORT` | Port for the MCP server | `3001` (default) |
|
|
32
|
-
|
|
33
|
-
## Running the Server
|
|
34
|
-
|
|
35
|
-
### Development Mode
|
|
36
|
-
```bash
|
|
37
|
-
# Windows (PowerShell)
|
|
38
|
-
$env:QUANTIX_API_URL="https://api.quantix.example.com"; $env:QUANTIX_API_KEY="test"; npm run dev
|
|
39
|
-
|
|
40
|
-
# Linux/Mac
|
|
41
|
-
QUANTIX_API_URL=https://api.quantix.example.com QUANTIX_API_KEY=test npm run dev
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Production
|
|
45
|
-
```bash
|
|
46
|
-
node dist/index.js
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Using with Claude Desktop
|
|
50
|
-
|
|
51
|
-
Add the server config to your Claude Desktop configuration file:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"mcpServers": {
|
|
56
|
-
"quantix": {
|
|
57
|
-
"command": "node",
|
|
58
|
-
"args": ["path/to/morpheus-mcp/dist/index.js"],
|
|
59
|
-
"env": {
|
|
60
|
-
"QUANTIX_API_URL": "...",
|
|
61
|
-
"QUANTIX_API_KEY": "..."
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Verification
|
|
69
|
-
|
|
70
|
-
To verify the integration, use the MCP Inspector or curl the running server (since it's HTTP/SSE based):
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
curl http://localhost:3001/mcp
|
|
74
|
-
```
|
|
1
|
+
# Quickstart: Quantix MCP Server
|
|
2
|
+
|
|
3
|
+
This guide explains how to configure and run the Quantix MCP server integration.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- A running instance of the Quantix API (or access to Staging/Prod)
|
|
9
|
+
- An API Key for Quantix
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
1. Install dependencies:
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Build the project:
|
|
19
|
+
```bash
|
|
20
|
+
npm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
Set the following environment variables. You can add them to a `.env` file or export them in your shell.
|
|
26
|
+
|
|
27
|
+
| Variable | Description | Example |
|
|
28
|
+
|----------|-------------|---------|
|
|
29
|
+
| `QUANTIX_API_URL` | Base URL of the Quantix API | `https://api.quantix.example.com` |
|
|
30
|
+
| `QUANTIX_API_KEY` | Your authentication key | `sk_live_12345` |
|
|
31
|
+
| `MPC_PORT` | Port for the MCP server | `3001` (default) |
|
|
32
|
+
|
|
33
|
+
## Running the Server
|
|
34
|
+
|
|
35
|
+
### Development Mode
|
|
36
|
+
```bash
|
|
37
|
+
# Windows (PowerShell)
|
|
38
|
+
$env:QUANTIX_API_URL="https://api.quantix.example.com"; $env:QUANTIX_API_KEY="test"; npm run dev
|
|
39
|
+
|
|
40
|
+
# Linux/Mac
|
|
41
|
+
QUANTIX_API_URL=https://api.quantix.example.com QUANTIX_API_KEY=test npm run dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Production
|
|
45
|
+
```bash
|
|
46
|
+
node dist/index.js
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Using with Claude Desktop
|
|
50
|
+
|
|
51
|
+
Add the server config to your Claude Desktop configuration file:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"quantix": {
|
|
57
|
+
"command": "node",
|
|
58
|
+
"args": ["path/to/morpheus-mcp/dist/index.js"],
|
|
59
|
+
"env": {
|
|
60
|
+
"QUANTIX_API_URL": "...",
|
|
61
|
+
"QUANTIX_API_KEY": "..."
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Verification
|
|
69
|
+
|
|
70
|
+
To verify the integration, use the MCP Inspector or curl the running server (since it's HTTP/SSE based):
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl http://localhost:3001/mcp
|
|
74
|
+
```
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# Research & Decisions: MCP API Integration
|
|
2
|
-
|
|
3
|
-
**Feature**: [spec.md](./spec.md)
|
|
4
|
-
**Status**: Complete
|
|
5
|
-
|
|
6
|
-
## Unknowns & Clarifications
|
|
7
|
-
|
|
8
|
-
### 1. Project Structure for Scaling Tools
|
|
9
|
-
**Question**: How to manage 12+ tools without bloating `index.ts`?
|
|
10
|
-
**Context**: Current `index.ts` has tool definition inline.
|
|
11
|
-
**Finding**: The MCP SDK `server.registerTool` can be called from imported modules if we pass the `mcpServer` instance, or better yet, we can export `Tool` definitions (name, description, schema, handler) and register them in a loop.
|
|
12
|
-
**Decision**:
|
|
13
|
-
- Create a `registerTools(server: McpServer)` function in each tool module (e.g., `src/tools/categories.ts`).
|
|
14
|
-
- `src/index.ts` will import these registration functions and call them.
|
|
15
|
-
|
|
16
|
-
### 2. Mocking `fetch` for Tests
|
|
17
|
-
**Question**: Best way to test without hitting real API?
|
|
18
|
-
**Context**: We generally want unit tests to be fast and isolated.
|
|
19
|
-
**Finding**: Since we are using native `fetch` (Node 18+), we can use `vitest` to spy on `global.fetch` or use a library like `msw` (Mock Service Worker). Given the simplicity, basic `vi.spyOn(global, 'fetch')` is sufficient.
|
|
20
|
-
**Decision**: Use `vitest` and spy on `global.fetch`.
|
|
21
|
-
|
|
22
|
-
## Technology Choices
|
|
23
|
-
|
|
24
|
-
| Area | Choice | Rationale |
|
|
25
|
-
|------|--------|-----------|
|
|
26
|
-
| **Validation** | `zod` | Native support in MCP SDK, TypeScript native, easy to derive from OpenAPI. |
|
|
27
|
-
| **HTTP Client** | Native `fetch` | No extra dependency weight, fully supported in modern Node. |
|
|
28
|
-
| **Testing** | `vitest` | Fast, compatible with ESM (Type "module" in package.json), Jest-compatible API. |
|
|
29
|
-
| **Env Vars** | `process.env` | Simple standard. |
|
|
30
|
-
|
|
31
|
-
## Design Patterns
|
|
32
|
-
|
|
33
|
-
### API Client Wrapper
|
|
34
|
-
Instead of calling `fetch` in every tool, we will create `src/services/apiClient.ts`:
|
|
35
|
-
```typescript
|
|
36
|
-
async function apiFetch<T>(endpoint: string, options: RequestInit): Promise<T> {
|
|
37
|
-
const url = `${process.env.QUANTIX_API_URL}${endpoint}`;
|
|
38
|
-
const response = await fetch(url, {
|
|
39
|
-
...options,
|
|
40
|
-
headers: {
|
|
41
|
-
...options.headers,
|
|
42
|
-
'API-KEY': process.env.QUANTIX_API_KEY
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
// Error handling logic here
|
|
46
|
-
return response.json();
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Zod Schema Reusability
|
|
51
|
-
We will define Zod schemas in `src/types/schemas.ts` that mirror the OpenAPI `components/schemas`. Use `z.infer` to generate TypeScript types for compile-time safety.
|
|
52
|
-
|
|
53
|
-
## Alternatives Considered
|
|
54
|
-
|
|
55
|
-
- **OpenAPI Code Generator**: Could auto-generate the client.
|
|
56
|
-
- *Rejected*: Too heavy for 12 endpoints, harder to customize for MCP specific return formats.
|
|
57
|
-
- **Axios**:
|
|
58
|
-
- *Rejected*: `fetch` is built-in.
|
|
1
|
+
# Research & Decisions: MCP API Integration
|
|
2
|
+
|
|
3
|
+
**Feature**: [spec.md](./spec.md)
|
|
4
|
+
**Status**: Complete
|
|
5
|
+
|
|
6
|
+
## Unknowns & Clarifications
|
|
7
|
+
|
|
8
|
+
### 1. Project Structure for Scaling Tools
|
|
9
|
+
**Question**: How to manage 12+ tools without bloating `index.ts`?
|
|
10
|
+
**Context**: Current `index.ts` has tool definition inline.
|
|
11
|
+
**Finding**: The MCP SDK `server.registerTool` can be called from imported modules if we pass the `mcpServer` instance, or better yet, we can export `Tool` definitions (name, description, schema, handler) and register them in a loop.
|
|
12
|
+
**Decision**:
|
|
13
|
+
- Create a `registerTools(server: McpServer)` function in each tool module (e.g., `src/tools/categories.ts`).
|
|
14
|
+
- `src/index.ts` will import these registration functions and call them.
|
|
15
|
+
|
|
16
|
+
### 2. Mocking `fetch` for Tests
|
|
17
|
+
**Question**: Best way to test without hitting real API?
|
|
18
|
+
**Context**: We generally want unit tests to be fast and isolated.
|
|
19
|
+
**Finding**: Since we are using native `fetch` (Node 18+), we can use `vitest` to spy on `global.fetch` or use a library like `msw` (Mock Service Worker). Given the simplicity, basic `vi.spyOn(global, 'fetch')` is sufficient.
|
|
20
|
+
**Decision**: Use `vitest` and spy on `global.fetch`.
|
|
21
|
+
|
|
22
|
+
## Technology Choices
|
|
23
|
+
|
|
24
|
+
| Area | Choice | Rationale |
|
|
25
|
+
|------|--------|-----------|
|
|
26
|
+
| **Validation** | `zod` | Native support in MCP SDK, TypeScript native, easy to derive from OpenAPI. |
|
|
27
|
+
| **HTTP Client** | Native `fetch` | No extra dependency weight, fully supported in modern Node. |
|
|
28
|
+
| **Testing** | `vitest` | Fast, compatible with ESM (Type "module" in package.json), Jest-compatible API. |
|
|
29
|
+
| **Env Vars** | `process.env` | Simple standard. |
|
|
30
|
+
|
|
31
|
+
## Design Patterns
|
|
32
|
+
|
|
33
|
+
### API Client Wrapper
|
|
34
|
+
Instead of calling `fetch` in every tool, we will create `src/services/apiClient.ts`:
|
|
35
|
+
```typescript
|
|
36
|
+
async function apiFetch<T>(endpoint: string, options: RequestInit): Promise<T> {
|
|
37
|
+
const url = `${process.env.QUANTIX_API_URL}${endpoint}`;
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
...options,
|
|
40
|
+
headers: {
|
|
41
|
+
...options.headers,
|
|
42
|
+
'API-KEY': process.env.QUANTIX_API_KEY
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// Error handling logic here
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Zod Schema Reusability
|
|
51
|
+
We will define Zod schemas in `src/types/schemas.ts` that mirror the OpenAPI `components/schemas`. Use `z.infer` to generate TypeScript types for compile-time safety.
|
|
52
|
+
|
|
53
|
+
## Alternatives Considered
|
|
54
|
+
|
|
55
|
+
- **OpenAPI Code Generator**: Could auto-generate the client.
|
|
56
|
+
- *Rejected*: Too heavy for 12 endpoints, harder to customize for MCP specific return formats.
|
|
57
|
+
- **Axios**:
|
|
58
|
+
- *Rejected*: `fetch` is built-in.
|