UNPKG

it-tools-mcp

Version:

MCP-compliant server access to over 100 IT tools and utilities commonly used by developers, system administrators, and IT professionals.

42 lines (41 loc) 1.34 kB
import { z } from "zod"; export function registerConvertHtmlMarkdown(server) { server.registerTool("convert_html_to_markdown", { inputSchema: { html: z.string().describe("HTML content to convert to Markdown"), }, // VS Code compliance annotations annotations: { title: "Convert Html To Markdown", readOnlyHint: false } }, async ({ html }) => { try { const TurndownService = (await import("turndown")).default; const turndownService = new TurndownService({ headingStyle: 'atx', codeBlockStyle: 'fenced', emDelimiter: '*', }); const markdown = turndownService.turndown(html); return { content: [ { type: "text", text: `Markdown result:\n${markdown}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting HTML to Markdown: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }); }