@vint.tri/report_gen_mcp 1.0.25 → 1.0.26

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.
Files changed (3) hide show
  1. package/dist/index.js +23 -32
  2. package/package.json +1 -1
  3. package/src/index.ts +27 -36
package/dist/index.js CHANGED
@@ -15,36 +15,16 @@ const zod_1 = require("zod");
15
15
  const app = (0, express_1.default)();
16
16
  const port = 3000;
17
17
  app.use(express_1.default.json());
18
- // Parse command line arguments to get the reports directory
19
- commander_1.program
20
- .option('-d, --directory <path>', 'Directory for generated reports (required)')
21
- .parse(process.argv);
22
- const options = commander_1.program.opts();
23
- // Check if directory parameter is provided
24
- if (!options.directory) {
25
- console.error('Error: The --directory (-d) parameter is required to specify the folder for generated reports.');
26
- console.error('Example usage:');
27
- console.error(' report_gen_mcp --directory /path/to/reports');
28
- console.error(' report_gen_mcp --directory ./reports start-server');
29
- console.error(' report_gen_mcp --directory ./reports generate --document doc.md --charts charts.json');
30
- process.exit(1);
31
- }
32
- // Validate that the directory exists or can be created
33
- let reportsDir;
34
- try {
35
- reportsDir = path_1.default.resolve(options.directory);
36
- fs_extra_1.default.ensureDirSync(reportsDir);
37
- }
38
- catch (error) {
39
- console.error(`Error: Cannot access or create directory "${options.directory}"`);
40
- process.exit(1);
41
- }
42
- // Use the reports directory as the base directory for all operations
43
- let homeDir = reportsDir;
44
18
  app.post('/generate-report', async (req, res) => {
19
+ // Check if tempDirectory parameter is provided
45
20
  const { document, charts, outputFile = 'report.html', tempDirectory } = req.body;
46
- const effectiveTempDir = tempDirectory || homeDir;
47
- const outputPath = path_1.default.resolve(effectiveTempDir, outputFile);
21
+ if (!tempDirectory) {
22
+ return res.status(400).json({
23
+ error: 'tempDirectory parameter is required. Please provide the directory where reports should be generated.',
24
+ example: 'curl -X POST http://localhost:3000/generate-report -H "Content-Type: application/json" -d \'{"document": "# Report", "charts": {}, "tempDirectory": "/path/to/reports"}\''
25
+ });
26
+ }
27
+ const outputPath = path_1.default.resolve(tempDirectory, outputFile);
48
28
  try {
49
29
  const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
50
30
  // Send the file content back to the client
@@ -67,13 +47,20 @@ commander_1.program
67
47
  });
68
48
  });
69
49
  commander_1.program
70
- .command('generate')
50
+ .command('generate <directory>')
71
51
  .option('--document <md>', 'Markdown document with placeholders [[chart:id]]')
72
52
  .option('--charts <json>', 'JSON string of charts {id: {type: "bar", config: {...}}}')
73
53
  .option('--output <file>', 'Output HTML file', 'report.html')
74
- .action(async (opts) => {
54
+ .description('Generate a report in the specified directory')
55
+ .action(async (directory, opts) => {
56
+ // Check if directory parameter is provided
57
+ if (!directory) {
58
+ console.error('Error: Directory parameter is required. Please specify the directory where reports should be generated.');
59
+ console.error('Example: npx @vint.tri/report_gen_mcp@latest generate /path/to/reports --document "# Report" --charts \'{}\'');
60
+ process.exit(1);
61
+ }
75
62
  const charts = JSON.parse(opts.charts);
76
- const result = await (0, reportGenerator_1.generateReport)(opts.document, charts, opts.output);
63
+ const result = await (0, reportGenerator_1.generateReport)(opts.document, charts, path_1.default.resolve(directory, opts.output));
77
64
  console.log(result);
78
65
  });
79
66
  // Handle stdio mode for Claude Desktop integration
@@ -126,7 +113,11 @@ if (process.argv.length === 2) {
126
113
  else if (params.arguments && typeof params.arguments === 'object') {
127
114
  processedParams = params.arguments;
128
115
  }
129
- const { document, charts, outputFile = 'report.html', tempDirectory = process.cwd() } = processedParams;
116
+ // Check if tempDirectory parameter is provided
117
+ if (!processedParams.tempDirectory) {
118
+ throw new Error('tempDirectory parameter is required. Please provide the directory where reports should be generated.');
119
+ }
120
+ const { document, charts, outputFile = 'report.html', tempDirectory } = processedParams;
130
121
  const outputPath = path_1.default.resolve(tempDirectory, outputFile);
131
122
  try {
132
123
  const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "CLI tool for generating HTML reports with embedded charts",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -15,40 +15,18 @@ const port = 3000;
15
15
 
16
16
  app.use(express.json());
17
17
 
18
- // Parse command line arguments to get the reports directory
19
- program
20
- .option('-d, --directory <path>', 'Directory for generated reports (required)')
21
- .parse(process.argv);
22
-
23
- const options = program.opts();
24
-
25
- // Check if directory parameter is provided
26
- if (!options.directory) {
27
- console.error('Error: The --directory (-d) parameter is required to specify the folder for generated reports.');
28
- console.error('Example usage:');
29
- console.error(' report_gen_mcp --directory /path/to/reports');
30
- console.error(' report_gen_mcp --directory ./reports start-server');
31
- console.error(' report_gen_mcp --directory ./reports generate --document doc.md --charts charts.json');
32
- process.exit(1);
33
- }
34
-
35
- // Validate that the directory exists or can be created
36
- let reportsDir: string;
37
- try {
38
- reportsDir = path.resolve(options.directory);
39
- fs.ensureDirSync(reportsDir);
40
- } catch (error) {
41
- console.error(`Error: Cannot access or create directory "${options.directory}"`);
42
- process.exit(1);
43
- }
44
-
45
- // Use the reports directory as the base directory for all operations
46
- let homeDir = reportsDir;
47
-
48
18
  app.post('/generate-report', async (req, res) => {
19
+ // Check if tempDirectory parameter is provided
49
20
  const { document, charts, outputFile = 'report.html', tempDirectory } = req.body;
50
- const effectiveTempDir = tempDirectory || homeDir;
51
- const outputPath = path.resolve(effectiveTempDir, outputFile);
21
+
22
+ if (!tempDirectory) {
23
+ return res.status(400).json({
24
+ error: 'tempDirectory parameter is required. Please provide the directory where reports should be generated.',
25
+ example: 'curl -X POST http://localhost:3000/generate-report -H "Content-Type: application/json" -d \'{"document": "# Report", "charts": {}, "tempDirectory": "/path/to/reports"}\''
26
+ });
27
+ }
28
+
29
+ const outputPath = path.resolve(tempDirectory, outputFile);
52
30
 
53
31
  try {
54
32
  const result = await generateReport(document, charts, outputPath);
@@ -74,13 +52,21 @@ program
74
52
  });
75
53
 
76
54
  program
77
- .command('generate')
55
+ .command('generate <directory>')
78
56
  .option('--document <md>', 'Markdown document with placeholders [[chart:id]]')
79
57
  .option('--charts <json>', 'JSON string of charts {id: {type: "bar", config: {...}}}')
80
58
  .option('--output <file>', 'Output HTML file', 'report.html')
81
- .action(async (opts) => {
59
+ .description('Generate a report in the specified directory')
60
+ .action(async (directory, opts) => {
61
+ // Check if directory parameter is provided
62
+ if (!directory) {
63
+ console.error('Error: Directory parameter is required. Please specify the directory where reports should be generated.');
64
+ console.error('Example: npx @vint.tri/report_gen_mcp@latest generate /path/to/reports --document "# Report" --charts \'{}\'');
65
+ process.exit(1);
66
+ }
67
+
82
68
  const charts = JSON.parse(opts.charts);
83
- const result = await generateReport(opts.document, charts, opts.output);
69
+ const result = await generateReport(opts.document, charts, path.resolve(directory, opts.output));
84
70
  console.log(result);
85
71
  });
86
72
 
@@ -134,7 +120,12 @@ if (process.argv.length === 2) {
134
120
  processedParams = params.arguments;
135
121
  }
136
122
 
137
- const { document, charts, outputFile = 'report.html', tempDirectory = process.cwd() } = processedParams;
123
+ // Check if tempDirectory parameter is provided
124
+ if (!processedParams.tempDirectory) {
125
+ throw new Error('tempDirectory parameter is required. Please provide the directory where reports should be generated.');
126
+ }
127
+
128
+ const { document, charts, outputFile = 'report.html', tempDirectory } = processedParams;
138
129
  const outputPath = path.resolve(tempDirectory, outputFile);
139
130
 
140
131
  try {