hub-qrcode-mcp

stefan-d-p/hub-qrcode-mcp

3.2

If you are the rightful owner of hub-qrcode-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

An MCP server that generates QR codes as PNG data URIs for various applications.

Tools
5
Resources
0
Prompts
0

QR Code MCP Server

An MCP (Model Context Protocol) server that provides tools for generating various types of QR codes as PNG data URIs.

Features

This server exposes five tools for generating QR codes:

  • URL QR Codes - Direct users to websites when scanned
  • vCard QR Codes - Share contact information that can be saved to address books
  • Email QR Codes - Pre-fill email composition with recipient, subject, and body
  • SMS QR Codes - Pre-fill text messages with phone number and message
  • WiFi QR Codes - Allow automatic WiFi network connection

All QR codes are returned as PNG data URIs that can be directly embedded in HTML or displayed by AI assistants.

Tool Usage Examples

Once configured, you can ask Claude to generate QR codes:

  • "Generate a QR code for https://example.com"
  • "Create a vCard QR code for John Doe, phone: 555-0123, email: john@example.com"
  • "Make a WiFi QR code for network MyWiFi with password SecurePass123"
  • "Generate an SMS QR code to 555-0199 with message: Hello there"
  • "Create an email QR code for support@example.com with subject: Help Request"

How It Works

The server uses the qrcode library with PIL (Pillow) to generate QR code images. Each tool function constructs the appropriate data format for its QR code type (URL, vCard, mailto URI, SMS URI, or WiFi string), generates the QR code, converts it to a PNG image in memory, encodes it as base64, and wraps it in a data URI format.

The data URI format (data:image/png;base64,...) allows the QR code to be directly embedded without needing to save files to disk or serve them from a web server.

Development

The project structure is simple:

  • server.py - Main MCP server implementation with all tool definitions
  • pyproject.toml - Project metadata and dependencies managed by uv
  • README.md - This file

To add new QR code types, create a new function decorated with @mcp.tool(), construct the appropriate data string for that QR code type, and call the qr_to_data_uri() helper function.

Error Correction

QR codes include error correction capabilities that allow them to be scanned even if partially damaged. This server uses the default "L" (Low) level which provides approximately 7% error recovery. For more critical applications where QR codes might be damaged or degraded, you can modify the qr_to_data_uri() function to use higher error correction levels:

  • ERROR_CORRECT_L - Low (7% recovery)
  • ERROR_CORRECT_M - Medium (15% recovery)
  • ERROR_CORRECT_Q - Quartile (25% recovery)
  • ERROR_CORRECT_H - High (30% recovery)

Higher error correction levels result in larger, denser QR codes.