@vint.tri/report_gen_mcp 1.0.10 → 1.0.12

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
@@ -8,17 +8,27 @@ const express_1 = __importDefault(require("express"));
8
8
  const commander_1 = require("commander");
9
9
  const reportGenerator_1 = require("./utils/reportGenerator");
10
10
  const path_1 = __importDefault(require("path"));
11
+ const fs_extra_1 = __importDefault(require("fs-extra"));
11
12
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
12
13
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
13
14
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
14
15
  const app = (0, express_1.default)();
15
16
  const port = 3000;
16
17
  app.use(express_1.default.json());
18
+ // Add home directory parameter
19
+ let homeDir = process.cwd(); // Default to current working directory
17
20
  app.post('/generate-report', async (req, res) => {
18
- const { document, charts, outputFile = 'report.html' } = req.body;
21
+ const { document, charts, outputFile = 'report.html', tempDirectory } = req.body;
22
+ const effectiveTempDir = tempDirectory || homeDir;
23
+ const outputPath = path_1.default.resolve(effectiveTempDir, outputFile);
19
24
  try {
20
- const result = await (0, reportGenerator_1.generateReport)(document, charts, path_1.default.resolve(outputFile));
21
- res.json(result);
25
+ const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
26
+ // Send the file content back to the client
27
+ const fileContent = await fs_extra_1.default.readFile(outputPath, 'utf8');
28
+ res.json({
29
+ ...result,
30
+ fileContent: fileContent
31
+ });
22
32
  }
23
33
  catch (error) {
24
34
  res.status(500).json({ error: error.message });
@@ -86,6 +96,10 @@ if (process.argv.length === 2) {
86
96
  outputFile: {
87
97
  type: "string",
88
98
  description: "Output HTML file path"
99
+ },
100
+ tempDirectory: {
101
+ type: "string",
102
+ description: "Temporary directory for file storage (defaults to current working directory if not specified)"
89
103
  }
90
104
  },
91
105
  required: ["document", "charts"]
@@ -108,12 +122,19 @@ if (process.argv.length === 2) {
108
122
  const document = typeof args.document === 'string' ? args.document : '';
109
123
  const charts = (typeof args.charts === 'object' && args.charts !== null) ? args.charts : {};
110
124
  const outputFile = typeof args.outputFile === 'string' ? args.outputFile : 'report.html';
111
- const result = await (0, reportGenerator_1.generateReport)(document, charts, path_1.default.resolve(outputFile));
125
+ const tempDirectory = typeof args.tempDirectory === 'string' ? args.tempDirectory : process.cwd();
126
+ const outputPath = path_1.default.resolve(tempDirectory, outputFile);
127
+ const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
128
+ // Read the file content to send back to the client
129
+ const fileContent = await fs_extra_1.default.readFile(outputPath, 'utf8');
112
130
  return {
113
131
  content: [
114
132
  {
115
133
  type: 'text',
116
- text: JSON.stringify(result),
134
+ text: JSON.stringify({
135
+ ...result,
136
+ fileContent: fileContent
137
+ }),
117
138
  }
118
139
  ],
119
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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
@@ -4,6 +4,7 @@ import express from 'express';
4
4
  import { program } from 'commander';
5
5
  import { generateReport } from './utils/reportGenerator';
6
6
  import path from 'path';
7
+ import fs from 'fs-extra';
7
8
  import { stdin } from 'process';
8
9
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
9
10
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -17,11 +18,23 @@ const port = 3000;
17
18
 
18
19
  app.use(express.json());
19
20
 
21
+ // Add home directory parameter
22
+ let homeDir = process.cwd(); // Default to current working directory
23
+
20
24
  app.post('/generate-report', async (req, res) => {
21
- const { document, charts, outputFile = 'report.html' } = req.body;
25
+ const { document, charts, outputFile = 'report.html', tempDirectory } = req.body;
26
+ const effectiveTempDir = tempDirectory || homeDir;
27
+ const outputPath = path.resolve(effectiveTempDir, outputFile);
28
+
22
29
  try {
23
- const result = await generateReport(document, charts, path.resolve(outputFile));
24
- res.json(result);
30
+ const result = await generateReport(document, charts, outputPath);
31
+
32
+ // Send the file content back to the client
33
+ const fileContent = await fs.readFile(outputPath, 'utf8');
34
+ res.json({
35
+ ...result,
36
+ fileContent: fileContent
37
+ });
25
38
  } catch (error) {
26
39
  res.status(500).json({ error: (error as Error).message });
27
40
  }
@@ -95,6 +108,10 @@ if (process.argv.length === 2) {
95
108
  outputFile: {
96
109
  type: "string",
97
110
  description: "Output HTML file path"
111
+ },
112
+ tempDirectory: {
113
+ type: "string",
114
+ description: "Temporary directory for file storage (defaults to current working directory if not specified)"
98
115
  }
99
116
  },
100
117
  required: ["document", "charts"]
@@ -118,13 +135,22 @@ if (process.argv.length === 2) {
118
135
  const document = typeof args.document === 'string' ? args.document : '';
119
136
  const charts = (typeof args.charts === 'object' && args.charts !== null) ? args.charts as Record<string, { type: string; config: any }> : {};
120
137
  const outputFile = typeof args.outputFile === 'string' ? args.outputFile : 'report.html';
138
+ const tempDirectory = typeof args.tempDirectory === 'string' ? args.tempDirectory : process.cwd();
139
+ const outputPath = path.resolve(tempDirectory, outputFile);
140
+
141
+ const result = await generateReport(document, charts, outputPath);
142
+
143
+ // Read the file content to send back to the client
144
+ const fileContent = await fs.readFile(outputPath, 'utf8');
121
145
 
122
- const result = await generateReport(document, charts, path.resolve(outputFile));
123
146
  return {
124
147
  content: [
125
148
  {
126
149
  type: 'text',
127
- text: JSON.stringify(result),
150
+ text: JSON.stringify({
151
+ ...result,
152
+ fileContent: fileContent
153
+ }),
128
154
  }
129
155
  ],
130
156
  };