Skip to content

Latest commit

 

History

History

README.md

MCP Server: Markdown to HTML

This is an MCP server that converts markdown text to HTML.

Install

Install in VS Code Install in VS Code Insiders Install in Visual Studio

Prerequisites

What's Included

Markdown to HTML MCP server includes:

Building Block Name Description Usage
Tools convert_markdown_to_html Converts markdown document to HTML. #convert_markdown_to_html

Getting Started

Getting repository root

  1. Get the repository root.

    # bash/zsh
    REPOSITORY_ROOT=$(git rev-parse --show-toplevel)
    # PowerShell
    $REPOSITORY_ROOT = git rev-parse --show-toplevel

Running MCP server

On a local machine

  1. Run the MCP server app.

    cd $REPOSITORY_ROOT/markdown-to-html
    dotnet run --project ./src/McpSamples.MarkdownToHtml.HybridApp

    Make sure take note the absolute directory path of the McpSamples.MarkdownToHtml.HybridApp project.

    Parameters:

    • --http: The switch that indicates to run this MCP server as a streamable HTTP type. When this switch is added, the MCP server URL is http://localhost:5280.
    • --tech-community/-tc: The switch that indicates to convert the markdown text to HTML specific to Microsoft Tech Community.
    • --extra-paragraph/-p: The switch that indicates whether to put extra paragraph between the given HTML elements that is defined by the --tags argument.
    • --tags: The comma delimited list of HTML tags that adds extra paragraph in between. Default value is p,blockquote,h1,h2,h3,h4,h5,h6,ol,ul,dl

    With these parameters, you can run the MCP server like:

    dotnet run --project ./src/McpSamples.MarkdownToHtml.HybridApp -- --http -tc -p --tags "p,h1,h2,h3,ol,ul,dl"

In a container

  1. Build the MCP server app as a container image.

    cd $REPOSITORY_ROOT
    docker build -f Dockerfile.markdown-to-html -t markdown-to-html:latest .
  2. Run the MCP server app in a container.

    docker run -i --rm -p 8080:8080 markdown-to-html:latest

    Alternatively, use the container image from the container registry.

    docker run -i --rm -p 8080:8080 ghcr.io/microsoft/mcp-dotnet-samples/markdown-to-html:latest

    Parameters:

    • --http: The switch that indicates to run this MCP server as a streamable HTTP type. When this switch is added, the MCP server URL is http://localhost:8080.
    • --tech-community/-tc: The switch that indicates to convert the markdown text to HTML specific to Microsoft Tech Community.
    • --extra-paragraph/-p: The switch that indicates whether to put extra paragraph between the given HTML elements that is defined by the --tags argument.
    • --tags: The comma delimited list of HTML tags that adds extra paragraph in between. Default value is p,blockquote,h1,h2,h3,h4,h5,h6,ol,ul,dl

    With these parameters, you can run the MCP server like:

    # use local container image
    docker run -i --rm -p 8080:8080 markdown-to-html:latest --http -tc -p --tags "p,h1,h2,h3,ol,ul,dl"
    # use container image from the container registry
    docker run -i --rm -p 8080:8080 ghcr.io/microsoft/mcp-dotnet-samples/markdown-to-html:latest --http -tc -p --tags "p,h1,h2,h3,ol,ul,dl"

On Azure

  1. Navigate to the directory.

    cd $REPOSITORY_ROOT/markdown-to-html
  2. Login to Azure.

    # Login with Azure Developer CLI
    azd auth login
  3. Deploy the MCP server app to Azure.

    azd up

    While provisioning and deploying, you'll be asked to provide subscription ID, location, environment name.

  4. After the deployment is complete, get the information by running the following commands:

    • Azure Container Apps FQDN:

      azd env get-value AZURE_RESOURCE_MCP_MD2HTML_FQDN

Connect MCP server to an MCP host/client

VS Code + Agent Mode + Local MCP server

  1. Copy mcp.json to the repository root.

    For locally running MCP server (STDIO):

    mkdir -p $REPOSITORY_ROOT/.vscode
    cp $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.stdio.local.json \
       $REPOSITORY_ROOT/.vscode/mcp.json
    New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
    Copy-Item -Path $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.stdio.local.json `
              -Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force

    For locally running MCP server (HTTP):

    mkdir -p $REPOSITORY_ROOT/.vscode
    cp $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.local.json \
       $REPOSITORY_ROOT/.vscode/mcp.json
    New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
    Copy-Item -Path $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.local.json `
              -Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force

    For locally running MCP server in a container (STDIO):

    mkdir -p $REPOSITORY_ROOT/.vscode
    cp $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.stdio.container.json \
       $REPOSITORY_ROOT/.vscode/mcp.json
    New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
    Copy-Item -Path $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.stdio.container.json `
              -Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force

    For locally running MCP server in a container (HTTP):

    mkdir -p $REPOSITORY_ROOT/.vscode
    cp $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.container.json \
       $REPOSITORY_ROOT/.vscode/mcp.json
    New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
    Copy-Item -Path $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.container.json `
              -Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force

    For remotely running MCP server in a container (HTTP):

    mkdir -p $REPOSITORY_ROOT/.vscode
    cp $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.remote.json \
       $REPOSITORY_ROOT/.vscode/mcp.json
    New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
    Copy-Item -Path $REPOSITORY_ROOT/markdown-to-html/.vscode/mcp.http.remote.json `
              -Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force
  2. Open Command Palette by typing F1 or Ctrl+Shift+P on Windows or Cmd+Shift+P on Mac OS, and search MCP: List Servers.

  3. Choose markdown-to-html then click Start Server.

  4. When prompted, enter one of the following values:

    • The absolute directory path of the McpSamples.MarkdownToHtml.HybridApp project
    • The FQDN of Azure Container Apps.
  5. Enter prompt like:

    Convert the highlighted markdown text to HTML and save it to `converted.html` at the repository root. DO NOT alter the converted HTML.
    
  6. Confirm the result.