@codespar/mcp-afip 0.1.0 → 0.2.0-alpha.1

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.d.ts CHANGED
@@ -2,15 +2,27 @@
2
2
  /**
3
3
  * MCP Server for AFIP — Argentine tax authority, electronic invoicing (Factura Electrónica).
4
4
  *
5
- * Tools:
6
- * - create_invoice: Create an electronic invoice (Factura Electrónica)
7
- * - get_invoice: Get invoice details by type and number
8
- * - get_last_invoice_number: Get last authorized invoice number for a POS
5
+ * Tools (WSFE / WS_SR_PADRON):
6
+ * - create_invoice: Create an electronic invoice (FECAESolicitar — single)
7
+ * - create_invoice_batch: Create up to 250 invoices in a single CAE request (FECAESolicitar — batch)
8
+ * - create_credit_note: Issue a credit note (Nota de Crédito A/B/C)
9
+ * - create_debit_note: Issue a debit note (Nota de Débito A/B/C)
10
+ * - cancel_invoice: Cancel/void an authorized invoice where applicable (FECancel)
11
+ * - get_invoice: Get invoice details (FECompConsultar)
12
+ * - get_invoice_total_x_request: Max records per request (FECompTotXRequest)
13
+ * - get_last_invoice_number: Last authorized invoice number (FECompUltimoAutorizado)
9
14
  * - get_cae_status: Check CAE authorization status
10
- * - list_invoice_types: List available invoice types (A, B, C, etc.)
11
- * - list_tax_types: List available tax types (IVA, percepciones, etc.)
12
- * - get_server_status: Check AFIP web-service availability
15
+ * - list_invoice_types: Invoice types (FEParamGetTiposCbte)
16
+ * - list_concept_types: Concept types (FEParamGetTiposConcepto)
17
+ * - list_doc_types: Document types (FEParamGetTiposDoc)
18
+ * - list_iva_types: IVA aliquots (FEParamGetTiposIva)
19
+ * - list_currency_types: Currencies (FEParamGetTiposMonedas)
20
+ * - list_tax_types: Tax types (FEParamGetTiposTributos)
21
+ * - get_currency_rate: FX rate for a currency (FEParamGetCotizacion)
22
+ * - get_server_status: AFIP web-service availability
13
23
  * - get_authorized_points_of_sale: List authorized puntos de venta
24
+ * - lookup_taxpayer: Padrón lookup by CUIT (A4/A5/A13)
25
+ * - get_registration_certificate: Constancia de inscripción for a CUIT
14
26
  *
15
27
  * Environment:
16
28
  * AFIP_CERT_PATH — Path to AFIP certificate (.crt)
package/dist/index.js CHANGED
@@ -2,15 +2,27 @@
2
2
  /**
3
3
  * MCP Server for AFIP — Argentine tax authority, electronic invoicing (Factura Electrónica).
4
4
  *
5
- * Tools:
6
- * - create_invoice: Create an electronic invoice (Factura Electrónica)
7
- * - get_invoice: Get invoice details by type and number
8
- * - get_last_invoice_number: Get last authorized invoice number for a POS
5
+ * Tools (WSFE / WS_SR_PADRON):
6
+ * - create_invoice: Create an electronic invoice (FECAESolicitar — single)
7
+ * - create_invoice_batch: Create up to 250 invoices in a single CAE request (FECAESolicitar — batch)
8
+ * - create_credit_note: Issue a credit note (Nota de Crédito A/B/C)
9
+ * - create_debit_note: Issue a debit note (Nota de Débito A/B/C)
10
+ * - cancel_invoice: Cancel/void an authorized invoice where applicable (FECancel)
11
+ * - get_invoice: Get invoice details (FECompConsultar)
12
+ * - get_invoice_total_x_request: Max records per request (FECompTotXRequest)
13
+ * - get_last_invoice_number: Last authorized invoice number (FECompUltimoAutorizado)
9
14
  * - get_cae_status: Check CAE authorization status
10
- * - list_invoice_types: List available invoice types (A, B, C, etc.)
11
- * - list_tax_types: List available tax types (IVA, percepciones, etc.)
12
- * - get_server_status: Check AFIP web-service availability
15
+ * - list_invoice_types: Invoice types (FEParamGetTiposCbte)
16
+ * - list_concept_types: Concept types (FEParamGetTiposConcepto)
17
+ * - list_doc_types: Document types (FEParamGetTiposDoc)
18
+ * - list_iva_types: IVA aliquots (FEParamGetTiposIva)
19
+ * - list_currency_types: Currencies (FEParamGetTiposMonedas)
20
+ * - list_tax_types: Tax types (FEParamGetTiposTributos)
21
+ * - get_currency_rate: FX rate for a currency (FEParamGetCotizacion)
22
+ * - get_server_status: AFIP web-service availability
13
23
  * - get_authorized_points_of_sale: List authorized puntos de venta
24
+ * - lookup_taxpayer: Padrón lookup by CUIT (A4/A5/A13)
25
+ * - get_registration_certificate: Constancia de inscripción for a CUIT
14
26
  *
15
27
  * Environment:
16
28
  * AFIP_CERT_PATH — Path to AFIP certificate (.crt)
@@ -48,7 +60,7 @@ async function afipRequest(method, path, body) {
48
60
  }
49
61
  return res.json();
50
62
  }
51
- const server = new Server({ name: "mcp-afip", version: "0.1.0" }, { capabilities: { tools: {} } });
63
+ const server = new Server({ name: "mcp-afip", version: "0.2.0-alpha.1" }, { capabilities: { tools: {} } });
52
64
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
53
65
  tools: [
54
66
  {
@@ -142,6 +154,168 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
142
154
  description: "List authorized puntos de venta for the CUIT",
143
155
  inputSchema: { type: "object", properties: {} },
144
156
  },
157
+ {
158
+ name: "create_invoice_batch",
159
+ description: "Create a batch of invoices in a single CAE request (FECAESolicitar, up to 250)",
160
+ inputSchema: {
161
+ type: "object",
162
+ properties: {
163
+ point_of_sale: { type: "number", description: "Punto de venta number" },
164
+ invoice_type: { type: "number", description: "Invoice type code (1=A, 6=B, 11=C, etc.)" },
165
+ invoices: {
166
+ type: "array",
167
+ description: "Invoice records (max 250 per request)",
168
+ items: {
169
+ type: "object",
170
+ properties: {
171
+ concept: { type: "number", description: "Concept (1=Products, 2=Services, 3=Both)" },
172
+ doc_type: { type: "number", description: "Document type" },
173
+ doc_number: { type: "number", description: "Document number" },
174
+ invoice_number: { type: "number", description: "CbteDesde/CbteHasta number" },
175
+ amount_total: { type: "number", description: "Total amount" },
176
+ amount_net: { type: "number", description: "Net taxable amount" },
177
+ amount_iva: { type: "number", description: "IVA amount" },
178
+ currency: { type: "string", description: "Currency code (PES=ARS, DOL=USD)" },
179
+ },
180
+ required: ["concept", "doc_type", "doc_number", "invoice_number", "amount_total"],
181
+ },
182
+ },
183
+ },
184
+ required: ["point_of_sale", "invoice_type", "invoices"],
185
+ },
186
+ },
187
+ {
188
+ name: "create_credit_note",
189
+ description: "Issue a credit note (Nota de Crédito A/B/C: types 3, 8, 13) referencing an original invoice",
190
+ inputSchema: {
191
+ type: "object",
192
+ properties: {
193
+ point_of_sale: { type: "number", description: "Punto de venta number" },
194
+ note_type: { type: "number", description: "Credit note type (3=A, 8=B, 13=C)" },
195
+ concept: { type: "number", description: "Concept (1=Products, 2=Services, 3=Both)" },
196
+ doc_type: { type: "number", description: "Customer document type" },
197
+ doc_number: { type: "number", description: "Customer document number" },
198
+ amount_total: { type: "number", description: "Total amount" },
199
+ amount_net: { type: "number", description: "Net taxable amount" },
200
+ amount_iva: { type: "number", description: "IVA amount" },
201
+ currency: { type: "string", description: "Currency code" },
202
+ related_invoice: {
203
+ type: "object",
204
+ description: "Original invoice reference (CbtesAsoc)",
205
+ properties: {
206
+ invoice_type: { type: "number", description: "Original invoice type" },
207
+ point_of_sale: { type: "number", description: "Original punto de venta" },
208
+ invoice_number: { type: "number", description: "Original invoice number" },
209
+ },
210
+ required: ["invoice_type", "point_of_sale", "invoice_number"],
211
+ },
212
+ },
213
+ required: ["point_of_sale", "note_type", "concept", "doc_type", "doc_number", "amount_total", "related_invoice"],
214
+ },
215
+ },
216
+ {
217
+ name: "create_debit_note",
218
+ description: "Issue a debit note (Nota de Débito A/B/C: types 2, 7, 12) referencing an original invoice",
219
+ inputSchema: {
220
+ type: "object",
221
+ properties: {
222
+ point_of_sale: { type: "number", description: "Punto de venta number" },
223
+ note_type: { type: "number", description: "Debit note type (2=A, 7=B, 12=C)" },
224
+ concept: { type: "number", description: "Concept (1=Products, 2=Services, 3=Both)" },
225
+ doc_type: { type: "number", description: "Customer document type" },
226
+ doc_number: { type: "number", description: "Customer document number" },
227
+ amount_total: { type: "number", description: "Total amount" },
228
+ amount_net: { type: "number", description: "Net taxable amount" },
229
+ amount_iva: { type: "number", description: "IVA amount" },
230
+ currency: { type: "string", description: "Currency code" },
231
+ related_invoice: {
232
+ type: "object",
233
+ description: "Original invoice reference (CbtesAsoc)",
234
+ properties: {
235
+ invoice_type: { type: "number", description: "Original invoice type" },
236
+ point_of_sale: { type: "number", description: "Original punto de venta" },
237
+ invoice_number: { type: "number", description: "Original invoice number" },
238
+ },
239
+ required: ["invoice_type", "point_of_sale", "invoice_number"],
240
+ },
241
+ },
242
+ required: ["point_of_sale", "note_type", "concept", "doc_type", "doc_number", "amount_total", "related_invoice"],
243
+ },
244
+ },
245
+ {
246
+ name: "cancel_invoice",
247
+ description: "Cancel/void an authorized invoice (FECancel — limited to certain types/conditions)",
248
+ inputSchema: {
249
+ type: "object",
250
+ properties: {
251
+ point_of_sale: { type: "number", description: "Punto de venta number" },
252
+ invoice_type: { type: "number", description: "Invoice type code" },
253
+ invoice_number: { type: "number", description: "Invoice number" },
254
+ reason: { type: "string", description: "Optional cancellation reason" },
255
+ },
256
+ required: ["point_of_sale", "invoice_type", "invoice_number"],
257
+ },
258
+ },
259
+ {
260
+ name: "get_invoice_total_x_request",
261
+ description: "Max number of records allowed per FECAESolicitar request (FECompTotXRequest)",
262
+ inputSchema: { type: "object", properties: {} },
263
+ },
264
+ {
265
+ name: "list_concept_types",
266
+ description: "List available concept types (FEParamGetTiposConcepto: 1=Products, 2=Services, 3=Both)",
267
+ inputSchema: { type: "object", properties: {} },
268
+ },
269
+ {
270
+ name: "list_doc_types",
271
+ description: "List document/identifier types (FEParamGetTiposDoc: 80=CUIT, 86=CUIL, 96=DNI, 99=Consumer Final)",
272
+ inputSchema: { type: "object", properties: {} },
273
+ },
274
+ {
275
+ name: "list_iva_types",
276
+ description: "List IVA tax aliquots (FEParamGetTiposIva: 21%, 10.5%, 27%, 0%, etc.)",
277
+ inputSchema: { type: "object", properties: {} },
278
+ },
279
+ {
280
+ name: "list_currency_types",
281
+ description: "List supported currencies (FEParamGetTiposMonedas)",
282
+ inputSchema: { type: "object", properties: {} },
283
+ },
284
+ {
285
+ name: "get_currency_rate",
286
+ description: "Get FX rate (cotización) for a currency vs ARS (FEParamGetCotizacion)",
287
+ inputSchema: {
288
+ type: "object",
289
+ properties: {
290
+ currency: { type: "string", description: "Currency code (e.g. DOL for USD)" },
291
+ date: { type: "string", description: "Optional date YYYYMMDD; defaults to last business day" },
292
+ },
293
+ required: ["currency"],
294
+ },
295
+ },
296
+ {
297
+ name: "lookup_taxpayer",
298
+ description: "Padrón lookup by CUIT (WS_SR_PADRON A4/A5/A13 — fiscal status, name, address)",
299
+ inputSchema: {
300
+ type: "object",
301
+ properties: {
302
+ cuit: { type: "string", description: "CUIT/CUIL to query (11 digits)" },
303
+ scope: { type: "string", description: "Padrón scope: A4, A5, or A13 (default A5)" },
304
+ },
305
+ required: ["cuit"],
306
+ },
307
+ },
308
+ {
309
+ name: "get_registration_certificate",
310
+ description: "Get constancia de inscripción (registration certificate) for a CUIT",
311
+ inputSchema: {
312
+ type: "object",
313
+ properties: {
314
+ cuit: { type: "string", description: "CUIT/CUIL (11 digits)" },
315
+ },
316
+ required: ["cuit"],
317
+ },
318
+ },
145
319
  ],
146
320
  }));
147
321
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
@@ -181,6 +355,80 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
181
355
  return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/status"), null, 2) }] };
182
356
  case "get_authorized_points_of_sale":
183
357
  return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/points-of-sale"), null, 2) }] };
358
+ case "create_invoice_batch": {
359
+ const payload = {
360
+ point_of_sale: args?.point_of_sale,
361
+ invoice_type: args?.invoice_type,
362
+ invoices: args?.invoices,
363
+ };
364
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("POST", "/wsfe/invoices/batch", payload), null, 2) }] };
365
+ }
366
+ case "create_credit_note": {
367
+ const payload = {
368
+ point_of_sale: args?.point_of_sale,
369
+ note_type: args?.note_type,
370
+ concept: args?.concept,
371
+ doc_type: args?.doc_type,
372
+ doc_number: args?.doc_number,
373
+ amount_total: args?.amount_total,
374
+ related_invoice: args?.related_invoice,
375
+ };
376
+ if (args?.amount_net)
377
+ payload.amount_net = args.amount_net;
378
+ if (args?.amount_iva)
379
+ payload.amount_iva = args.amount_iva;
380
+ if (args?.currency)
381
+ payload.currency = args.currency;
382
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("POST", "/wsfe/credit-notes", payload), null, 2) }] };
383
+ }
384
+ case "create_debit_note": {
385
+ const payload = {
386
+ point_of_sale: args?.point_of_sale,
387
+ note_type: args?.note_type,
388
+ concept: args?.concept,
389
+ doc_type: args?.doc_type,
390
+ doc_number: args?.doc_number,
391
+ amount_total: args?.amount_total,
392
+ related_invoice: args?.related_invoice,
393
+ };
394
+ if (args?.amount_net)
395
+ payload.amount_net = args.amount_net;
396
+ if (args?.amount_iva)
397
+ payload.amount_iva = args.amount_iva;
398
+ if (args?.currency)
399
+ payload.currency = args.currency;
400
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("POST", "/wsfe/debit-notes", payload), null, 2) }] };
401
+ }
402
+ case "cancel_invoice": {
403
+ const payload = {
404
+ point_of_sale: args?.point_of_sale,
405
+ invoice_type: args?.invoice_type,
406
+ invoice_number: args?.invoice_number,
407
+ };
408
+ if (args?.reason)
409
+ payload.reason = args.reason;
410
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("POST", "/wsfe/cancel", payload), null, 2) }] };
411
+ }
412
+ case "get_invoice_total_x_request":
413
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/total-x-request"), null, 2) }] };
414
+ case "list_concept_types":
415
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/concept-types"), null, 2) }] };
416
+ case "list_doc_types":
417
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/doc-types"), null, 2) }] };
418
+ case "list_iva_types":
419
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/iva-types"), null, 2) }] };
420
+ case "list_currency_types":
421
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", "/wsfe/currency-types"), null, 2) }] };
422
+ case "get_currency_rate": {
423
+ const qs = args?.date ? `?date=${encodeURIComponent(String(args.date))}` : "";
424
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", `/wsfe/currency-rate/${encodeURIComponent(String(args?.currency))}${qs}`), null, 2) }] };
425
+ }
426
+ case "lookup_taxpayer": {
427
+ const scope = args?.scope || "A5";
428
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", `/padron/${encodeURIComponent(scope)}/${encodeURIComponent(String(args?.cuit))}`), null, 2) }] };
429
+ }
430
+ case "get_registration_certificate":
431
+ return { content: [{ type: "text", text: JSON.stringify(await afipRequest("GET", `/padron/constancia/${encodeURIComponent(String(args?.cuit))}`), null, 2) }] };
184
432
  default:
185
433
  return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
186
434
  }
@@ -207,7 +455,7 @@ async function main() {
207
455
  const t = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID(), onsessioninitialized: (id) => { transports.set(id, t); } });
208
456
  t.onclose = () => { if (t.sessionId)
209
457
  transports.delete(t.sessionId); };
210
- const s = new Server({ name: "mcp-afip", version: "0.1.0" }, { capabilities: { tools: {} } });
458
+ const s = new Server({ name: "mcp-afip", version: "0.2.0-alpha.1" }, { capabilities: { tools: {} } });
211
459
  server._requestHandlers.forEach((v, k) => s._requestHandlers.set(k, v));
212
460
  server._notificationHandlers?.forEach((v, k) => s._notificationHandlers.set(k, v));
213
461
  await s.connect(t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codespar/mcp-afip",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-alpha.1",
4
4
  "description": "MCP server for AFIP — Argentine tax authority, electronic invoicing (Factura Electrónica)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",