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,147 +1,203 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { CreateCreditCardInput, UpdateCreditCardInput, PayStatementInput, ReopenStatementInput } from '../types/schemas.js';
|
|
4
|
-
import { apiClient } from '../services/apiClient.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { CreateCreditCardInput, UpdateCreditCardInput, PayStatementInput, ReopenStatementInput, CreateAnticipationInput } from '../types/schemas.js';
|
|
4
|
+
import { apiClient } from '../services/apiClient.js';
|
|
5
|
+
import { handleToolError } from '../utils/toolHelpers.js';
|
|
6
|
+
|
|
7
|
+
export function registerCreditCardTools(server: McpServer) {
|
|
8
|
+
server.registerTool(
|
|
9
|
+
'create_credit_card',
|
|
10
|
+
{
|
|
11
|
+
title: 'Create Credit Card',
|
|
12
|
+
description: 'Create a new credit card account',
|
|
13
|
+
inputSchema: CreateCreditCardInput
|
|
14
|
+
},
|
|
15
|
+
async (args) => {
|
|
16
|
+
try {
|
|
17
|
+
const card = await apiClient.post('/credit-cards', args);
|
|
18
|
+
return {
|
|
19
|
+
content: [{ type: 'text', text: `Credit Card created: ${JSON.stringify(card, null, 2)}` }]
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return handleToolError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
server.registerTool(
|
|
28
|
+
'get_credit_cards',
|
|
29
|
+
{
|
|
30
|
+
title: 'Get Credit Cards',
|
|
31
|
+
description: 'List all credit cards',
|
|
32
|
+
inputSchema: z.object({})
|
|
33
|
+
},
|
|
34
|
+
async () => {
|
|
35
|
+
try {
|
|
36
|
+
const cards = await apiClient.get('/credit-cards');
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: 'text', text: `Credit Cards: ${JSON.stringify(cards, null, 2)}` }]
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return handleToolError(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
server.registerTool(
|
|
47
|
+
'get_credit_card',
|
|
48
|
+
{
|
|
49
|
+
title: 'Get Credit Card',
|
|
50
|
+
description: 'Get a credit card by ID',
|
|
51
|
+
inputSchema: z.object({ id: z.string() })
|
|
52
|
+
},
|
|
53
|
+
async ({ id }) => {
|
|
54
|
+
try {
|
|
55
|
+
const card = await apiClient.get(`/credit-cards/${id}`);
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: 'text', text: `Credit Card: ${JSON.stringify(card, null, 2)}` }]
|
|
58
|
+
};
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return handleToolError(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
server.registerTool(
|
|
66
|
+
'update_credit_card',
|
|
67
|
+
{
|
|
68
|
+
title: 'Update Credit Card',
|
|
69
|
+
description: 'Update a credit card',
|
|
70
|
+
inputSchema: UpdateCreditCardInput
|
|
71
|
+
},
|
|
72
|
+
async ({ id, ...data }) => {
|
|
73
|
+
try {
|
|
74
|
+
const card = await apiClient.patch(`/credit-cards/${id}`, data);
|
|
75
|
+
return {
|
|
76
|
+
content: [{ type: 'text', text: `Credit Card updated: ${JSON.stringify(card, null, 2)}` }]
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
return handleToolError(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
server.registerTool(
|
|
85
|
+
'delete_credit_card',
|
|
86
|
+
{
|
|
87
|
+
title: 'Delete Credit Card',
|
|
88
|
+
description: 'Delete a credit card by ID',
|
|
89
|
+
inputSchema: z.object({ id: z.string() })
|
|
90
|
+
},
|
|
91
|
+
async ({ id }) => {
|
|
92
|
+
try {
|
|
93
|
+
await apiClient.delete(`/credit-cards/${id}`);
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: `Credit Card deleted successfully (ID: ${id})` }]
|
|
96
|
+
};
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return handleToolError(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
server.registerTool(
|
|
104
|
+
'get_statement',
|
|
105
|
+
{
|
|
106
|
+
title: 'Get Statement',
|
|
107
|
+
description: 'Get credit card statement for a specific month',
|
|
108
|
+
inputSchema: z.object({
|
|
109
|
+
id: z.string().describe('Credit Card ID'),
|
|
110
|
+
month: z.string().describe('Month in YYYY-MM format')
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
async ({ id, month }) => {
|
|
114
|
+
try {
|
|
115
|
+
const statement = await apiClient.get(`/credit-cards/${id}/statement?month=${month}`);
|
|
116
|
+
return {
|
|
117
|
+
content: [{ type: 'text', text: `Statement: ${JSON.stringify(statement, null, 2)}` }]
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return handleToolError(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
server.registerTool(
|
|
126
|
+
'pay_statement',
|
|
127
|
+
{
|
|
128
|
+
title: 'Pay Statement',
|
|
129
|
+
description: 'Mark all transactions in a credit card statement as paid',
|
|
130
|
+
inputSchema: PayStatementInput
|
|
131
|
+
},
|
|
132
|
+
async ({ cardId, month, paymentAccountId }) => {
|
|
133
|
+
try {
|
|
134
|
+
await apiClient.post(`/credit-cards/${cardId}/pay-statement`, { month, paymentAccountId });
|
|
135
|
+
return {
|
|
136
|
+
content: [{ type: 'text', text: `Statement for ${month} paid successfully.` }]
|
|
137
|
+
};
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return handleToolError(error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
server.registerTool(
|
|
145
|
+
'reopen_statement',
|
|
146
|
+
{
|
|
147
|
+
title: 'Reopen Statement',
|
|
148
|
+
description: 'Reopen a credit card statement by marking all transactions as unpaid',
|
|
149
|
+
inputSchema: ReopenStatementInput
|
|
150
|
+
},
|
|
151
|
+
async ({ cardId, month }) => {
|
|
152
|
+
try {
|
|
153
|
+
const result = await apiClient.post(`/credit-cards/${cardId}/reopen-statement`, { month });
|
|
154
|
+
return {
|
|
155
|
+
content: [{ type: 'text', text: `Statement reopened: ${JSON.stringify(result, null, 2)}` }]
|
|
156
|
+
};
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return handleToolError(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
server.registerTool(
|
|
164
|
+
'get_statement_status',
|
|
165
|
+
{
|
|
166
|
+
title: 'Get Statement Status',
|
|
167
|
+
description: 'Get credit card statement payment status',
|
|
168
|
+
inputSchema: z.object({
|
|
169
|
+
id: z.string().describe('Credit Card ID'),
|
|
170
|
+
month: z.string().describe('Month in YYYY-MM format')
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
async ({ id, month }) => {
|
|
174
|
+
try {
|
|
175
|
+
const status = await apiClient.get(`/credit-cards/${id}/statement-status?month=${month}`);
|
|
176
|
+
return {
|
|
177
|
+
content: [{ type: 'text', text: `Statement Status: ${JSON.stringify(status, null, 2)}` }]
|
|
178
|
+
};
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return handleToolError(error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
server.registerTool(
|
|
186
|
+
'create_anticipation',
|
|
187
|
+
{
|
|
188
|
+
title: 'Create Credit Card Anticipation',
|
|
189
|
+
description: 'Create a credit card anticipation (advance payment toward a statement). Creates a linked pair: INCOME on the credit card side and EXPENSE on the account side.',
|
|
190
|
+
inputSchema: CreateAnticipationInput
|
|
191
|
+
},
|
|
192
|
+
async ({ cardId, ...body }) => {
|
|
193
|
+
try {
|
|
194
|
+
const result = await apiClient.post(`/credit-cards/${cardId}/anticipations`, body);
|
|
195
|
+
return {
|
|
196
|
+
content: [{ type: 'text', text: `Anticipation created: ${JSON.stringify(result, null, 2)}` }]
|
|
197
|
+
};
|
|
198
|
+
} catch (error) {
|
|
199
|
+
return handleToolError(error);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}
|
package/src/tools/data.ts
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { ImportDataInput } from '../types/schemas.js';
|
|
4
|
-
import { apiClient } from '../services/apiClient.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ImportDataInput } from '../types/schemas.js';
|
|
4
|
+
import { apiClient } from '../services/apiClient.js';
|
|
5
|
+
import { handleToolError } from '../utils/toolHelpers.js';
|
|
6
|
+
|
|
7
|
+
export function registerDataTools(server: McpServer) {
|
|
8
|
+
server.registerTool(
|
|
9
|
+
'export_data',
|
|
10
|
+
{
|
|
11
|
+
title: 'Export Data',
|
|
12
|
+
description: 'Export all user data (settings, categories, accounts, credit cards, recurrence rules, transactions) as a complete backup',
|
|
13
|
+
inputSchema: z.object({})
|
|
14
|
+
},
|
|
15
|
+
async () => {
|
|
16
|
+
try {
|
|
17
|
+
const data = await apiClient.get('/export');
|
|
18
|
+
return {
|
|
19
|
+
content: [{ type: 'text', text: `Export: ${JSON.stringify(data, null, 2)}` }]
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return handleToolError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
server.registerTool(
|
|
28
|
+
'import_data',
|
|
29
|
+
{
|
|
30
|
+
title: 'Import Data',
|
|
31
|
+
description: 'Import a previously exported backup. Mode "reset" clears all existing data first; mode "increment" adds new records and skips existing IDs.',
|
|
32
|
+
inputSchema: ImportDataInput
|
|
33
|
+
},
|
|
34
|
+
async (args) => {
|
|
35
|
+
try {
|
|
36
|
+
const result = await apiClient.post('/import', args);
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: 'text', text: `Import result: ${JSON.stringify(result, null, 2)}` }]
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return handleToolError(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/tools/settings.ts
CHANGED
|
@@ -1,51 +1,64 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { CreateSettingsInput, UpdateSettingsInput } from '../types/schemas.js';
|
|
4
|
-
import { apiClient } from '../services/apiClient.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { CreateSettingsInput, UpdateSettingsInput } from '../types/schemas.js';
|
|
4
|
+
import { apiClient } from '../services/apiClient.js';
|
|
5
|
+
import { handleToolError } from '../utils/toolHelpers.js';
|
|
6
|
+
|
|
7
|
+
export function registerSettingsTools(server: McpServer) {
|
|
8
|
+
server.registerTool(
|
|
9
|
+
'create_settings',
|
|
10
|
+
{
|
|
11
|
+
title: 'Create Settings',
|
|
12
|
+
description: 'Create global settings (only if not exists)',
|
|
13
|
+
inputSchema: CreateSettingsInput
|
|
14
|
+
},
|
|
15
|
+
async (args) => {
|
|
16
|
+
try {
|
|
17
|
+
const settings = await apiClient.post('/settings', args);
|
|
18
|
+
return {
|
|
19
|
+
content: [{ type: 'text', text: `Settings created: ${JSON.stringify(settings, null, 2)}` }]
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return handleToolError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
server.registerTool(
|
|
28
|
+
'get_settings',
|
|
29
|
+
{
|
|
30
|
+
title: 'Get Settings',
|
|
31
|
+
description: 'Get global settings',
|
|
32
|
+
inputSchema: z.object({})
|
|
33
|
+
},
|
|
34
|
+
async () => {
|
|
35
|
+
try {
|
|
36
|
+
const settings = await apiClient.get('/settings');
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: 'text', text: `Settings: ${JSON.stringify(settings, null, 2)}` }]
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return handleToolError(error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
server.registerTool(
|
|
47
|
+
'update_settings',
|
|
48
|
+
{
|
|
49
|
+
title: 'Update Settings',
|
|
50
|
+
description: 'Update global settings',
|
|
51
|
+
inputSchema: UpdateSettingsInput
|
|
52
|
+
},
|
|
53
|
+
async (args) => {
|
|
54
|
+
try {
|
|
55
|
+
const settings = await apiClient.put('/settings', args);
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: 'text', text: `Settings updated: ${JSON.stringify(settings, null, 2)}` }]
|
|
58
|
+
};
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return handleToolError(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|