@xjtlumedia/markdown-mcp-server 1.0.3 → 1.0.5
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 +29 -2
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -11,11 +11,38 @@ import remarkStringify from 'remark-stringify';
|
|
|
11
11
|
import remarkRehype from 'remark-rehype';
|
|
12
12
|
import rehypeKatex from 'rehype-katex';
|
|
13
13
|
import rehypeStringify from 'rehype-stringify';
|
|
14
|
-
import puppeteer from 'puppeteer';
|
|
14
|
+
import puppeteer from 'puppeteer-core';
|
|
15
15
|
import * as fs from 'fs/promises';
|
|
16
16
|
import * as path from 'path';
|
|
17
|
+
import * as os from 'os';
|
|
17
18
|
import { parseMarkdownToRTF, parseMarkdownToDocx, parseMarkdownToLaTeX, generateCSV, generateJSON, generateXML, generateXLSXIndex, cleanMarkdownText } from "./core-exports.js";
|
|
18
19
|
import { Packer } from "docx";
|
|
20
|
+
// Find Chrome/Chromium executable on the system
|
|
21
|
+
async function findChrome() {
|
|
22
|
+
const platform = os.platform();
|
|
23
|
+
const candidates = [];
|
|
24
|
+
if (platform === 'win32') {
|
|
25
|
+
const programFiles = process.env['PROGRAMFILES'] || 'C:\\Program Files';
|
|
26
|
+
const programFilesX86 = process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)';
|
|
27
|
+
const localAppData = process.env['LOCALAPPDATA'] || '';
|
|
28
|
+
candidates.push(path.join(programFiles, 'Google', 'Chrome', 'Application', 'chrome.exe'), path.join(programFilesX86, 'Google', 'Chrome', 'Application', 'chrome.exe'), path.join(localAppData, 'Google', 'Chrome', 'Application', 'chrome.exe'), path.join(programFiles, 'Microsoft', 'Edge', 'Application', 'msedge.exe'), path.join(programFilesX86, 'Microsoft', 'Edge', 'Application', 'msedge.exe'));
|
|
29
|
+
}
|
|
30
|
+
else if (platform === 'darwin') {
|
|
31
|
+
candidates.push('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', '/Applications/Chromium.app/Contents/MacOS/Chromium');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
candidates.push('/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium', '/usr/bin/chromium-browser', '/snap/bin/chromium');
|
|
35
|
+
}
|
|
36
|
+
for (const candidate of candidates) {
|
|
37
|
+
try {
|
|
38
|
+
await fs.access(candidate);
|
|
39
|
+
return candidate;
|
|
40
|
+
}
|
|
41
|
+
catch { /* not found, try next */ }
|
|
42
|
+
}
|
|
43
|
+
throw new Error('No Chrome/Chromium/Edge browser found. PDF and PNG export require a Chromium-based browser. ' +
|
|
44
|
+
'Please install Google Chrome, Microsoft Edge, or Chromium.');
|
|
45
|
+
}
|
|
19
46
|
const server = new Server({
|
|
20
47
|
name: "markdown-formatter-mcp",
|
|
21
48
|
version: "1.0.0",
|
|
@@ -293,7 +320,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
293
320
|
if (name === "convert_to_html") {
|
|
294
321
|
return handleOutput(htmlDoc, outputPath);
|
|
295
322
|
}
|
|
296
|
-
const browser = await puppeteer.launch({ headless: true });
|
|
323
|
+
const browser = await puppeteer.launch({ headless: true, executablePath: await findChrome() });
|
|
297
324
|
const page = await browser.newPage();
|
|
298
325
|
await page.setContent(htmlDoc);
|
|
299
326
|
let resultBuffer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xjtlumedia/markdown-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "AI Answer Copier — MCP Server that converts Markdown to 14 formats: PDF, DOCX, HTML, LaTeX, CSV, JSON, XML, XLSX, RTF, PNG and more. Built for educators and developers.",
|
|
5
5
|
"mcpName": "io.github.XJTLUmedia/markdown-formatter",
|
|
6
6
|
"type": "module",
|
|
@@ -50,9 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@modelcontextprotocol/sdk": "^0.6.0",
|
|
53
|
-
"@types/node": "^20.11.0",
|
|
54
53
|
"docx": "^9.5.1",
|
|
55
|
-
"puppeteer": "^23.
|
|
54
|
+
"puppeteer-core": "^23.11.1",
|
|
56
55
|
"rehype-katex": "^7.0.0",
|
|
57
56
|
"rehype-parse": "^9.0.0",
|
|
58
57
|
"rehype-stringify": "^10.0.0",
|
|
@@ -61,10 +60,13 @@
|
|
|
61
60
|
"remark-parse": "^11.0.0",
|
|
62
61
|
"remark-rehype": "^11.1.0",
|
|
63
62
|
"remark-stringify": "^11.0.0",
|
|
64
|
-
"tsx": "^4.7.1",
|
|
65
|
-
"typescript": "^5.3.3",
|
|
66
63
|
"unified": "^11.0.5",
|
|
67
64
|
"xlsx": "^0.18.5",
|
|
68
65
|
"zod": "^3.23.8"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^20.11.0",
|
|
69
|
+
"tsx": "^4.7.1",
|
|
70
|
+
"typescript": "^5.3.3"
|
|
69
71
|
}
|
|
70
|
-
}
|
|
72
|
+
}
|