@vint.tri/report_gen_mcp 1.0.14 → 1.0.18
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/README.md +252 -13
- package/debug-report.html +15 -0
- package/detailed-debug.js +1 -1
- package/dist/charts/bar.js +1 -0
- package/dist/charts/line.js +2 -1
- package/dist/charts/pie.js +1 -0
- package/dist/index.js +86 -104
- package/package.json +1 -1
- package/src/charts/bar.ts +1 -0
- package/src/charts/line.ts +2 -1
- package/src/charts/pie.ts +1 -0
- package/src/index.ts +91 -117
- package/CLAUDE_DESKTOP_FIX_INSTRUCTIONS.md +0 -75
- package/CLAUDE_DESKTOP_INTEGRATION_SUMMARY.md +0 -156
- package/CLAUDE_DESKTOP_README.md +0 -88
- package/USAGE_SUMMARY.md +0 -123
- package/claude-desktop-config.json +0 -14
- package/claude-desktop-corrected-config.json +0 -35
- package/claude-desktop-final-config.json +0 -14
- package/claude-desktop-simulation.js +0 -154
- package/cli-test-report.html +0 -21
- package/debug-method.js +0 -67
- package/debug-stdio.js +0 -65
- package/generated-report.html +0 -1
- package/npx-test-report.html +0 -15
- package/package-test-report.html +0 -19
- package/report.html +0 -15
- package/republished-test-report.html +0 -14
- package/simple-test.js +0 -35
- package/stdio-test-report.html +0 -19
- package/test-charts.json +0 -29
- package/test-claude-full-functionality.js +0 -161
- package/test-claude-stdio.js +0 -44
- package/test-cli-report-fixed.html +0 -14
- package/test-cli-report.html +0 -0
- package/test-document.md +0 -15
- package/test-list-tools.js +0 -35
- package/test-local-installed.js +0 -36
- package/test-local-list-tools.js +0 -36
- package/test-local-stdio.js +0 -34
- package/test-new-command.js +0 -39
- package/test-npx-command.js +0 -39
- package/test-npx-explicit-version.js +0 -36
- package/test-npx-stdio.js +0 -39
- package/test-package.js +0 -33
- package/test-report.html +0 -15
- package/test-report.json +0 -22
- package/test-stdio-direct.js +0 -31
- package/test-stdio-full.js +0 -61
- package/test-stdio.js +0 -28
- package/verify-claude-integration.js +0 -231
- 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.
|
|
20
|
+
npm install -g @vint.tri/report_gen_mcp@1.0.18
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Direct Execution with npx
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
npx @vint.tri/report_gen_mcp@1.0.
|
|
26
|
+
npx @vint.tri/report_gen_mcp@1.0.18
|
|
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.
|
|
67
|
+
"@vint.tri/report_gen_mcp@1.0.18"
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
Once configured, Claude can generate reports by sending requests
|
|
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:
|
|
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
|
-
"
|
|
121
|
+
"sales": {
|
|
82
122
|
"type": "bar",
|
|
83
123
|
"config": {
|
|
84
|
-
"labels": ["
|
|
85
|
-
"datasets": [
|
|
86
|
-
|
|
87
|
-
|
|
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:
|
|
@@ -130,8 +350,9 @@ npm test
|
|
|
130
350
|
### Methods
|
|
131
351
|
|
|
132
352
|
1. `generate-report`: Creates an HTML report with embedded charts
|
|
133
|
-
2. `
|
|
134
|
-
3. `
|
|
353
|
+
2. `get-report-url`: Returns a clickable URL for a generated report file
|
|
354
|
+
3. `health`: Checks if the tool is running correctly
|
|
355
|
+
4. `mcp:list-tools`: Returns available tools (used by Claude Desktop)
|
|
135
356
|
|
|
136
357
|
### Method Details
|
|
137
358
|
|
|
@@ -143,6 +364,7 @@ npm test
|
|
|
143
364
|
- `type` (string): Chart type ("bar", "line", or "pie")
|
|
144
365
|
- `config` (object): Chart.js configuration object
|
|
145
366
|
- `outputFile` (string, optional): Output HTML file path (defaults to "report.html")
|
|
367
|
+
- `tempDirectory` (string, optional): Temporary directory for file storage (defaults to current working directory if not specified)
|
|
146
368
|
|
|
147
369
|
**Response:**
|
|
148
370
|
```json
|
|
@@ -153,6 +375,23 @@ npm test
|
|
|
153
375
|
}
|
|
154
376
|
```
|
|
155
377
|
|
|
378
|
+
#### get-report-url
|
|
379
|
+
|
|
380
|
+
**Description:** Get a clickable URL for a generated report file
|
|
381
|
+
|
|
382
|
+
**Parameters:**
|
|
383
|
+
- `filePath` (string): Full path to the report file
|
|
384
|
+
|
|
385
|
+
**Response:**
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"success": true,
|
|
389
|
+
"fileUrl": "file:///absolute/path/to/report.html",
|
|
390
|
+
"message": "Click the URL to open the report",
|
|
391
|
+
"filePath": "/absolute/path/to/report.html"
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
156
395
|
#### health
|
|
157
396
|
|
|
158
397
|
**Response:**
|
|
@@ -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.
|
|
5
|
+
const child = spawn('npx', ['-y', '@vint.tri/report_gen_mcp@1.0.14'], {
|
|
6
6
|
stdio: ['pipe', 'pipe', 'pipe']
|
|
7
7
|
});
|
|
8
8
|
|
package/dist/charts/bar.js
CHANGED
|
@@ -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(),
|
package/dist/charts/line.js
CHANGED
|
@@ -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(),
|
package/dist/charts/pie.js
CHANGED
|
@@ -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,10 @@ 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
|
|
12
|
+
const os_1 = __importDefault(require("os"));
|
|
13
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
13
14
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
14
|
-
const
|
|
15
|
+
const zod_1 = require("zod");
|
|
15
16
|
const app = (0, express_1.default)();
|
|
16
17
|
const port = 3000;
|
|
17
18
|
app.use(express_1.default.json());
|
|
@@ -52,123 +53,104 @@ commander_1.program
|
|
|
52
53
|
const result = await (0, reportGenerator_1.generateReport)(opts.document, charts, opts.output);
|
|
53
54
|
console.log(result);
|
|
54
55
|
});
|
|
55
|
-
// Handle stdio mode for Claude Desktop integration
|
|
56
|
+
// Handle stdio mode for Claude Desktop integration
|
|
56
57
|
if (process.argv.length === 2) {
|
|
57
|
-
// No command specified, run in stdio mode
|
|
58
|
-
const
|
|
59
|
-
name:
|
|
60
|
-
version:
|
|
58
|
+
// No command specified, run in stdio mode using MCP SDK
|
|
59
|
+
const mcpServer = new mcp_js_1.McpServer({
|
|
60
|
+
name: "report_gen_mcp",
|
|
61
|
+
version: "1.0.18",
|
|
61
62
|
}, {
|
|
63
|
+
// Disable health check to prevent automatic calls
|
|
62
64
|
capabilities: {
|
|
63
|
-
tools: {}
|
|
64
|
-
}
|
|
65
|
+
tools: {}
|
|
66
|
+
}
|
|
65
67
|
});
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}));
|
|
110
|
-
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
68
|
+
// Register the generate-report tool
|
|
69
|
+
mcpServer.registerTool("generate-report", {
|
|
70
|
+
description: "Generate an HTML report with embedded charts",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
document: zod_1.z.string().describe("Markdown document with chart placeholders [[chart:id]]"),
|
|
73
|
+
charts: zod_1.z.record(zod_1.z.object({
|
|
74
|
+
type: zod_1.z.enum(["bar", "line", "pie"]),
|
|
75
|
+
config: zod_1.z.object({
|
|
76
|
+
labels: zod_1.z.array(zod_1.z.string()),
|
|
77
|
+
datasets: zod_1.z.array(zod_1.z.object({
|
|
78
|
+
label: zod_1.z.string().optional(),
|
|
79
|
+
data: zod_1.z.array(zod_1.z.number()),
|
|
80
|
+
backgroundColor: zod_1.z.array(zod_1.z.string()).optional(),
|
|
81
|
+
borderColor: zod_1.z.array(zod_1.z.string()).optional(),
|
|
82
|
+
fill: zod_1.z.boolean().optional(),
|
|
83
|
+
})),
|
|
84
|
+
options: zod_1.z.object({
|
|
85
|
+
title: zod_1.z.string().optional(),
|
|
86
|
+
}).optional(),
|
|
87
|
+
}),
|
|
88
|
+
})).describe("Chart configurations mapped by ID"),
|
|
89
|
+
outputFile: zod_1.z.string().optional().describe("Output HTML file path"),
|
|
90
|
+
tempDirectory: zod_1.z.string().optional().describe("Temporary directory for file storage (defaults to system temporary directory if not specified)"),
|
|
91
|
+
},
|
|
92
|
+
}, async (params) => {
|
|
93
|
+
const { document, charts, outputFile = 'report.html', tempDirectory = os_1.default.tmpdir() } = params;
|
|
94
|
+
const outputPath = path_1.default.resolve(tempDirectory, outputFile);
|
|
111
95
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type: 'text',
|
|
126
|
-
text: JSON.stringify({
|
|
127
|
-
...result,
|
|
128
|
-
fileContent: fileContent
|
|
129
|
-
}),
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return {
|
|
136
|
-
content: [
|
|
137
|
-
{
|
|
138
|
-
type: 'text',
|
|
139
|
-
text: JSON.stringify({ error: 'Unknown method' }),
|
|
140
|
-
}
|
|
141
|
-
],
|
|
142
|
-
isError: true,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
96
|
+
const result = await (0, reportGenerator_1.generateReport)(document, charts, outputPath);
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: "text",
|
|
101
|
+
text: JSON.stringify({
|
|
102
|
+
...result,
|
|
103
|
+
message: "Report generated successfully",
|
|
104
|
+
filePath: outputPath
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
};
|
|
145
109
|
}
|
|
146
110
|
catch (error) {
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
// Register a new tool to get file path/URL
|
|
115
|
+
mcpServer.registerTool("get-report-url", {
|
|
116
|
+
description: "Get a clickable URL for a generated report file",
|
|
117
|
+
inputSchema: {
|
|
118
|
+
filePath: zod_1.z.string().describe("Full path to the report file")
|
|
119
|
+
},
|
|
120
|
+
}, async (params) => {
|
|
121
|
+
const { filePath } = params;
|
|
122
|
+
try {
|
|
123
|
+
// Check if file exists
|
|
124
|
+
await fs_extra_1.default.access(filePath);
|
|
125
|
+
// Return a file URL that can be clicked to open the file
|
|
126
|
+
const fileUrl = `file://${filePath}`;
|
|
147
127
|
return {
|
|
148
128
|
content: [
|
|
149
129
|
{
|
|
150
|
-
type:
|
|
151
|
-
text: JSON.stringify({
|
|
130
|
+
type: "text",
|
|
131
|
+
text: JSON.stringify({
|
|
132
|
+
success: true,
|
|
133
|
+
fileUrl: fileUrl,
|
|
134
|
+
message: "Click the URL to open the report",
|
|
135
|
+
filePath: filePath
|
|
136
|
+
})
|
|
152
137
|
}
|
|
153
|
-
]
|
|
154
|
-
isError: true,
|
|
138
|
+
]
|
|
155
139
|
};
|
|
156
140
|
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw new Error(`File not found: ${filePath}`);
|
|
143
|
+
}
|
|
157
144
|
});
|
|
158
|
-
|
|
159
|
-
server.onerror = (error) => {
|
|
160
|
-
console.error('[MCP Error]', error);
|
|
161
|
-
};
|
|
162
|
-
process.on('SIGINT', async () => {
|
|
163
|
-
await server.close();
|
|
164
|
-
process.exit(0);
|
|
165
|
-
});
|
|
166
|
-
// Connect the server to stdio
|
|
167
|
-
(async () => {
|
|
145
|
+
async function main() {
|
|
168
146
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
169
|
-
await
|
|
170
|
-
console.
|
|
171
|
-
}
|
|
147
|
+
await mcpServer.connect(transport);
|
|
148
|
+
console.log("MCP server is running...");
|
|
149
|
+
}
|
|
150
|
+
main().catch((error) => {
|
|
151
|
+
console.error("Server error:", error);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
});
|
|
172
154
|
}
|
|
173
155
|
else {
|
|
174
156
|
// Run commander program when arguments are provided
|
package/package.json
CHANGED
package/src/charts/bar.ts
CHANGED
package/src/charts/line.ts
CHANGED
|
@@ -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