@codespar/mcp-open-finance 0.1.2 → 0.2.0

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/dist/index.js CHANGED
@@ -6,11 +6,21 @@
6
6
  * - list_accounts: List customer accounts
7
7
  * - get_account_balance: Get account balance
8
8
  * - list_transactions: List account transactions
9
+ * - get_account_overdraft_limits: Get account overdraft limits
9
10
  * - get_consent: Get consent details
10
11
  * - create_consent: Create a new consent request
12
+ * - revoke_consent: Revoke an existing consent
11
13
  * - list_credit_cards: List credit card accounts
14
+ * - get_credit_card_bills: Get credit card bills
12
15
  * - get_credit_card_transactions: Get credit card transactions
16
+ * - list_loans: List loan contracts
17
+ * - get_loan_payments: Get loan payment schedule
18
+ * - list_financings: List financing contracts
13
19
  * - list_investments: List investment products
20
+ * - create_payment_consent: Create payment-initiation consent
21
+ * - create_payment: Initiate a payment
22
+ * - get_personal_qualifications: Get personal customer qualifications
23
+ * - get_business_qualifications: Get business customer qualifications
14
24
  *
15
25
  * Environment:
16
26
  * OPEN_FINANCE_BASE_URL — Institution API base URL
@@ -37,7 +47,7 @@ async function getAccessToken() {
37
47
  grant_type: "client_credentials",
38
48
  client_id: CLIENT_ID,
39
49
  client_secret: CLIENT_SECRET,
40
- scope: "openid accounts credit-cards-accounts resources consents investments",
50
+ scope: "openid accounts credit-cards-accounts resources consents investments loans financings customers payments",
41
51
  }),
42
52
  });
43
53
  if (!res.ok) {
@@ -65,7 +75,7 @@ async function openFinanceRequest(method, path, body) {
65
75
  }
66
76
  return res.json();
67
77
  }
68
- const server = new Server({ name: "mcp-open-finance", version: "0.1.0" }, { capabilities: { tools: {} } });
78
+ const server = new Server({ name: "mcp-open-finance", version: "0.2.0" }, { capabilities: { tools: {} } });
69
79
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
70
80
  tools: [
71
81
  {
@@ -109,6 +119,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
109
119
  required: ["consentId", "accountId"],
110
120
  },
111
121
  },
122
+ {
123
+ name: "get_account_overdraft_limits",
124
+ description: "Get account overdraft (limites) via Open Finance",
125
+ inputSchema: {
126
+ type: "object",
127
+ properties: {
128
+ consentId: { type: "string", description: "Consent ID" },
129
+ accountId: { type: "string", description: "Account ID" },
130
+ },
131
+ required: ["consentId", "accountId"],
132
+ },
133
+ },
112
134
  {
113
135
  name: "get_consent",
114
136
  description: "Get consent details by ID",
@@ -138,6 +160,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
138
160
  required: ["permissions", "expirationDateTime"],
139
161
  },
140
162
  },
163
+ {
164
+ name: "revoke_consent",
165
+ description: "Revoke an existing consent (data or payment)",
166
+ inputSchema: {
167
+ type: "object",
168
+ properties: {
169
+ consentId: { type: "string", description: "Consent ID to revoke" },
170
+ consentType: { type: "string", enum: ["data", "payment"], description: "Consent type (default: data)" },
171
+ },
172
+ required: ["consentId"],
173
+ },
174
+ },
141
175
  {
142
176
  name: "list_credit_cards",
143
177
  description: "List credit card accounts via Open Finance",
@@ -151,6 +185,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
151
185
  required: ["consentId"],
152
186
  },
153
187
  },
188
+ {
189
+ name: "get_credit_card_bills",
190
+ description: "Get credit card bills (faturas) via Open Finance",
191
+ inputSchema: {
192
+ type: "object",
193
+ properties: {
194
+ consentId: { type: "string", description: "Consent ID" },
195
+ creditCardAccountId: { type: "string", description: "Credit card account ID" },
196
+ fromDueDate: { type: "string", description: "Start due date (YYYY-MM-DD)" },
197
+ toDueDate: { type: "string", description: "End due date (YYYY-MM-DD)" },
198
+ page: { type: "number", description: "Page number" },
199
+ pageSize: { type: "number", description: "Items per page" },
200
+ },
201
+ required: ["consentId", "creditCardAccountId"],
202
+ },
203
+ },
154
204
  {
155
205
  name: "get_credit_card_transactions",
156
206
  description: "Get credit card transactions via Open Finance",
@@ -167,6 +217,46 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
167
217
  required: ["consentId", "creditCardAccountId"],
168
218
  },
169
219
  },
220
+ {
221
+ name: "list_loans",
222
+ description: "List loan contracts (empréstimos) via Open Finance",
223
+ inputSchema: {
224
+ type: "object",
225
+ properties: {
226
+ consentId: { type: "string", description: "Consent ID" },
227
+ page: { type: "number", description: "Page number" },
228
+ pageSize: { type: "number", description: "Items per page" },
229
+ },
230
+ required: ["consentId"],
231
+ },
232
+ },
233
+ {
234
+ name: "get_loan_payments",
235
+ description: "Get loan payment schedule via Open Finance",
236
+ inputSchema: {
237
+ type: "object",
238
+ properties: {
239
+ consentId: { type: "string", description: "Consent ID" },
240
+ contractId: { type: "string", description: "Loan contract ID" },
241
+ page: { type: "number", description: "Page number" },
242
+ pageSize: { type: "number", description: "Items per page" },
243
+ },
244
+ required: ["consentId", "contractId"],
245
+ },
246
+ },
247
+ {
248
+ name: "list_financings",
249
+ description: "List financing contracts (financiamentos) via Open Finance",
250
+ inputSchema: {
251
+ type: "object",
252
+ properties: {
253
+ consentId: { type: "string", description: "Consent ID" },
254
+ page: { type: "number", description: "Page number" },
255
+ pageSize: { type: "number", description: "Items per page" },
256
+ },
257
+ required: ["consentId"],
258
+ },
259
+ },
170
260
  {
171
261
  name: "list_investments",
172
262
  description: "List investment products via Open Finance",
@@ -181,6 +271,66 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
181
271
  required: ["consentId"],
182
272
  },
183
273
  },
274
+ {
275
+ name: "create_payment_consent",
276
+ description: "Create payment-initiation consent (e.g., PIX) via Open Finance",
277
+ inputSchema: {
278
+ type: "object",
279
+ properties: {
280
+ loggedUserCpf: { type: "string", description: "Logged user CPF" },
281
+ creditorName: { type: "string", description: "Creditor name" },
282
+ creditorCpfCnpj: { type: "string", description: "Creditor CPF/CNPJ" },
283
+ paymentAmount: { type: "string", description: "Payment amount (e.g., '100.00')" },
284
+ paymentCurrency: { type: "string", description: "ISO 4217 currency (default: BRL)" },
285
+ localInstrument: { type: "string", enum: ["MANU", "DICT", "QRDN", "QRES", "INIC"], description: "PIX local instrument (default: DICT)" },
286
+ paymentType: { type: "string", enum: ["PIX", "TED", "TEF", "BOLETO"], description: "Payment type (default: PIX)" },
287
+ expirationDateTime: { type: "string", description: "Consent expiration (ISO 8601)" },
288
+ },
289
+ required: ["loggedUserCpf", "creditorName", "creditorCpfCnpj", "paymentAmount"],
290
+ },
291
+ },
292
+ {
293
+ name: "create_payment",
294
+ description: "Initiate a payment using an authorized payment consent",
295
+ inputSchema: {
296
+ type: "object",
297
+ properties: {
298
+ consentId: { type: "string", description: "Authorized payment consent ID" },
299
+ creditorAccountIspb: { type: "string", description: "Creditor account ISPB" },
300
+ creditorAccountIssuer: { type: "string", description: "Creditor account issuer (agência)" },
301
+ creditorAccountNumber: { type: "string", description: "Creditor account number" },
302
+ creditorAccountType: { type: "string", enum: ["CACC", "SLRY", "SVGS", "TRAN"], description: "Creditor account type" },
303
+ paymentAmount: { type: "string", description: "Payment amount (e.g., '100.00')" },
304
+ paymentCurrency: { type: "string", description: "ISO 4217 currency (default: BRL)" },
305
+ remittanceInformation: { type: "string", description: "Free-text remittance info" },
306
+ qrCode: { type: "string", description: "PIX QR Code payload (optional)" },
307
+ proxy: { type: "string", description: "PIX key/proxy (optional)" },
308
+ },
309
+ required: ["consentId", "creditorAccountIspb", "creditorAccountIssuer", "creditorAccountNumber", "creditorAccountType", "paymentAmount"],
310
+ },
311
+ },
312
+ {
313
+ name: "get_personal_qualifications",
314
+ description: "Get personal customer qualifications (income, occupation) via Open Finance",
315
+ inputSchema: {
316
+ type: "object",
317
+ properties: {
318
+ consentId: { type: "string", description: "Consent ID" },
319
+ },
320
+ required: ["consentId"],
321
+ },
322
+ },
323
+ {
324
+ name: "get_business_qualifications",
325
+ description: "Get business customer qualifications via Open Finance",
326
+ inputSchema: {
327
+ type: "object",
328
+ properties: {
329
+ consentId: { type: "string", description: "Consent ID" },
330
+ },
331
+ required: ["consentId"],
332
+ },
333
+ },
184
334
  ],
185
335
  }));
186
336
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
@@ -210,6 +360,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
210
360
  params.set("page-size", String(args.pageSize));
211
361
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/accounts/v2/accounts/${args?.accountId}/transactions?${params}`), null, 2) }] };
212
362
  }
363
+ case "get_account_overdraft_limits":
364
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/accounts/v2/accounts/${args?.accountId}/overdraft-limits`), null, 2) }] };
213
365
  case "get_consent":
214
366
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/consents/v2/consents/${args?.consentId}`), null, 2) }] };
215
367
  case "create_consent": {
@@ -223,6 +375,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
223
375
  };
224
376
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/consents/v2/consents", payload), null, 2) }] };
225
377
  }
378
+ case "revoke_consent": {
379
+ const consentType = args?.consentType || "data";
380
+ const path = consentType === "payment"
381
+ ? `/open-banking/payments/v3/consents/${args?.consentId}`
382
+ : `/open-banking/consents/v2/consents/${args?.consentId}`;
383
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("DELETE", path), null, 2) }] };
384
+ }
226
385
  case "list_credit_cards": {
227
386
  const params = new URLSearchParams();
228
387
  if (args?.page)
@@ -231,6 +390,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
231
390
  params.set("page-size", String(args.pageSize));
232
391
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts?${params}`), null, 2) }] };
233
392
  }
393
+ case "get_credit_card_bills": {
394
+ const params = new URLSearchParams();
395
+ if (args?.fromDueDate)
396
+ params.set("fromDueDate", String(args.fromDueDate));
397
+ if (args?.toDueDate)
398
+ params.set("toDueDate", String(args.toDueDate));
399
+ if (args?.page)
400
+ params.set("page", String(args.page));
401
+ if (args?.pageSize)
402
+ params.set("page-size", String(args.pageSize));
403
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts/${args?.creditCardAccountId}/bills?${params}`), null, 2) }] };
404
+ }
234
405
  case "get_credit_card_transactions": {
235
406
  const params = new URLSearchParams();
236
407
  if (args?.fromDate)
@@ -243,6 +414,30 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
243
414
  params.set("page-size", String(args.pageSize));
244
415
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts/${args?.creditCardAccountId}/transactions?${params}`), null, 2) }] };
245
416
  }
417
+ case "list_loans": {
418
+ const params = new URLSearchParams();
419
+ if (args?.page)
420
+ params.set("page", String(args.page));
421
+ if (args?.pageSize)
422
+ params.set("page-size", String(args.pageSize));
423
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/loans/v2/contracts?${params}`), null, 2) }] };
424
+ }
425
+ case "get_loan_payments": {
426
+ const params = new URLSearchParams();
427
+ if (args?.page)
428
+ params.set("page", String(args.page));
429
+ if (args?.pageSize)
430
+ params.set("page-size", String(args.pageSize));
431
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/loans/v2/contracts/${args?.contractId}/payments?${params}`), null, 2) }] };
432
+ }
433
+ case "list_financings": {
434
+ const params = new URLSearchParams();
435
+ if (args?.page)
436
+ params.set("page", String(args.page));
437
+ if (args?.pageSize)
438
+ params.set("page-size", String(args.pageSize));
439
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/financings/v2/contracts?${params}`), null, 2) }] };
440
+ }
246
441
  case "list_investments": {
247
442
  const investmentType = args?.investmentType || "BANK_FIXED_INCOMES";
248
443
  const params = new URLSearchParams();
@@ -252,6 +447,51 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
252
447
  params.set("page-size", String(args.pageSize));
253
448
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/investments/v1/${investmentType.toLowerCase().replace(/_/g, "-")}?${params}`), null, 2) }] };
254
449
  }
450
+ case "create_payment_consent": {
451
+ const payload = {
452
+ data: {
453
+ loggedUser: { document: { identification: args?.loggedUserCpf, rel: "CPF" } },
454
+ creditor: {
455
+ personType: String(args?.creditorCpfCnpj).length > 11 ? "PESSOA_JURIDICA" : "PESSOA_NATURAL",
456
+ cpfCnpj: args?.creditorCpfCnpj,
457
+ name: args?.creditorName,
458
+ },
459
+ payment: {
460
+ type: args?.paymentType || "PIX",
461
+ currency: args?.paymentCurrency || "BRL",
462
+ amount: args?.paymentAmount,
463
+ details: { localInstrument: args?.localInstrument || "DICT" },
464
+ },
465
+ expirationDateTime: args?.expirationDateTime,
466
+ },
467
+ };
468
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/payments/v3/consents", payload), null, 2) }] };
469
+ }
470
+ case "create_payment": {
471
+ const payload = {
472
+ data: {
473
+ consentId: args?.consentId,
474
+ creditorAccount: {
475
+ ispb: args?.creditorAccountIspb,
476
+ issuer: args?.creditorAccountIssuer,
477
+ number: args?.creditorAccountNumber,
478
+ accountType: args?.creditorAccountType,
479
+ },
480
+ payment: {
481
+ currency: args?.paymentCurrency || "BRL",
482
+ amount: args?.paymentAmount,
483
+ },
484
+ remittanceInformation: args?.remittanceInformation,
485
+ qrCode: args?.qrCode,
486
+ proxy: args?.proxy,
487
+ },
488
+ };
489
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/payments/v3/pix/payments", payload), null, 2) }] };
490
+ }
491
+ case "get_personal_qualifications":
492
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", "/open-banking/customers/v2/personal/qualifications"), null, 2) }] };
493
+ case "get_business_qualifications":
494
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", "/open-banking/customers/v2/business/qualifications"), null, 2) }] };
255
495
  default:
256
496
  return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
257
497
  }
@@ -278,7 +518,7 @@ async function main() {
278
518
  const t = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID(), onsessioninitialized: (id) => { transports.set(id, t); } });
279
519
  t.onclose = () => { if (t.sessionId)
280
520
  transports.delete(t.sessionId); };
281
- const s = new Server({ name: "mcp-open-finance", version: "0.1.0" }, { capabilities: { tools: {} } });
521
+ const s = new Server({ name: "mcp-open-finance", version: "0.2.0" }, { capabilities: { tools: {} } });
282
522
  server._requestHandlers.forEach((v, k) => s._requestHandlers.set(k, v));
283
523
  server._notificationHandlers?.forEach((v, k) => s._notificationHandlers.set(k, v));
284
524
  await s.connect(t);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codespar/mcp-open-finance",
3
- "version": "0.1.2",
4
- "description": "MCP server for Open Finance Brasil — accounts, transactions, consents, investments",
3
+ "version": "0.2.0",
4
+ "description": "MCP server for Open Finance Brasil — accounts, transactions, consents, credit cards, loans, financings, investments, payment-initiation, customer qualifications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "bin": {
package/server.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.codespar/mcp-open-finance",
4
- "description": "MCP server for Open Finance Brasil — accounts, transactions, consents, investments",
4
+ "description": "MCP server for Open Finance Brasil — accounts, transactions, consents, credit cards, loans, financings, investments, payment-initiation, customer qualifications",
5
5
  "repository": {
6
6
  "url": "https://github.com/codespar/mcp-dev-brasil",
7
7
  "source": "github",
8
8
  "subfolder": "packages/banking/open-finance"
9
9
  },
10
- "version": "0.1.2",
10
+ "version": "0.2.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "@codespar/mcp-open-finance",
15
- "version": "0.1.2",
15
+ "version": "0.2.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
package/src/index.ts CHANGED
@@ -7,11 +7,21 @@
7
7
  * - list_accounts: List customer accounts
8
8
  * - get_account_balance: Get account balance
9
9
  * - list_transactions: List account transactions
10
+ * - get_account_overdraft_limits: Get account overdraft limits
10
11
  * - get_consent: Get consent details
11
12
  * - create_consent: Create a new consent request
13
+ * - revoke_consent: Revoke an existing consent
12
14
  * - list_credit_cards: List credit card accounts
15
+ * - get_credit_card_bills: Get credit card bills
13
16
  * - get_credit_card_transactions: Get credit card transactions
17
+ * - list_loans: List loan contracts
18
+ * - get_loan_payments: Get loan payment schedule
19
+ * - list_financings: List financing contracts
14
20
  * - list_investments: List investment products
21
+ * - create_payment_consent: Create payment-initiation consent
22
+ * - create_payment: Initiate a payment
23
+ * - get_personal_qualifications: Get personal customer qualifications
24
+ * - get_business_qualifications: Get business customer qualifications
15
25
  *
16
26
  * Environment:
17
27
  * OPEN_FINANCE_BASE_URL — Institution API base URL
@@ -45,7 +55,7 @@ async function getAccessToken(): Promise<string> {
45
55
  grant_type: "client_credentials",
46
56
  client_id: CLIENT_ID,
47
57
  client_secret: CLIENT_SECRET,
48
- scope: "openid accounts credit-cards-accounts resources consents investments",
58
+ scope: "openid accounts credit-cards-accounts resources consents investments loans financings customers payments",
49
59
  }),
50
60
  });
51
61
  if (!res.ok) {
@@ -76,7 +86,7 @@ async function openFinanceRequest(method: string, path: string, body?: unknown):
76
86
  }
77
87
 
78
88
  const server = new Server(
79
- { name: "mcp-open-finance", version: "0.1.0" },
89
+ { name: "mcp-open-finance", version: "0.2.0" },
80
90
  { capabilities: { tools: {} } }
81
91
  );
82
92
 
@@ -123,6 +133,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
123
133
  required: ["consentId", "accountId"],
124
134
  },
125
135
  },
136
+ {
137
+ name: "get_account_overdraft_limits",
138
+ description: "Get account overdraft (limites) via Open Finance",
139
+ inputSchema: {
140
+ type: "object",
141
+ properties: {
142
+ consentId: { type: "string", description: "Consent ID" },
143
+ accountId: { type: "string", description: "Account ID" },
144
+ },
145
+ required: ["consentId", "accountId"],
146
+ },
147
+ },
126
148
  {
127
149
  name: "get_consent",
128
150
  description: "Get consent details by ID",
@@ -152,6 +174,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
152
174
  required: ["permissions", "expirationDateTime"],
153
175
  },
154
176
  },
177
+ {
178
+ name: "revoke_consent",
179
+ description: "Revoke an existing consent (data or payment)",
180
+ inputSchema: {
181
+ type: "object",
182
+ properties: {
183
+ consentId: { type: "string", description: "Consent ID to revoke" },
184
+ consentType: { type: "string", enum: ["data", "payment"], description: "Consent type (default: data)" },
185
+ },
186
+ required: ["consentId"],
187
+ },
188
+ },
155
189
  {
156
190
  name: "list_credit_cards",
157
191
  description: "List credit card accounts via Open Finance",
@@ -165,6 +199,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
165
199
  required: ["consentId"],
166
200
  },
167
201
  },
202
+ {
203
+ name: "get_credit_card_bills",
204
+ description: "Get credit card bills (faturas) via Open Finance",
205
+ inputSchema: {
206
+ type: "object",
207
+ properties: {
208
+ consentId: { type: "string", description: "Consent ID" },
209
+ creditCardAccountId: { type: "string", description: "Credit card account ID" },
210
+ fromDueDate: { type: "string", description: "Start due date (YYYY-MM-DD)" },
211
+ toDueDate: { type: "string", description: "End due date (YYYY-MM-DD)" },
212
+ page: { type: "number", description: "Page number" },
213
+ pageSize: { type: "number", description: "Items per page" },
214
+ },
215
+ required: ["consentId", "creditCardAccountId"],
216
+ },
217
+ },
168
218
  {
169
219
  name: "get_credit_card_transactions",
170
220
  description: "Get credit card transactions via Open Finance",
@@ -181,6 +231,46 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
181
231
  required: ["consentId", "creditCardAccountId"],
182
232
  },
183
233
  },
234
+ {
235
+ name: "list_loans",
236
+ description: "List loan contracts (empréstimos) via Open Finance",
237
+ inputSchema: {
238
+ type: "object",
239
+ properties: {
240
+ consentId: { type: "string", description: "Consent ID" },
241
+ page: { type: "number", description: "Page number" },
242
+ pageSize: { type: "number", description: "Items per page" },
243
+ },
244
+ required: ["consentId"],
245
+ },
246
+ },
247
+ {
248
+ name: "get_loan_payments",
249
+ description: "Get loan payment schedule via Open Finance",
250
+ inputSchema: {
251
+ type: "object",
252
+ properties: {
253
+ consentId: { type: "string", description: "Consent ID" },
254
+ contractId: { type: "string", description: "Loan contract ID" },
255
+ page: { type: "number", description: "Page number" },
256
+ pageSize: { type: "number", description: "Items per page" },
257
+ },
258
+ required: ["consentId", "contractId"],
259
+ },
260
+ },
261
+ {
262
+ name: "list_financings",
263
+ description: "List financing contracts (financiamentos) via Open Finance",
264
+ inputSchema: {
265
+ type: "object",
266
+ properties: {
267
+ consentId: { type: "string", description: "Consent ID" },
268
+ page: { type: "number", description: "Page number" },
269
+ pageSize: { type: "number", description: "Items per page" },
270
+ },
271
+ required: ["consentId"],
272
+ },
273
+ },
184
274
  {
185
275
  name: "list_investments",
186
276
  description: "List investment products via Open Finance",
@@ -195,6 +285,66 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
195
285
  required: ["consentId"],
196
286
  },
197
287
  },
288
+ {
289
+ name: "create_payment_consent",
290
+ description: "Create payment-initiation consent (e.g., PIX) via Open Finance",
291
+ inputSchema: {
292
+ type: "object",
293
+ properties: {
294
+ loggedUserCpf: { type: "string", description: "Logged user CPF" },
295
+ creditorName: { type: "string", description: "Creditor name" },
296
+ creditorCpfCnpj: { type: "string", description: "Creditor CPF/CNPJ" },
297
+ paymentAmount: { type: "string", description: "Payment amount (e.g., '100.00')" },
298
+ paymentCurrency: { type: "string", description: "ISO 4217 currency (default: BRL)" },
299
+ localInstrument: { type: "string", enum: ["MANU", "DICT", "QRDN", "QRES", "INIC"], description: "PIX local instrument (default: DICT)" },
300
+ paymentType: { type: "string", enum: ["PIX", "TED", "TEF", "BOLETO"], description: "Payment type (default: PIX)" },
301
+ expirationDateTime: { type: "string", description: "Consent expiration (ISO 8601)" },
302
+ },
303
+ required: ["loggedUserCpf", "creditorName", "creditorCpfCnpj", "paymentAmount"],
304
+ },
305
+ },
306
+ {
307
+ name: "create_payment",
308
+ description: "Initiate a payment using an authorized payment consent",
309
+ inputSchema: {
310
+ type: "object",
311
+ properties: {
312
+ consentId: { type: "string", description: "Authorized payment consent ID" },
313
+ creditorAccountIspb: { type: "string", description: "Creditor account ISPB" },
314
+ creditorAccountIssuer: { type: "string", description: "Creditor account issuer (agência)" },
315
+ creditorAccountNumber: { type: "string", description: "Creditor account number" },
316
+ creditorAccountType: { type: "string", enum: ["CACC", "SLRY", "SVGS", "TRAN"], description: "Creditor account type" },
317
+ paymentAmount: { type: "string", description: "Payment amount (e.g., '100.00')" },
318
+ paymentCurrency: { type: "string", description: "ISO 4217 currency (default: BRL)" },
319
+ remittanceInformation: { type: "string", description: "Free-text remittance info" },
320
+ qrCode: { type: "string", description: "PIX QR Code payload (optional)" },
321
+ proxy: { type: "string", description: "PIX key/proxy (optional)" },
322
+ },
323
+ required: ["consentId", "creditorAccountIspb", "creditorAccountIssuer", "creditorAccountNumber", "creditorAccountType", "paymentAmount"],
324
+ },
325
+ },
326
+ {
327
+ name: "get_personal_qualifications",
328
+ description: "Get personal customer qualifications (income, occupation) via Open Finance",
329
+ inputSchema: {
330
+ type: "object",
331
+ properties: {
332
+ consentId: { type: "string", description: "Consent ID" },
333
+ },
334
+ required: ["consentId"],
335
+ },
336
+ },
337
+ {
338
+ name: "get_business_qualifications",
339
+ description: "Get business customer qualifications via Open Finance",
340
+ inputSchema: {
341
+ type: "object",
342
+ properties: {
343
+ consentId: { type: "string", description: "Consent ID" },
344
+ },
345
+ required: ["consentId"],
346
+ },
347
+ },
198
348
  ],
199
349
  }));
200
350
 
@@ -220,6 +370,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
220
370
  if (args?.pageSize) params.set("page-size", String(args.pageSize));
221
371
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/accounts/v2/accounts/${args?.accountId}/transactions?${params}`), null, 2) }] };
222
372
  }
373
+ case "get_account_overdraft_limits":
374
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/accounts/v2/accounts/${args?.accountId}/overdraft-limits`), null, 2) }] };
223
375
  case "get_consent":
224
376
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/consents/v2/consents/${args?.consentId}`), null, 2) }] };
225
377
  case "create_consent": {
@@ -233,12 +385,27 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
233
385
  };
234
386
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/consents/v2/consents", payload), null, 2) }] };
235
387
  }
388
+ case "revoke_consent": {
389
+ const consentType = (args?.consentType as string) || "data";
390
+ const path = consentType === "payment"
391
+ ? `/open-banking/payments/v3/consents/${args?.consentId}`
392
+ : `/open-banking/consents/v2/consents/${args?.consentId}`;
393
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("DELETE", path), null, 2) }] };
394
+ }
236
395
  case "list_credit_cards": {
237
396
  const params = new URLSearchParams();
238
397
  if (args?.page) params.set("page", String(args.page));
239
398
  if (args?.pageSize) params.set("page-size", String(args.pageSize));
240
399
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts?${params}`), null, 2) }] };
241
400
  }
401
+ case "get_credit_card_bills": {
402
+ const params = new URLSearchParams();
403
+ if (args?.fromDueDate) params.set("fromDueDate", String(args.fromDueDate));
404
+ if (args?.toDueDate) params.set("toDueDate", String(args.toDueDate));
405
+ if (args?.page) params.set("page", String(args.page));
406
+ if (args?.pageSize) params.set("page-size", String(args.pageSize));
407
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts/${args?.creditCardAccountId}/bills?${params}`), null, 2) }] };
408
+ }
242
409
  case "get_credit_card_transactions": {
243
410
  const params = new URLSearchParams();
244
411
  if (args?.fromDate) params.set("fromTransactionDate", String(args.fromDate));
@@ -247,6 +414,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
247
414
  if (args?.pageSize) params.set("page-size", String(args.pageSize));
248
415
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/credit-cards-accounts/v2/accounts/${args?.creditCardAccountId}/transactions?${params}`), null, 2) }] };
249
416
  }
417
+ case "list_loans": {
418
+ const params = new URLSearchParams();
419
+ if (args?.page) params.set("page", String(args.page));
420
+ if (args?.pageSize) params.set("page-size", String(args.pageSize));
421
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/loans/v2/contracts?${params}`), null, 2) }] };
422
+ }
423
+ case "get_loan_payments": {
424
+ const params = new URLSearchParams();
425
+ if (args?.page) params.set("page", String(args.page));
426
+ if (args?.pageSize) params.set("page-size", String(args.pageSize));
427
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/loans/v2/contracts/${args?.contractId}/payments?${params}`), null, 2) }] };
428
+ }
429
+ case "list_financings": {
430
+ const params = new URLSearchParams();
431
+ if (args?.page) params.set("page", String(args.page));
432
+ if (args?.pageSize) params.set("page-size", String(args.pageSize));
433
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/financings/v2/contracts?${params}`), null, 2) }] };
434
+ }
250
435
  case "list_investments": {
251
436
  const investmentType = (args?.investmentType as string) || "BANK_FIXED_INCOMES";
252
437
  const params = new URLSearchParams();
@@ -254,6 +439,51 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
254
439
  if (args?.pageSize) params.set("page-size", String(args.pageSize));
255
440
  return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", `/open-banking/investments/v1/${investmentType.toLowerCase().replace(/_/g, "-")}?${params}`), null, 2) }] };
256
441
  }
442
+ case "create_payment_consent": {
443
+ const payload = {
444
+ data: {
445
+ loggedUser: { document: { identification: args?.loggedUserCpf, rel: "CPF" } },
446
+ creditor: {
447
+ personType: String(args?.creditorCpfCnpj).length > 11 ? "PESSOA_JURIDICA" : "PESSOA_NATURAL",
448
+ cpfCnpj: args?.creditorCpfCnpj,
449
+ name: args?.creditorName,
450
+ },
451
+ payment: {
452
+ type: (args?.paymentType as string) || "PIX",
453
+ currency: (args?.paymentCurrency as string) || "BRL",
454
+ amount: args?.paymentAmount,
455
+ details: { localInstrument: (args?.localInstrument as string) || "DICT" },
456
+ },
457
+ expirationDateTime: args?.expirationDateTime,
458
+ },
459
+ };
460
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/payments/v3/consents", payload), null, 2) }] };
461
+ }
462
+ case "create_payment": {
463
+ const payload = {
464
+ data: {
465
+ consentId: args?.consentId,
466
+ creditorAccount: {
467
+ ispb: args?.creditorAccountIspb,
468
+ issuer: args?.creditorAccountIssuer,
469
+ number: args?.creditorAccountNumber,
470
+ accountType: args?.creditorAccountType,
471
+ },
472
+ payment: {
473
+ currency: (args?.paymentCurrency as string) || "BRL",
474
+ amount: args?.paymentAmount,
475
+ },
476
+ remittanceInformation: args?.remittanceInformation,
477
+ qrCode: args?.qrCode,
478
+ proxy: args?.proxy,
479
+ },
480
+ };
481
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("POST", "/open-banking/payments/v3/pix/payments", payload), null, 2) }] };
482
+ }
483
+ case "get_personal_qualifications":
484
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", "/open-banking/customers/v2/personal/qualifications"), null, 2) }] };
485
+ case "get_business_qualifications":
486
+ return { content: [{ type: "text", text: JSON.stringify(await openFinanceRequest("GET", "/open-banking/customers/v2/business/qualifications"), null, 2) }] };
257
487
  default:
258
488
  return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
259
489
  }
@@ -276,7 +506,7 @@ async function main() {
276
506
  if (!sid && isInitializeRequest(req.body)) {
277
507
  const t = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID(), onsessioninitialized: (id) => { transports.set(id, t); } });
278
508
  t.onclose = () => { if (t.sessionId) transports.delete(t.sessionId); };
279
- const s = new Server({ name: "mcp-open-finance", version: "0.1.0" }, { capabilities: { tools: {} } }); (server as any)._requestHandlers.forEach((v: any, k: any) => (s as any)._requestHandlers.set(k, v)); (server as any)._notificationHandlers?.forEach((v: any, k: any) => (s as any)._notificationHandlers.set(k, v)); await s.connect(t);
509
+ const s = new Server({ name: "mcp-open-finance", version: "0.2.0" }, { capabilities: { tools: {} } }); (server as any)._requestHandlers.forEach((v: any, k: any) => (s as any)._requestHandlers.set(k, v)); (server as any)._notificationHandlers?.forEach((v: any, k: any) => (s as any)._notificationHandlers.set(k, v)); await s.connect(t);
280
510
  await t.handleRequest(req, res, req.body); return;
281
511
  }
282
512
  res.status(400).json({ jsonrpc: "2.0", error: { code: -32000, message: "Bad Request" }, id: null });