@zincapp/mcp-server 1.7.0 → 1.8.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/tools/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { registerAuditEntities } from './audit-entities.js';
|
|
|
13
13
|
import { registerApplyCompletion } from './apply-completion.js';
|
|
14
14
|
import { registerProposeAuthorizations } from './propose-authorizations.js';
|
|
15
15
|
import { registerApplyAuthorization } from './apply-authorization.js';
|
|
16
|
+
import { registerLinkGestorAuthorizations } from './link-gestor-authorizations.js';
|
|
16
17
|
import { registerProposeNt } from './propose-nt.js';
|
|
17
18
|
import { registerLookupAuthorization } from './lookup-authorization.js';
|
|
18
19
|
export function registerAllTools(server, client) {
|
|
@@ -31,6 +32,7 @@ export function registerAllTools(server, client) {
|
|
|
31
32
|
registerApplyCompletion(server, client);
|
|
32
33
|
registerProposeAuthorizations(server, client);
|
|
33
34
|
registerApplyAuthorization(server, client);
|
|
35
|
+
registerLinkGestorAuthorizations(server, client);
|
|
34
36
|
registerProposeNt(server, client);
|
|
35
37
|
registerLookupAuthorization(server, client);
|
|
36
38
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { resolveElevation } from './elevation.js';
|
|
3
|
+
export function registerLinkGestorAuthorizations(server, client) {
|
|
4
|
+
server.tool('link_gestor_authorizations', 'Backfill the missing gestor authorization LINK on a year\'s waste removals — the fix for the ' +
|
|
5
|
+
'register\'s `autorizacion-gestor` gap. The importer created the gestor EntidadCentroLer rows ' +
|
|
6
|
+
'with an empty auth_id; this links each to the center\'s already-loaded gestor authorization ' +
|
|
7
|
+
'(G0x) using the SAME rule the register enforces (destino + hazard class). Without confirm it ' +
|
|
8
|
+
'is a DRY-RUN (shows what would be linked and what can\'t resolve); with confirm=true it writes ' +
|
|
9
|
+
'under your active operator elevation (company derived from it). Rows whose center has no ' +
|
|
10
|
+
'matching destino authorization are reported, never forced — load the G0x with ' +
|
|
11
|
+
'apply_authorization first. Read the dry-run before confirming.', {
|
|
12
|
+
year: z.number().describe('Calendar year, e.g. 2025'),
|
|
13
|
+
confirm: z.boolean().optional().describe('true to write; omit/false for a dry-run'),
|
|
14
|
+
}, async ({ year, confirm }) => {
|
|
15
|
+
const elev = await resolveElevation(client);
|
|
16
|
+
if ('content' in elev)
|
|
17
|
+
return elev;
|
|
18
|
+
const body = { year, confirm: confirm === true };
|
|
19
|
+
const res = confirm === true
|
|
20
|
+
? await client.post('/mwm/retirada/link-gestor-authorizations', body)
|
|
21
|
+
: await client.post('/mwm/retirada/link-gestor-authorizations', body);
|
|
22
|
+
if (confirm !== true) {
|
|
23
|
+
const d = res;
|
|
24
|
+
const sampleR = d.resoluble.slice(0, 15).map(r => ` - ${r.clientId}/${r.centerId} · LER ${r.codigoLer} → \`${r.authId}\``).join('\n');
|
|
25
|
+
const sampleU = d.unresoluble.slice(0, 15).map(u => ` - ${u.clientId}/${u.centerId} · LER ${u.codigoLer}: ${u.reason}`).join('\n');
|
|
26
|
+
const text = `# Dry-run · vincular autorización de gestor · ${d.year}\n` +
|
|
27
|
+
`${d.total} fila(s) EntidadCentroLer sin auth_id · ${d.resoluble.length} resolubles · ${d.unresoluble.length} sin resolver.\n\n` +
|
|
28
|
+
(d.resoluble.length ? `## Se vincularían (authId)\n${sampleR}${d.resoluble.length > 15 ? `\n … +${d.resoluble.length - 15} más` : ''}\n\n` : '') +
|
|
29
|
+
(d.unresoluble.length ? `## No resolubles (falta cargar la G0x)\n${sampleU}${d.unresoluble.length > 15 ? `\n … +${d.unresoluble.length - 15} más` : ''}\n\n` : '') +
|
|
30
|
+
`_Ejecuta con confirm=true para aplicar las ${d.resoluble.length} resolubles._`;
|
|
31
|
+
return { content: [{ type: 'text', text }] };
|
|
32
|
+
}
|
|
33
|
+
const r = res;
|
|
34
|
+
const failLines = r.failed.length ? '\n\n### Fallidas\n' + r.failed.map(f => `- ${f.clientId}/${f.centerId} LER ${f.codigoLer}: ${f.error}`).join('\n') : '';
|
|
35
|
+
const text = `# Aplicado · vincular autorización de gestor · ${r.year}\n` +
|
|
36
|
+
`${r.applied} vinculada(s)${r.skipped ? `, ${r.skipped} ya poblada(s)` : ''}${r.failed.length ? `, ${r.failed.length} con error` : ''}, bajo tu elevación.` +
|
|
37
|
+
(r.unresoluble.length ? `\n${r.unresoluble.length} sin resolver (falta cargar su G0x — usa apply_authorization).` : '') +
|
|
38
|
+
failLines +
|
|
39
|
+
`\n\n_Recuerda des-elevarte desde el portal web con un motivo cuando termines._`;
|
|
40
|
+
return { content: [{ type: 'text', text }] };
|
|
41
|
+
});
|
|
42
|
+
}
|
package/package.json
CHANGED