@xjtlumedia/markdown-mcp-server 2.0.0 → 2.1.0

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 (2) hide show
  1. package/dist/index.js +30 -18
  2. package/package.json +14 -3
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
- import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { unified } from 'unified';
6
6
  import remarkParse from 'remark-parse';
7
7
  import remarkGfm from 'remark-gfm';
@@ -943,6 +943,9 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
943
943
  throw new Error(`Unknown prompt: ${name}`);
944
944
  });
945
945
  // ── Resources ────────────────────────────────────────────────────────
946
+ server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
947
+ return { resourceTemplates: [] };
948
+ });
946
949
  server.setRequestHandler(ListResourcesRequestSchema, async () => {
947
950
  return {
948
951
  resources: [
@@ -1106,6 +1109,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1106
1109
  if (!markdown && !noMarkdownTools.includes(name)) {
1107
1110
  throw new Error("Markdown content is required");
1108
1111
  }
1112
+ // Guard against oversized inputs to prevent runaway memory/CPU usage
1113
+ const MAX_INPUT_BYTES = 1024 * 1024 * 1024; // 1 GB
1114
+ const inputToCheck = markdown ?? args.html ?? '';
1115
+ if (Buffer.byteLength(inputToCheck, 'utf8') > MAX_INPUT_BYTES) {
1116
+ throw new Error('Input too large: content exceeds the 1 GB limit. Please split the document into smaller sections.');
1117
+ }
1109
1118
  if (name === "harmonize_markdown") {
1110
1119
  const file = await unified()
1111
1120
  .use(remarkParse)
@@ -1196,25 +1205,28 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1196
1205
  return handleOutput(htmlDoc, outputPath);
1197
1206
  }
1198
1207
  const browser = await puppeteer.launch({ headless: true, executablePath: await findChrome() });
1199
- const page = await browser.newPage();
1200
- await page.setContent(htmlDoc);
1201
- let resultBuffer;
1202
- if (name === "convert_to_pdf") {
1203
- resultBuffer = await page.pdf({ format: 'A4' });
1204
- await browser.close();
1205
- return handleOutput(resultBuffer, outputPath, {
1206
- format: 'pdf',
1207
- description: 'PDF document generated from Markdown via Puppeteer'
1208
- });
1208
+ try {
1209
+ const page = await browser.newPage();
1210
+ await page.setContent(htmlDoc);
1211
+ let resultBuffer;
1212
+ if (name === "convert_to_pdf") {
1213
+ resultBuffer = await page.pdf({ format: 'A4' });
1214
+ return handleOutput(resultBuffer, outputPath, {
1215
+ format: 'pdf',
1216
+ description: 'PDF document generated from Markdown via Puppeteer'
1217
+ });
1218
+ }
1219
+ else {
1220
+ const screenshot = await page.screenshot({ fullPage: true, encoding: 'binary' });
1221
+ resultBuffer = screenshot;
1222
+ return handleOutput(resultBuffer, outputPath, {
1223
+ format: 'png',
1224
+ description: 'PNG image screenshot of the rendered Markdown'
1225
+ });
1226
+ }
1209
1227
  }
1210
- else {
1211
- const screenshot = await page.screenshot({ fullPage: true, encoding: 'binary' });
1212
- resultBuffer = screenshot;
1228
+ finally {
1213
1229
  await browser.close();
1214
- return handleOutput(resultBuffer, outputPath, {
1215
- format: 'png',
1216
- description: 'PNG image screenshot of the rendered Markdown'
1217
- });
1218
1230
  }
1219
1231
  }
1220
1232
  // New tools: convert_to_md and generate_html
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xjtlumedia/markdown-mcp-server",
3
- "version": "2.0.0",
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.",
3
+ "version": "2.1.0",
4
+ "description": "AI Answer Copier — MCP Server with 33 tools: convert Markdown to 23+ formats (PDF, DOCX, HTML, Slack, Discord, JIRA, Confluence, AsciiDoc, RST, MediaWiki, BBCode, Textile, Org Mode, Email HTML, and more), plus document analysis, repair/lint, and HTML import.",
5
5
  "mcpName": "io.github.XJTLUmedia/markdown-formatter",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -37,7 +37,18 @@
37
37
  "lms",
38
38
  "claude",
39
39
  "copilot",
40
- "ai-tools"
40
+ "ai-tools",
41
+ "slack",
42
+ "discord",
43
+ "jira",
44
+ "confluence",
45
+ "asciidoc",
46
+ "rst",
47
+ "mediawiki",
48
+ "bbcode",
49
+ "lint",
50
+ "repair",
51
+ "document-analysis"
41
52
  ],
42
53
  "author": "XJTLUmedia",
43
54
  "license": "MIT",