autoform-mcp-server 1.7.1 → 1.7.2

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) {
@@ -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;
@@ -36,6 +36,10 @@ Modos de distribucion:
36
36
  type: 'boolean',
37
37
  description: 'Si es true, une todos los PDFs en uno solo. Default: false.'
38
38
  },
39
+ output_dir: {
40
+ type: 'string',
41
+ description: '(Opcional) Directorio donde guardar los PDFs generados. Default: mismo directorio del PDF base del template.'
42
+ },
39
43
  _session_id: {
40
44
  type: 'string',
41
45
  description: '(Opcional) ID de sesion experimental para agrupar tool calls en metrics.jsonl.'
@@ -50,7 +54,7 @@ Modos de distribucion:
50
54
  }
51
55
  };
52
56
  export async function handleGenerateBatch(args) {
53
- const { template_name, distribution_mode = 'sequential', merge_into_single = false } = args;
57
+ const { template_name, distribution_mode = 'sequential', merge_into_single = false, output_dir } = args;
54
58
  // data puede llegar como string JSON o como array
55
59
  let data = args.data;
56
60
  if (typeof data === 'string') {
@@ -97,7 +101,7 @@ export async function handleGenerateBatch(args) {
97
101
  };
98
102
  }
99
103
  // Generate
100
- const result = await BatchGenerator.generate(template, parsedData, distribution_mode, merge_into_single);
104
+ const result = await BatchGenerator.generate(template, parsedData, distribution_mode, merge_into_single, output_dir);
101
105
  return {
102
106
  content: [{
103
107
  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.2",
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",