QR Code Generator MCP server

Generates QR codes from any text including Chinese characters with customizable styling options like colors, box size, and borders, returning base64-encoded images for document generation, contact sharing, and URL shortening workflows.
Back to servers
Setup instructions
Provider
niu_he
Release date
Jul 04, 2025
Stats
6 stars

This QR code generation MCP server allows you to create customizable QR codes from text, supporting multiple transport modes and offering a convenient way to integrate QR code functionality into your applications.

Installation

You can install the required dependencies using either UV or pip:

uv sync
# or
pip install qrcode Pillow mcp

Running the Server

Docker Deployment

Building the Docker Image

docker build -t qrcode-mcp .

Running the Container

# Default SSE mode
docker run -p 8008:8008 qrcode-mcp

# HTTP mode
docker run -p 8008:8008 -e TRANSPORT_MODE=http qrcode-mcp

# STDIO mode (for testing)
docker run -e TRANSPORT_MODE=stdio qrcode-mcp

# Custom host and port
docker run -p 9000:9000 -e TRANSPORT_MODE=http -e HOST=0.0.0.0 -e PORT=9000 qrcode-mcp

Environment Variables

  • TRANSPORT_MODE: Transport mode (sse, http, stdio), default: sse
  • HOST: Host address to bind, default: 0.0.0.0
  • PORT: Port to bind, default: 8008

Using Docker Compose

version: '3.8'
services:
  qrcode-mcp:
    build: .
    ports:
      - "8008:8008"
    environment:
      - TRANSPORT_MODE=sse
      - HOST=0.0.0.0
      - PORT=8008

Running Without Docker

You can start the server directly using Python with different transport modes:

# STDIO mode (for Claude Desktop)
python qrcode_mcp_server.py

# HTTP mode
python qrcode_mcp_server.py --http --host 127.0.0.1 --port 8008

# SSE mode (Server-Sent Events)
python qrcode_mcp_server.py --sse --host 127.0.0.1 --port 8008

Configuring Claude Desktop

Add the MCP server configuration to Claude Desktop's configuration file located at ~/Library/Application Support/Claude/claude_desktop_config.json:

STDIO Mode (Local Use)

{
  "mcpServers": {
    "qrcode-mcp": {
      "command": "python",
      "args": ["/ABSOLUTE/PATH/TO/qrcode_mcp/qrcode_mcp_server.py"],
      "cwd": "/ABSOLUTE/PATH/TO/qrcode_mcp"
    }
  }
}

HTTP Mode (Network Deployment)

{
  "mcpServers": {
    "qrcode-mcp": {
      "transport": "http",
      "url": "http://127.0.0.1:8008/mcp/"
    }
  }
}

SSE Mode (Server-Sent Events)

{
  "mcpServers": {
    "qrcode-mcp": {
      "serverUrl": "http://127.0.0.1:8008/sse"
    }
  }
}

Using the Python API Directly

You can also use the QR code generation functionality directly in your Python code:

from qrcode_utils import text_to_qr_base64

# Basic usage
base64_result = text_to_qr_base64("Hello, World!")

# Custom styling
base64_result = text_to_qr_base64(
    "Custom QR Code",
    box_size=15,
    fill_color="darkblue",
    back_color="lightgray"
)

MCP Tool Parameters

generate_qr_code

This tool generates a QR code and returns its base64 encoding.

Parameters:

  • text (required): Text content to convert to QR code
  • box_size (optional): Pixel size of each box, default 10
  • border (optional): Number of border boxes, default 4
  • fill_color (optional): Foreground color, default "black"
  • back_color (optional): Background color, default "white"
  • return_data_url (optional): Whether to return Data URL format, default false

Testing

You can test the MCP client with:

python test_mcp_client.py

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "qrcode-mcp" '{"command":"python","args":["/ABSOLUTE/PATH/TO/qrcode_mcp/qrcode_mcp_server.py"],"cwd":"/ABSOLUTE/PATH/TO/qrcode_mcp"}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "qrcode-mcp": {
            "command": "python",
            "args": [
                "/ABSOLUTE/PATH/TO/qrcode_mcp/qrcode_mcp_server.py"
            ],
            "cwd": "/ABSOLUTE/PATH/TO/qrcode_mcp"
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "qrcode-mcp": {
            "command": "python",
            "args": [
                "/ABSOLUTE/PATH/TO/qrcode_mcp/qrcode_mcp_server.py"
            ],
            "cwd": "/ABSOLUTE/PATH/TO/qrcode_mcp"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later