markdown-to-html
Convert Markdown content to HTML using this utility. Ideal for developers and system administrators needing quick transformations for web or documentation purposes.
Instructions
Convert Markdown to HTML
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| markdown | Yes | Markdown content to convert to HTML |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"markdown": {
"description": "Markdown content to convert to HTML",
"type": "string"
}
},
"required": [
"markdown"
],
"type": "object"
}
Implementation Reference
- The handler function that performs the core logic of converting Markdown to HTML using the 'marked' library with GFM support and line breaks. Returns formatted HTML or error message.}, async ({ markdown }) => { try { const { marked } = await import("marked"); const html = marked(markdown, { breaks: true, gfm: true }); return { content: [ { type: "text", text: `HTML result:\n${html}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting Markdown to HTML: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }
- Zod input schema defining the 'markdown' parameter as a string.inputSchema: { markdown: z.string().describe("Markdown content to convert to HTML"), },
- src/tools/data_format/convert_markdown_to_html/index.ts:4-44 (registration)The registration function that registers the tool named 'convert_markdown_to_html' with the MCP server, including description, input schema, annotations, and handler.export function registerConvertMarkdownHtml(server: McpServer) { server.registerTool("convert_markdown_to_html", { description: "Convert Markdown to HTML", inputSchema: { markdown: z.string().describe("Markdown content to convert to HTML"), }, // VS Code compliance annotations annotations: { title: "Convert Markdown To Html", description: "Convert Markdown to HTML", readOnlyHint: false } }, async ({ markdown }) => { try { const { marked } = await import("marked"); const html = marked(markdown, { breaks: true, gfm: true }); return { content: [ { type: "text", text: `HTML result:\n${html}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error converting Markdown to HTML: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } ); }