it-tools-mcp
Version:
Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities
44 lines (43 loc) • 1.44 kB
JavaScript
import { z } from "zod";
export function registerConvertHtmlMarkdown(server) {
server.registerTool("convert_html_to_markdown", {
description: "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",
description: "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'}`,
},
],
};
}
});
}