@fiscalapi/docs-mcp 0.0.0-stage → 4.0.461
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/LICENSE +373 -0
- package/README.md +92 -2
- package/data/docs-index.json +1 -0
- package/data/operations/calculateInvoice.json +1 -0
- package/data/operations/cancelInvoice.json +1 -0
- package/data/operations/cancelTicket.json +1 -0
- package/data/operations/createApiKey.json +1 -0
- package/data/operations/createDownloadRequest.json +1 -0
- package/data/operations/createDownloadRule.json +1 -0
- package/data/operations/createDownloadRuleTestRequest.json +1 -0
- package/data/operations/createEmployeeData.json +1 -0
- package/data/operations/createEmployerData.json +1 -0
- package/data/operations/createInvoice.json +1 -0
- package/data/operations/createPerson.json +1 -0
- package/data/operations/createProduct.json +1 -0
- package/data/operations/createTaxFile.json +1 -0
- package/data/operations/createTicket.json +1 -0
- package/data/operations/createWebhook.json +1 -0
- package/data/operations/deleteDownloadRequest.json +1 -0
- package/data/operations/deleteDownloadRule.json +1 -0
- package/data/operations/deleteEmployeeData.json +1 -0
- package/data/operations/deleteEmployerData.json +1 -0
- package/data/operations/deletePerson.json +1 -0
- package/data/operations/deleteProduct.json +1 -0
- package/data/operations/deleteTaxFile.json +1 -0
- package/data/operations/deleteWebhook.json +1 -0
- package/data/operations/downloadPortalTicketInvoice.json +1 -0
- package/data/operations/getApiKey.json +1 -0
- package/data/operations/getAutoInvoiceConsumptionReport.json +1 -0
- package/data/operations/getAutoInvoicePortalName.json +1 -0
- package/data/operations/getAutoInvoicePortalNameAvailability.json +1 -0
- package/data/operations/getAutoInvoiceSettings.json +1 -0
- package/data/operations/getCatalogRecord.json +1 -0
- package/data/operations/getDownloadRequest.json +1 -0
- package/data/operations/getDownloadRequestPackage.json +1 -0
- package/data/operations/getDownloadRequestRawRequest.json +1 -0
- package/data/operations/getDownloadRequestRawResponse.json +1 -0
- package/data/operations/getDownloadRule.json +1 -0
- package/data/operations/getEmployeeData.json +1 -0
- package/data/operations/getEmployerData.json +1 -0
- package/data/operations/getEvent.json +1 -0
- package/data/operations/getInvoice.json +1 -0
- package/data/operations/getInvoicePdf.json +1 -0
- package/data/operations/getInvoiceStatus.json +1 -0
- package/data/operations/getInvoiceXml.json +1 -0
- package/data/operations/getPerson.json +1 -0
- package/data/operations/getPortalBranding.json +1 -0
- package/data/operations/getPortalTicket.json +1 -0
- package/data/operations/getProduct.json +1 -0
- package/data/operations/getSatValidationType.json +1 -0
- package/data/operations/getStampTransaction.json +1 -0
- package/data/operations/getTaxFile.json +1 -0
- package/data/operations/getTaxFileDefaultValues.json +1 -0
- package/data/operations/getTicket.json +1 -0
- package/data/operations/getTicketCode.json +1 -0
- package/data/operations/getWebhook.json +1 -0
- package/data/operations/invoicePortalTicket.json +1 -0
- package/data/operations/listApiKeys.json +1 -0
- package/data/operations/listCatalogs.json +1 -0
- package/data/operations/listDownloadCatalogRecords.json +1 -0
- package/data/operations/listDownloadCatalogs.json +1 -0
- package/data/operations/listDownloadRequestMetaItems.json +1 -0
- package/data/operations/listDownloadRequestWithholdingPackages.json +1 -0
- package/data/operations/listDownloadRequestXmls.json +1 -0
- package/data/operations/listDownloadRequests.json +1 -0
- package/data/operations/listDownloadRules.json +1 -0
- package/data/operations/listEvents.json +1 -0
- package/data/operations/listInvoices.json +1 -0
- package/data/operations/listPeople.json +1 -0
- package/data/operations/listPortalCfdiUses.json +1 -0
- package/data/operations/listPortalTaxRegimes.json +1 -0
- package/data/operations/listProductTaxes.json +1 -0
- package/data/operations/listProducts.json +1 -0
- package/data/operations/listSatValidationTypeStatuses.json +1 -0
- package/data/operations/listSatValidationTypes.json +1 -0
- package/data/operations/listStampTransactions.json +1 -0
- package/data/operations/listTaxFiles.json +1 -0
- package/data/operations/listTickets.json +1 -0
- package/data/operations/listWebhookDeliveries.json +1 -0
- package/data/operations/listWebhooks.json +1 -0
- package/data/operations/patchPerson.json +1 -0
- package/data/operations/recoverPortalTicketInvoice.json +1 -0
- package/data/operations/resendEvent.json +1 -0
- package/data/operations/resendPortalTicketInvoice.json +1 -0
- package/data/operations/revokeApiKey.json +1 -0
- package/data/operations/rotateWebhookSecret.json +1 -0
- package/data/operations/runSatValidations.json +1 -0
- package/data/operations/searchCatalogRecords.json +1 -0
- package/data/operations/searchDownloadRequests.json +1 -0
- package/data/operations/sendInvoice.json +1 -0
- package/data/operations/signManifest.json +1 -0
- package/data/operations/testWebhook.json +1 -0
- package/data/operations/transferStamps.json +1 -0
- package/data/operations/triggerEvent.json +1 -0
- package/data/operations/updateApiKey.json +1 -0
- package/data/operations/updateAutoInvoicePortalName.json +1 -0
- package/data/operations/updateAutoInvoiceSettings.json +1 -0
- package/data/operations/updateDownloadRule.json +1 -0
- package/data/operations/updateEmployeeData.json +1 -0
- package/data/operations/updateEmployerData.json +1 -0
- package/data/operations/updatePerson.json +1 -0
- package/data/operations/updateProduct.json +1 -0
- package/data/operations/updateWebhook.json +1 -0
- package/data/operations.json +1 -0
- package/data/source.json +12 -0
- package/dist/api-operations.js +55 -0
- package/dist/data-files.js +22 -0
- package/dist/docs-index-options.js +29 -0
- package/dist/docs-index.js +35 -0
- package/dist/excerpt.js +54 -0
- package/dist/index.js +25 -0
- package/dist/operation-suggestions.js +37 -0
- package/dist/server.js +17 -0
- package/dist/tools/get-operation-tool.js +34 -0
- package/dist/tools/list-operations-tool.js +40 -0
- package/dist/tools/mcp-tool.js +1 -0
- package/dist/tools/search-docs-tool.js +55 -0
- package/dist/tools/tool-conventions.js +14 -0
- package/dist/tools/tool-results.js +6 -0
- package/package.json +62 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { API_SPECIFICATION_NOTICE, MAX_IDENTIFIER_CHARS, READ_ONLY_ANNOTATIONS, TOOL_NAMES } from './tool-conventions.js';
|
|
3
|
+
import { errorResult, textResult } from './tool-results.js';
|
|
4
|
+
export class ListOperationsTool {
|
|
5
|
+
#operations;
|
|
6
|
+
constructor(operations) {
|
|
7
|
+
this.#operations = operations;
|
|
8
|
+
}
|
|
9
|
+
register(server) {
|
|
10
|
+
server.registerTool(TOOL_NAMES.listOperations, {
|
|
11
|
+
title: 'Listar las operaciones de la API de FiscalAPI',
|
|
12
|
+
description: 'Devuelve las operaciones de la API REST de FiscalAPI (CFDI/Factura 4.0 y complementos, cancelación, descarga masiva del SAT, personas, productos, certificados, webhooks y más), agrupadas por tag, con operationId, método HTTP, ruta y resumen. ' +
|
|
13
|
+
`Úsala para encontrar la operación que necesitas; después llama a ${TOOL_NAMES.getOperation} con su operationId. ${API_SPECIFICATION_NOTICE}`,
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
tag: z
|
|
16
|
+
.string()
|
|
17
|
+
.max(MAX_IDENTIFIER_CHARS)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(`Tag por el que filtrar, sin distinguir mayúsculas. Valores: ${this.#operations.tags.join(', ')}. Omítelo para listar todas.`),
|
|
20
|
+
}),
|
|
21
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
22
|
+
}, ({ tag }) => this.#listOperations(tag));
|
|
23
|
+
}
|
|
24
|
+
#listOperations(tag) {
|
|
25
|
+
const operations = this.#operations.list(tag);
|
|
26
|
+
if (operations.length === 0) {
|
|
27
|
+
return errorResult(`No hay operaciones con el tag "${tag ?? ''}". Tags disponibles: ${this.#operations.tags.join(', ')}.`);
|
|
28
|
+
}
|
|
29
|
+
const header = `FiscalAPI: ${operations.length} operaciones. Para ver el contrato de una, llama a ${TOOL_NAMES.getOperation} con su operationId.`;
|
|
30
|
+
return textResult([header, ...linesGroupedByTag(operations)].join('\n'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function linesGroupedByTag(operations) {
|
|
34
|
+
const groups = Map.groupBy(operations, (operation) => operation.tag);
|
|
35
|
+
return [...groups].flatMap(([tag, taggedOperations]) => [
|
|
36
|
+
'',
|
|
37
|
+
`## ${tag}`,
|
|
38
|
+
...taggedOperations.map(({ operationId, method, path, summary }) => `${operationId} ${method} ${path} ${summary}`),
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { MAX_IDENTIFIER_CHARS, PUBLIC_DOCS_NOTICE, READ_ONLY_ANNOTATIONS, TOOL_NAMES } from './tool-conventions.js';
|
|
3
|
+
import { textResult } from './tool-results.js';
|
|
4
|
+
export const SEARCH_LIMITS = {
|
|
5
|
+
maxQueryChars: 200,
|
|
6
|
+
maxEchoedQueryChars: MAX_IDENTIFIER_CHARS,
|
|
7
|
+
maxResults: 10,
|
|
8
|
+
defaultResults: 5,
|
|
9
|
+
};
|
|
10
|
+
const inputSchema = z.object({
|
|
11
|
+
query: z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(SEARCH_LIMITS.maxQueryChars)
|
|
15
|
+
.describe('Qué buscar, en español o por código (por ejemplo "cancelar factura", "complemento de pago" o "CFDI40147").'),
|
|
16
|
+
limit: z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.min(1)
|
|
20
|
+
.max(SEARCH_LIMITS.maxResults)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe(`Número máximo de resultados, de 1 a ${SEARCH_LIMITS.maxResults}. Por omisión, ${SEARCH_LIMITS.defaultResults}.`),
|
|
23
|
+
});
|
|
24
|
+
export class SearchDocsTool {
|
|
25
|
+
#docs;
|
|
26
|
+
constructor(docs) {
|
|
27
|
+
this.#docs = docs;
|
|
28
|
+
}
|
|
29
|
+
register(server) {
|
|
30
|
+
server.registerTool(TOOL_NAMES.searchDocs, {
|
|
31
|
+
title: 'Buscar en la documentación de FiscalAPI',
|
|
32
|
+
description: 'Busca en las secciones de docs.fiscalapi.com: guías, reglas fiscales del SAT, catálogos SAT, errores de validación y rechazos del PAC por código (por ejemplo CFDI40147) y la referencia de cada operación. ' +
|
|
33
|
+
'Devuelve por resultado el título, la página, la URL .md de la sección y un extracto. ' +
|
|
34
|
+
`Úsala para saber qué regla aplica, qué significa un error o qué valor de catálogo usar; para leer la sección completa, descarga su URL .md. ${PUBLIC_DOCS_NOTICE}`,
|
|
35
|
+
inputSchema,
|
|
36
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
37
|
+
}, ({ query, limit }) => this.#searchDocs(query, limit ?? SEARCH_LIMITS.defaultResults));
|
|
38
|
+
}
|
|
39
|
+
#searchDocs(query, limit) {
|
|
40
|
+
const results = this.#docs.search(query, limit);
|
|
41
|
+
const echoedQuery = echo(query);
|
|
42
|
+
if (results.length === 0) {
|
|
43
|
+
return textResult(`FiscalAPI docs: no hay resultados para "${echoedQuery}". Prueba con otras palabras o usa ${TOOL_NAMES.listOperations} para ver las operaciones de la API.`);
|
|
44
|
+
}
|
|
45
|
+
const count = results.length === 1 ? '1 resultado' : `${results.length} resultados`;
|
|
46
|
+
const blocks = results.map((result) => `## ${resultHeading(result)}\n${result.url}\n\n${result.excerpt}`);
|
|
47
|
+
return textResult([`FiscalAPI docs: ${count} para "${echoedQuery}".`, ...blocks].join('\n\n'));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function echo(query) {
|
|
51
|
+
return query.length > SEARCH_LIMITS.maxEchoedQueryChars ? `${query.slice(0, SEARCH_LIMITS.maxEchoedQueryChars)}…` : query;
|
|
52
|
+
}
|
|
53
|
+
function resultHeading({ title, page }) {
|
|
54
|
+
return title === page ? title : `${title} (${page})`;
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const TOOL_NAMES = {
|
|
2
|
+
listOperations: 'fiscalapi_list_operations',
|
|
3
|
+
getOperation: 'fiscalapi_get_operation',
|
|
4
|
+
searchDocs: 'fiscalapi_search_docs',
|
|
5
|
+
};
|
|
6
|
+
export const READ_ONLY_ANNOTATIONS = {
|
|
7
|
+
readOnlyHint: true,
|
|
8
|
+
destructiveHint: false,
|
|
9
|
+
idempotentHint: true,
|
|
10
|
+
openWorldHint: false,
|
|
11
|
+
};
|
|
12
|
+
export const API_SPECIFICATION_NOTICE = 'Solo consulta la especificación pública de la API (OpenAPI): no llama a la API y no requiere API key.';
|
|
13
|
+
export const PUBLIC_DOCS_NOTICE = 'Solo consulta la documentación pública de FiscalAPI: no llama a la API y no requiere API key.';
|
|
14
|
+
export const MAX_IDENTIFIER_CHARS = 100;
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscalapi/docs-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "4.0.461",
|
|
4
|
+
"description": "Servidor MCP de solo lectura con la documentación y la referencia de la API de FiscalAPI (CFDI 4.0) para agentes de código.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"fiscalapi-docs-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"data",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build:data": "node scripts/build-data.ts",
|
|
16
|
+
"clean": "node --eval \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
17
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
18
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"prepack": "npm run build && npm run build:data",
|
|
21
|
+
"verify:package": "node scripts/verify-package.ts"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"fiscalapi",
|
|
25
|
+
"mcp",
|
|
26
|
+
"documentacion",
|
|
27
|
+
"openapi",
|
|
28
|
+
"cfdi",
|
|
29
|
+
"cfdi-4.0",
|
|
30
|
+
"factura",
|
|
31
|
+
"sat",
|
|
32
|
+
"mexico"
|
|
33
|
+
],
|
|
34
|
+
"author": "FiscalAPI",
|
|
35
|
+
"license": "MPL-2.0",
|
|
36
|
+
"homepage": "https://docs.fiscalapi.com",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/FiscalAPI/fiscalapi-ai.git",
|
|
40
|
+
"directory": "docs-mcp"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/FiscalAPI/fiscalapi-ai/issues"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@modelcontextprotocol/server": "2.3.1",
|
|
53
|
+
"@orama/stemmers": "3.1.18",
|
|
54
|
+
"@orama/stopwords": "3.1.18",
|
|
55
|
+
"minisearch": "7.2.0",
|
|
56
|
+
"zod": "4.6.7"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
60
|
+
"@types/node": "22.20.5",
|
|
61
|
+
"typescript": "7.0.2",
|
|
62
|
+
"vitest": "5.0.5"
|
|
63
|
+
}
|
|
64
|
+
}
|