autoform-mcp-server 1.7.1 → 1.7.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/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { handleGenerateBatch, generateBatchSchema } from './tools/generateBatch.
13
13
  import { handleListTemplates, listTemplatesSchema } from './tools/manageTemplates.js';
14
14
  import { handleImportTemplate, importTemplateSchema } from './tools/importTemplate.js';
15
15
  import { withMetrics } from './services/metricsLogger.js';
16
- const server = new Server({ name: 'autoform', version: '1.7.1' }, { capabilities: { tools: {} } });
16
+ const server = new Server({ name: 'autoform', version: '1.7.2' }, { capabilities: { tools: {} } });
17
17
  // Register all tools
18
18
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
19
19
  tools: [
@@ -4,7 +4,7 @@ import { SavedTemplate, ParsedData, DistributionMode, GenerationResult } from '.
4
4
  * Adapts web app's distributionEngine + pdfGenerator for Node.js.
5
5
  */
6
6
  export declare class BatchGenerator {
7
- static generate(template: SavedTemplate, data: ParsedData[], mode?: DistributionMode, mergeIntoSingle?: boolean): Promise<GenerationResult>;
7
+ static generate(template: SavedTemplate, data: ParsedData[], mode?: DistributionMode, mergeIntoSingle?: boolean, outputDir?: string): Promise<GenerationResult>;
8
8
  private static calculateDocumentsNeeded;
9
9
  private static createMappings;
10
10
  }
@@ -9,8 +9,9 @@ const OUTPUT_DIR = path.join(AUTOFORM_HOME, 'output');
9
9
  * Adapts web app's distributionEngine + pdfGenerator for Node.js.
10
10
  */
11
11
  export class BatchGenerator {
12
- static async generate(template, data, mode = 'sequential', mergeIntoSingle = false) {
13
- fs.mkdirSync(OUTPUT_DIR, { recursive: true });
12
+ static async generate(template, data, mode = 'sequential', mergeIntoSingle = false, outputDir) {
13
+ const effectiveOutputDir = outputDir || path.dirname(template.pdfPath) || OUTPUT_DIR;
14
+ fs.mkdirSync(effectiveOutputDir, { recursive: true });
14
15
  const timestamp = new Date().toISOString().slice(0, 10);
15
16
  const safeName = template.name.replace(/[^a-zA-Z0-9_\-]/g, '_');
16
17
  // Read base PDF
@@ -25,8 +26,8 @@ export class BatchGenerator {
25
26
  const errors = [];
26
27
  // If merging, write individuals to temp dir (will be cleaned up)
27
28
  const workingDir = mergeIntoSingle
28
- ? fs.mkdtempSync(path.join(OUTPUT_DIR, '.tmp_batch_'))
29
- : OUTPUT_DIR;
29
+ ? fs.mkdtempSync(path.join(effectiveOutputDir, '.tmp_batch_'))
30
+ : effectiveOutputDir;
30
31
  for (let docNum = 0; docNum < documentsNeeded; docNum++) {
31
32
  try {
32
33
  const mappings = this.createMappings(data, template, docNum, mode);
@@ -42,7 +43,7 @@ export class BatchGenerator {
42
43
  // Merge if requested — and clean up individuals
43
44
  let mergedPath;
44
45
  if (mergeIntoSingle && outputPaths.length > 0) {
45
- mergedPath = path.join(OUTPUT_DIR, `${safeName}_merged_${timestamp}.pdf`);
46
+ mergedPath = path.join(effectiveOutputDir, `${safeName}_merged_${timestamp}.pdf`);
46
47
  await PdfService.mergePdfs(outputPaths, mergedPath);
47
48
  // Delete temp files and dir
48
49
  for (const p of outputPaths) {
@@ -13,6 +13,7 @@ IMPORTANTE — Codificación de texto:
13
13
  IMPORTANTE — Casillas de verificación (checkboxes) en PDFs estaticos:
14
14
  - Si detectas opciones tipo checkbox, SOLO marcalas si puedes VER el PDF visualmente (adjuntado al chat). Si no puedes verlo, pide al usuario que lo adjunte.
15
15
  - Para marcar: text="X", fontSize=10, en las coordenadas exactas del cuadrado.
16
+ - CHECKBOXES MUTUAMENTE EXCLUYENTES: si el formulario tiene opciones donde solo una puede estar marcada (ej: ALUMNO / DOCENTE / ADMINISTRATIVO), cada fila de data_rows debe tener "X" en EXACTAMENTE UN campo checkbox y "" en los demas. NUNCA pongas "X" en multiples checkboxes de la misma fila.
16
17
 
17
18
  IMPORTANTE — Verificación visual:
18
19
  - Si el usuario adjunto el PDF al chat Y tambien dio la ruta, APROVECHA la imagen visual para verificar que tus coordenadas son correctas antes de generar.
@@ -27,6 +27,10 @@ export declare const generateBatchSchema: {
27
27
  type: string;
28
28
  description: string;
29
29
  };
30
+ output_dir: {
31
+ type: string;
32
+ description: string;
33
+ };
30
34
  _session_id: {
31
35
  type: string;
32
36
  description: string;
@@ -9,6 +9,15 @@ NO USAR SI: No tienes template guardado → usa autoform_fill_batch_at_coordinat
9
9
 
10
10
  DATOS: Pasa los datos como array de objetos JSON en el parametro "data". Si el usuario tiene un archivo (Excel, CSV, etc.), leelo primero y convierte a JSON.
11
11
 
12
+ CHECKBOXES MUTUAMENTE EXCLUYENTES:
13
+ - Si el template tiene campos tipo checkbox (ej: es_alumno, es_docente, es_administrativo) donde SOLO UNO debe marcarse por documento, asegurate de que CADA fila de data tenga "X" en EXACTAMENTE UN campo de checkbox y "" (string vacio) en todos los demas.
14
+ - NUNCA pongas "X" en multiples checkboxes de la misma fila.
15
+ - Si un error produce checkboxes mal marcados, el error esta en tus datos, NO en el MCP. Revisa y corrige los datos antes de culpar al sistema.
16
+
17
+ DIRECTORIO DE SALIDA: Si no se especifica output_dir, guarda en el mismo directorio del PDF base del template.
18
+
19
+ NO GENERES PDF DE PRUEBA: Genera el batch completo directamente.
20
+
12
21
  Modos de distribucion:
13
22
  - "sequential": campos repetidos consumen filas diferentes (para tablas/listas)
14
23
  - "repeat": una fila se repite en todos los campos con el mismo nombre (para certificados)`,
@@ -36,6 +45,10 @@ Modos de distribucion:
36
45
  type: 'boolean',
37
46
  description: 'Si es true, une todos los PDFs en uno solo. Default: false.'
38
47
  },
48
+ output_dir: {
49
+ type: 'string',
50
+ description: '(Opcional) Directorio donde guardar los PDFs generados. Default: mismo directorio del PDF base del template.'
51
+ },
39
52
  _session_id: {
40
53
  type: 'string',
41
54
  description: '(Opcional) ID de sesion experimental para agrupar tool calls en metrics.jsonl.'
@@ -50,7 +63,7 @@ Modos de distribucion:
50
63
  }
51
64
  };
52
65
  export async function handleGenerateBatch(args) {
53
- const { template_name, distribution_mode = 'sequential', merge_into_single = false } = args;
66
+ const { template_name, distribution_mode = 'sequential', merge_into_single = false, output_dir } = args;
54
67
  // data puede llegar como string JSON o como array
55
68
  let data = args.data;
56
69
  if (typeof data === 'string') {
@@ -97,7 +110,7 @@ export async function handleGenerateBatch(args) {
97
110
  };
98
111
  }
99
112
  // Generate
100
- const result = await BatchGenerator.generate(template, parsedData, distribution_mode, merge_into_single);
113
+ const result = await BatchGenerator.generate(template, parsedData, distribution_mode, merge_into_single, output_dir);
101
114
  return {
102
115
  content: [{
103
116
  type: 'text',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoform-mcp-server",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "MCP server for bulk PDF form filling. Detect fields, fill templates, and generate hundreds of PDFs from data — directly from Claude.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",