@vint.tri/report_gen_mcp 1.0.13 → 1.0.17

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 (52) hide show
  1. package/README.md +231 -11
  2. package/debug-report.html +15 -0
  3. package/detailed-debug.js +1 -1
  4. package/dist/charts/bar.js +1 -0
  5. package/dist/charts/line.js +2 -1
  6. package/dist/charts/pie.js +1 -0
  7. package/dist/index.js +85 -122
  8. package/package.json +1 -1
  9. package/src/charts/bar.ts +1 -0
  10. package/src/charts/line.ts +2 -1
  11. package/src/charts/pie.ts +1 -0
  12. package/src/index.ts +90 -134
  13. package/CLAUDE_DESKTOP_FIX_INSTRUCTIONS.md +0 -75
  14. package/CLAUDE_DESKTOP_INTEGRATION_SUMMARY.md +0 -156
  15. package/CLAUDE_DESKTOP_README.md +0 -88
  16. package/USAGE_SUMMARY.md +0 -123
  17. package/claude-desktop-config.json +0 -14
  18. package/claude-desktop-corrected-config.json +0 -35
  19. package/claude-desktop-final-config.json +0 -14
  20. package/claude-desktop-simulation.js +0 -154
  21. package/cli-test-report.html +0 -21
  22. package/debug-method.js +0 -67
  23. package/debug-stdio.js +0 -65
  24. package/generated-report.html +0 -1
  25. package/npx-test-report.html +0 -15
  26. package/package-test-report.html +0 -19
  27. package/report.html +0 -15
  28. package/republished-test-report.html +0 -14
  29. package/simple-test.js +0 -35
  30. package/stdio-test-report.html +0 -19
  31. package/test-charts.json +0 -29
  32. package/test-claude-full-functionality.js +0 -161
  33. package/test-claude-stdio.js +0 -44
  34. package/test-cli-report-fixed.html +0 -14
  35. package/test-cli-report.html +0 -0
  36. package/test-document.md +0 -15
  37. package/test-list-tools.js +0 -35
  38. package/test-local-installed.js +0 -36
  39. package/test-local-list-tools.js +0 -36
  40. package/test-local-stdio.js +0 -34
  41. package/test-new-command.js +0 -39
  42. package/test-npx-command.js +0 -39
  43. package/test-npx-explicit-version.js +0 -36
  44. package/test-npx-stdio.js +0 -39
  45. package/test-package.js +0 -33
  46. package/test-report.html +0 -15
  47. package/test-report.json +0 -22
  48. package/test-stdio-direct.js +0 -31
  49. package/test-stdio-full.js +0 -61
  50. package/test-stdio.js +0 -28
  51. package/verify-claude-integration.js +0 -231
  52. package/verify-fix.js +0 -98
package/README.md CHANGED
@@ -17,13 +17,13 @@ A powerful CLI tool for generating HTML reports with embedded charts, designed t
17
17
  ### Global Installation (Recommended)
18
18
 
19
19
  ```bash
20
- npm install -g @vint.tri/report_gen_mcp@1.0.9
20
+ npm install -g @vint.tri/report_gen_mcp@1.0.15
21
21
  ```
22
22
 
23
23
  ### Direct Execution with npx
24
24
 
25
25
  ```bash
26
- npx @vint.tri/report_gen_mcp@1.0.9
26
+ npx @vint.tri/report_gen_mcp@1.0.15
27
27
  ```
28
28
 
29
29
  ## Usage
@@ -64,28 +64,74 @@ To use this tool with Claude Desktop, add the following configuration to your Cl
64
64
  "tags": [],
65
65
  "command": "npx",
66
66
  "args": [
67
- "@vint.tri/report_gen_mcp@1.0.9"
67
+ "@vint.tri/report_gen_mcp@1.0.15"
68
68
  ]
69
69
  }
70
70
  }
71
71
  ```
72
72
 
73
- Once configured, Claude can generate reports by sending requests with the following format:
73
+ Once configured, Claude can generate reports by sending requests. Here's how to properly format your requests:
74
74
 
75
+ #### How to Provide Data for Reports
76
+
77
+ When calling the `generate-report` method, you need to provide three main pieces of data:
78
+
79
+ 1. **document**: A Markdown string containing your report content with chart placeholders
80
+ 2. **charts**: An object mapping chart IDs to their configurations
81
+ 3. **outputFile**: (Optional) The name of the output HTML file
82
+
83
+ #### Document Format
84
+
85
+ Your document should be a Markdown string that can include chart placeholders in the format `[[chart:chartId]]`. For example:
86
+
87
+ ```markdown
88
+ # Sales Report
89
+
90
+ ## Monthly Performance
91
+
92
+ [[chart:salesChart]]
93
+
94
+ As shown above, our sales have increased by 15% this month.
95
+
96
+ ## Regional Comparison
97
+
98
+ [[chart:regionalChart]]
99
+
100
+ Different regions show varying performance levels.
101
+ ```
102
+
103
+ #### Charts Configuration
104
+
105
+ The `charts` parameter is an object where each key is a chart ID that matches a placeholder in your document, and each value is a chart configuration object with:
106
+
107
+ - `type`: The chart type ("bar", "line", or "pie")
108
+ - `config`: The Chart.js configuration for that chart
109
+
110
+ #### Required Chart Data Structure
111
+
112
+ All charts must follow a specific data structure:
113
+
114
+ #### Method 1: Direct Method Call (Simple Format)
75
115
  ```json
76
116
  {
77
117
  "method": "generate-report",
78
118
  "params": {
79
- "document": "# Sales Report\n\n[[chart:salesChart]]",
119
+ "document": "# Sales Report\n\nThis is our monthly sales report.\n\n[[chart:sales]]\n\n## Conclusion\n\nThis report shows our sales performance.",
80
120
  "charts": {
81
- "salesChart": {
121
+ "sales": {
82
122
  "type": "bar",
83
123
  "config": {
84
- "labels": ["Jan", "Feb", "Mar"],
85
- "datasets": [{
86
- "label": "Sales",
87
- "data": [100, 150, 200]
88
- }]
124
+ "labels": ["January", "February", "March", "April", "May"],
125
+ "datasets": [
126
+ {
127
+ "label": "Sales (USD)",
128
+ "data": [12000, 19000, 15000, 18000, 22000],
129
+ "backgroundColor": ["#FF6384", "#36A2EB", "#FFCE56", "#4BC0C0", "#9966FF"]
130
+ }
131
+ ],
132
+ "options": {
133
+ "title": "Monthly Sales Data"
134
+ }
89
135
  }
90
136
  }
91
137
  },
@@ -94,6 +140,180 @@ Once configured, Claude can generate reports by sending requests with the follow
94
140
  }
95
141
  ```
96
142
 
143
+ #### Method 2: MCP Standard Format (Advanced)
144
+ ```json
145
+ {
146
+ "method": "tools/call",
147
+ "params": {
148
+ "name": "generate-report",
149
+ "arguments": {
150
+ "document": "# Performance Report\n\n[[chart:performance]]\n\nDetailed analysis below.",
151
+ "charts": {
152
+ "performance": {
153
+ "type": "line",
154
+ "config": {
155
+ "labels": ["Q1", "Q2", "Q3", "Q4"],
156
+ "datasets": [
157
+ {
158
+ "label": "Revenue",
159
+ "data": [45000, 52000, 48000, 61000],
160
+ "borderColor": "#36A2EB",
161
+ "fill": false
162
+ },
163
+ {
164
+ "label": "Expenses",
165
+ "data": [30000, 32000, 31000, 35000],
166
+ "borderColor": "#FF6384",
167
+ "fill": false
168
+ }
169
+ ],
170
+ "options": {
171
+ "title": "Quarterly Performance",
172
+ "scales": {
173
+ "yAxes": [{
174
+ "ticks": {
175
+ "beginAtZero": true
176
+ }
177
+ }]
178
+ }
179
+ }
180
+ }
181
+ }
182
+ },
183
+ "outputFile": "performance-report.html"
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ #### How to Insert Charts in Documents
190
+
191
+ Charts are inserted into your Markdown document using placeholders with the format `[[chart:chartId]]`, where `chartId` corresponds to the key in your charts object.
192
+
193
+ Example:
194
+ ```markdown
195
+ # My Report
196
+
197
+ ## Sales Overview
198
+
199
+ [[chart:salesChart]]
200
+
201
+ As we can see from the chart above, sales have been increasing steadily.
202
+
203
+ ## Regional Performance
204
+
205
+ [[chart:regionalChart]]
206
+
207
+ Different regions show varying performance levels.
208
+ ```
209
+
210
+ #### Health Check
211
+
212
+ To verify the tool is working correctly:
213
+
214
+ ```json
215
+ {
216
+ "method": "health"
217
+ }
218
+ ```
219
+
220
+ Expected response:
221
+ ```json
222
+ {
223
+ "status": "ok"
224
+ }
225
+ ```
226
+
227
+ #### List Available Tools
228
+
229
+ To see what tools are available:
230
+
231
+ ```json
232
+ {
233
+ "method": "tools/list"
234
+ }
235
+ ```
236
+ ```
237
+
238
+ ### Detailed Chart Configuration Requirements
239
+
240
+ Each chart type has specific configuration requirements that must be met. All chart configurations must include `labels` and `datasets` as arrays.
241
+
242
+ #### Bar Charts
243
+
244
+ Required structure:
245
+ ```json
246
+ {
247
+ "type": "bar",
248
+ "config": {
249
+ "labels": ["Label1", "Label2", "Label3"],
250
+ "datasets": [
251
+ {
252
+ "label": "Dataset Name",
253
+ "data": [10, 20, 30],
254
+ "backgroundColor": ["red", "blue", "green"] // Optional
255
+ }
256
+ ],
257
+ "options": {
258
+ "title": "Chart Title" // Optional
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ #### Line Charts
265
+
266
+ Required structure:
267
+ ```json
268
+ {
269
+ "type": "line",
270
+ "config": {
271
+ "labels": ["Label1", "Label2", "Label3"],
272
+ "datasets": [
273
+ {
274
+ "label": "Dataset Name",
275
+ "data": [10, 20, 30],
276
+ "borderColor": "blue" // Optional
277
+ }
278
+ ],
279
+ "options": {
280
+ "title": "Chart Title" // Optional
281
+ }
282
+ }
283
+ }
284
+ ```
285
+
286
+ #### Pie Charts
287
+
288
+ Required structure:
289
+ ```json
290
+ {
291
+ "type": "pie",
292
+ "config": {
293
+ "labels": ["Label1", "Label2", "Label3"],
294
+ "datasets": [
295
+ {
296
+ "data": [10, 20, 30],
297
+ "backgroundColor": ["red", "blue", "green"] // Optional
298
+ }
299
+ ],
300
+ "options": {
301
+ "title": "Chart Title" // Optional
302
+ }
303
+ }
304
+ }
305
+ ```
306
+
307
+ **Important Notes:**
308
+ 1. `labels` must be an array of strings
309
+ 2. `datasets` must be an array of objects
310
+ 3. Each dataset must include the required fields for its chart type:
311
+ - Bar charts: `label` and `data` (both required)
312
+ - Line charts: `label` and `data` (both required)
313
+ - Pie charts: `data` (required)
314
+ 4. All numerical data must be provided as arrays of numbers
315
+ 5. Color values (when provided) must be valid CSS color strings
316
+
97
317
  ### Health Check
98
318
 
99
319
  To verify the tool is working correctly:
@@ -0,0 +1,15 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>Report</title>
7
+ <style> body { font-family: Arial, sans-serif; } img { max-width: 100%; } </style>
8
+ </head>
9
+ <body>
10
+ <h1>Test Report</h1>
11
+ <p>This is a test.</p>
12
+
13
+ </body>
14
+ </html>
15
+
package/detailed-debug.js CHANGED
@@ -2,7 +2,7 @@ const { spawn } = require('child_process');
2
2
 
3
3
  console.log('Detailed debug test...\n');
4
4
 
5
- const child = spawn('npx', ['-y', '@vint.tri/report_gen_mcp@1.0.9'], {
5
+ const child = spawn('npx', ['-y', '@vint.tri/report_gen_mcp@1.0.14'], {
6
6
  stdio: ['pipe', 'pipe', 'pipe']
7
7
  });
8
8
 
@@ -10,6 +10,7 @@ exports.barSchema = zod_1.z.object({
10
10
  label: zod_1.z.string(),
11
11
  data: zod_1.z.array(zod_1.z.number()),
12
12
  backgroundColor: zod_1.z.array(zod_1.z.string()).optional(),
13
+ borderColor: zod_1.z.array(zod_1.z.string()).optional(),
13
14
  })),
14
15
  options: zod_1.z.object({
15
16
  title: zod_1.z.string().optional(),
@@ -9,7 +9,8 @@ exports.lineSchema = zod_1.z.object({
9
9
  datasets: zod_1.z.array(zod_1.z.object({
10
10
  label: zod_1.z.string(),
11
11
  data: zod_1.z.array(zod_1.z.number()),
12
- borderColor: zod_1.z.string().optional(),
12
+ borderColor: zod_1.z.array(zod_1.z.string()).optional(),
13
+ fill: zod_1.z.boolean().optional(),
13
14
  })),
14
15
  options: zod_1.z.object({
15
16
  title: zod_1.z.string().optional(),
@@ -9,6 +9,7 @@ exports.pieSchema = zod_1.z.object({
9
9
  datasets: zod_1.z.array(zod_1.z.object({
10
10
  data: zod_1.z.array(zod_1.z.number()),
11
11
  backgroundColor: zod_1.z.array(zod_1.z.string()).optional(),
12
+ borderColor: zod_1.z.array(zod_1.z.string()).optional(),
12
13
  })),
13
14
  options: zod_1.z.object({
14
15
  title: zod_1.z.string().optional(),
package/dist/index.js CHANGED
@@ -9,9 +9,9 @@ const commander_1 = require("commander");
9
9
  const reportGenerator_1 = require("./utils/reportGenerator");
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const fs_extra_1 = __importDefault(require("fs-extra"));
12
- const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
12
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
13
13
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
14
- const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
14
+ 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());
@@ -52,141 +52,104 @@ commander_1.program
52
52
  const result = await (0, reportGenerator_1.generateReport)(opts.document, charts, opts.output);
53
53
  console.log(result);
54
54
  });
55
- // Handle stdio mode for Claude Desktop integration using MCP SDK
55
+ // Handle stdio mode for Claude Desktop integration
56
56
  if (process.argv.length === 2) {
57
- // No command specified, run in stdio mode with MCP SDK
58
- const server = new index_js_1.Server({
59
- name: 'report-gen-mcp-server',
60
- version: '1.0.9',
57
+ // No command specified, run in stdio mode using MCP SDK
58
+ const mcpServer = new mcp_js_1.McpServer({
59
+ name: "report_gen_mcp",
60
+ version: "1.0.17",
61
61
  }, {
62
+ // Disable health check to prevent automatic calls
62
63
  capabilities: {
63
- tools: {},
64
- },
64
+ tools: {}
65
+ }
65
66
  });
66
- // Setup tool handlers
67
- server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
68
- tools: [
69
- {
70
- name: "generate-report",
71
- description: "Generate an HTML report with embedded charts",
72
- inputSchema: {
73
- type: "object",
74
- properties: {
75
- document: {
76
- type: "string",
77
- description: "Markdown document with chart placeholders [[chart:id]]"
78
- },
79
- charts: {
80
- type: "object",
81
- description: "Chart configurations mapped by ID",
82
- additionalProperties: {
83
- type: "object",
84
- properties: {
85
- type: {
86
- type: "string",
87
- enum: ["bar", "line", "pie"]
88
- },
89
- config: {
90
- type: "object"
91
- }
92
- },
93
- required: ["type", "config"]
94
- }
95
- },
96
- outputFile: {
97
- type: "string",
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)"
103
- }
104
- },
105
- required: ["document", "charts"]
106
- }
107
- },
108
- {
109
- name: "health",
110
- description: "Check if the tool is running correctly",
111
- inputSchema: {
112
- type: "object",
113
- properties: {}
114
- }
115
- }
116
- ]
117
- }));
118
- server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
67
+ // Register the generate-report tool
68
+ mcpServer.registerTool("generate-report", {
69
+ description: "Generate an HTML report with embedded charts",
70
+ inputSchema: {
71
+ document: zod_1.z.string().describe("Markdown document with chart placeholders [[chart:id]]"),
72
+ charts: zod_1.z.record(zod_1.z.object({
73
+ type: zod_1.z.enum(["bar", "line", "pie"]),
74
+ config: zod_1.z.object({
75
+ labels: zod_1.z.array(zod_1.z.string()),
76
+ datasets: zod_1.z.array(zod_1.z.object({
77
+ label: zod_1.z.string().optional(),
78
+ data: zod_1.z.array(zod_1.z.number()),
79
+ backgroundColor: zod_1.z.array(zod_1.z.string()).optional(),
80
+ borderColor: zod_1.z.array(zod_1.z.string()).optional(),
81
+ fill: zod_1.z.boolean().optional(),
82
+ })),
83
+ options: zod_1.z.object({
84
+ title: zod_1.z.string().optional(),
85
+ }).optional(),
86
+ }),
87
+ })).describe("Chart configurations mapped by ID"),
88
+ outputFile: zod_1.z.string().optional().describe("Output HTML file path"),
89
+ tempDirectory: zod_1.z.string().optional().describe("Temporary directory for file storage (defaults to current working directory if not specified)"),
90
+ },
91
+ }, async (params) => {
92
+ const { document, charts, outputFile = 'report.html', tempDirectory = process.cwd() } = params;
93
+ const outputPath = path_1.default.resolve(tempDirectory, outputFile);
119
94
  try {
120
- if (request.params.name === 'generate-report') {
121
- const args = request.params.arguments || {};
122
- const document = typeof args.document === 'string' ? args.document : '';
123
- const charts = (typeof args.charts === 'object' && args.charts !== null) ? args.charts : {};
124
- const outputFile = typeof args.outputFile === 'string' ? args.outputFile : 'report.html';
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');
130
- return {
131
- content: [
132
- {
133
- type: 'text',
134
- text: JSON.stringify({
135
- ...result,
136
- fileContent: fileContent
137
- }),
138
- }
139
- ],
140
- };
141
- }
142
- else if (request.params.name === 'health') {
143
- return {
144
- content: [
145
- {
146
- type: 'text',
147
- text: JSON.stringify({ status: 'ok' }),
148
- }
149
- ],
150
- };
151
- }
152
- else {
153
- return {
154
- content: [
155
- {
156
- type: 'text',
157
- text: JSON.stringify({ error: 'Unknown method' }),
158
- }
159
- ],
160
- isError: true,
161
- };
162
- }
95
+ const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
96
+ return {
97
+ content: [
98
+ {
99
+ type: "text",
100
+ text: JSON.stringify({
101
+ ...result,
102
+ message: "Report generated successfully",
103
+ filePath: outputPath
104
+ })
105
+ }
106
+ ]
107
+ };
163
108
  }
164
109
  catch (error) {
110
+ throw error;
111
+ }
112
+ });
113
+ // Register a new tool to get file path/URL
114
+ mcpServer.registerTool("get-report-url", {
115
+ description: "Get a clickable URL for a generated report file",
116
+ inputSchema: {
117
+ filePath: zod_1.z.string().describe("Full path to the report file")
118
+ },
119
+ }, async (params) => {
120
+ const { filePath } = params;
121
+ try {
122
+ // Check if file exists
123
+ await fs_extra_1.default.access(filePath);
124
+ // Return a file URL that can be clicked to open the file
125
+ const fileUrl = `file://${filePath}`;
165
126
  return {
166
127
  content: [
167
128
  {
168
- type: 'text',
169
- text: JSON.stringify({ error: error.message }),
129
+ type: "text",
130
+ text: JSON.stringify({
131
+ success: true,
132
+ fileUrl: fileUrl,
133
+ message: "Click the URL to open the report",
134
+ filePath: filePath
135
+ })
170
136
  }
171
- ],
172
- isError: true,
137
+ ]
173
138
  };
174
139
  }
140
+ catch (error) {
141
+ throw new Error(`File not found: ${filePath}`);
142
+ }
175
143
  });
176
- // Error handling
177
- server.onerror = (error) => {
178
- console.error('[MCP Error]', error);
179
- };
180
- process.on('SIGINT', async () => {
181
- await server.close();
182
- process.exit(0);
183
- });
184
- // Connect the server to stdio
185
- (async () => {
144
+ async function main() {
186
145
  const transport = new stdio_js_1.StdioServerTransport();
187
- await server.connect(transport);
188
- console.error('Report Generator MCP server running on stdio');
189
- })();
146
+ await mcpServer.connect(transport);
147
+ console.log("MCP server is running...");
148
+ }
149
+ main().catch((error) => {
150
+ console.error("Server error:", error);
151
+ process.exit(1);
152
+ });
190
153
  }
191
154
  else {
192
155
  // Run commander program when arguments are provided
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vint.tri/report_gen_mcp",
3
- "version": "1.0.13",
3
+ "version": "1.0.17",
4
4
  "description": "CLI tool for generating HTML reports with embedded charts",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/charts/bar.ts CHANGED
@@ -8,6 +8,7 @@ export const barSchema = z.object({
8
8
  label: z.string(),
9
9
  data: z.array(z.number()),
10
10
  backgroundColor: z.array(z.string()).optional(),
11
+ borderColor: z.array(z.string()).optional(),
11
12
  })),
12
13
  options: z.object({
13
14
  title: z.string().optional(),
@@ -7,7 +7,8 @@ export const lineSchema = z.object({
7
7
  datasets: z.array(z.object({
8
8
  label: z.string(),
9
9
  data: z.array(z.number()),
10
- borderColor: z.string().optional(),
10
+ borderColor: z.array(z.string()).optional(),
11
+ fill: z.boolean().optional(),
11
12
  })),
12
13
  options: z.object({
13
14
  title: z.string().optional(),
package/src/charts/pie.ts CHANGED
@@ -7,6 +7,7 @@ export const pieSchema = z.object({
7
7
  datasets: z.array(z.object({
8
8
  data: z.array(z.number()),
9
9
  backgroundColor: z.array(z.string()).optional(),
10
+ borderColor: z.array(z.string()).optional(),
10
11
  })),
11
12
  options: z.object({
12
13
  title: z.string().optional(),