Skip to main content
Glama
fashionzzZ

markdown-to-html

by fashionzzZ

markdown_to_html

Convert Markdown content into HTML format using this tool. Ideal for developers and content creators looking to transform text for web integration.

Instructions

Convert Markdown to HTML

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mdContentYesMarkdown content to convert

Implementation Reference

  • Core implementation of Markdown to HTML conversion using marked.js with custom renderer that supports themes, syntax highlighting, footnotes, and styling.
    export const renderMarkdown = (
      markdownText: string,
      themeStyles?: ThemeStyles,
      fontFamily?: string,
      fontSize?: string
    ): string => {
      // 创建基础样式
      const baseStyles = createBaseStyles(themeStyles, fontFamily, fontSize);
    
      // 获取渲染器和脚注处理器
      const { renderer, generateFootnotesHtml } = createMarkdownRenderer(themeStyles, baseStyles);
    
      // 配置渲染器
      marked.use({ renderer });
    
      // 渲染Markdown
      const rawHtml = marked.parse(markdownText) as string;
    
      // 获取脚注HTML
      const footnotesHtml = generateFootnotesHtml();
    
      // 组合HTML内容
      const combinedHtml = rawHtml + footnotesHtml;
    
      // 处理首段落的margin
      const modifiedHtml = adjustFirstParagraphMargin(combinedHtml);
    
      // 包装并返回
      return wrappedHtml(modifiedHtml);
    };
  • MCP CallTool request handler specifically for 'markdown_to_html' tool, validates input, calls renderMarkdown, and returns HTML content.
      this.server.setRequestHandler(
        CallToolRequestSchema,
        async (request) => {
          if (request.params.name !== "markdown_to_html") {
            throw new McpError(
              ErrorCode.MethodNotFound,
              `Unknown tool: ${request.params.name}`
            );
          }
    
          if (!request.params.arguments) {
            throw new McpError(ErrorCode.InvalidParams, "Missing request arguments");
          }
    
          const mdContent = request.params.arguments.mdContent;
    
          if (typeof mdContent !== 'string') {
            throw new McpError(ErrorCode.InvalidParams, "mdContent must be a string");
          }
    
          try {
            const htmlContent = renderMarkdown(mdContent, themes.grace, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE);
            
            return {
              content: [{
                type: "text",
                text: htmlContent
              }]
            };
          } catch (error) {
            throw error;
          }
        }
      );
    }
  • src/index.ts:60-78 (registration)
    Registers the 'markdown_to_html' tool in the ListTools response, including name, description, and input schema.
    this.server.setRequestHandler(
      ListToolsRequestSchema,
      async () => ({
        tools: [{
          name: "markdown_to_html",
          description: "Convert Markdown to HTML",
          inputSchema: {
            type: "object",
            properties: {
              mdContent: {
                type: "string",
                description: "Markdown content to convert",
              }
            },
            required: ["mdContent"]
          }
        }]
      })
    );
  • Input schema definition for the markdown_to_html tool, requiring a 'mdContent' string property.
    inputSchema: {
      type: "object",
      properties: {
        mdContent: {
          type: "string",
          description: "Markdown content to convert",
        }
      },
      required: ["mdContent"]
    }
  • Theme definitions used in rendering, with 'grace' theme specifically used in the tool handler.
    export const themes = {
      default: defaultTheme,
      classic: classicTheme,
      grace: graceTheme,
      simple: simpleTheme,
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the conversion action without mentioning any behavioral traits such as error handling, performance characteristics, or output format details. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Convert Markdown to HTML' is extremely concise and front-loaded, consisting of a single, clear sentence that directly communicates the tool's purpose without any unnecessary words. Every part of the description earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that performs data transformation. It fails to explain what the output looks like (e.g., HTML string), potential limitations, or error conditions, leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'mdContent' clearly documented as 'Markdown content to convert'. The description does not add any additional meaning beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Convert Markdown to HTML' clearly states the tool's function with a specific verb ('Convert') and resource ('Markdown to HTML'), making the purpose immediately understandable. However, with no sibling tools mentioned, there's no opportunity to distinguish from alternatives, which prevents a perfect score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or any contextual prerequisites. It simply states what the tool does without indicating scenarios for its application, leaving usage entirely implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fashionzzZ/markdown-to-html'

If you have feedback or need assistance with the MCP directory API, please join our Discord server