@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.
- package/dist/index.js +23 -32
- package/package.json +1 -1
- 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
|
-
|
|
47
|
-
|
|
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
|
-
.
|
|
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
|
-
|
|
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
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
|
-
|
|
51
|
-
|
|
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
|
-
.
|
|
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
|
-
|
|
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 {
|