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.
You can install the required dependencies using either UV or pip:
uv sync
# or
pip install qrcode Pillow mcp
docker build -t qrcode-mcp .
# 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
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
version: '3.8'
services:
qrcode-mcp:
build: .
ports:
- "8008:8008"
environment:
- TRANSPORT_MODE=sse
- HOST=0.0.0.0
- PORT=8008
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
Add the MCP server configuration to Claude Desktop's configuration file located at ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"qrcode-mcp": {
"command": "python",
"args": ["/ABSOLUTE/PATH/TO/qrcode_mcp/qrcode_mcp_server.py"],
"cwd": "/ABSOLUTE/PATH/TO/qrcode_mcp"
}
}
}
{
"mcpServers": {
"qrcode-mcp": {
"transport": "http",
"url": "http://127.0.0.1:8008/mcp/"
}
}
}
{
"mcpServers": {
"qrcode-mcp": {
"serverUrl": "http://127.0.0.1:8008/sse"
}
}
}
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"
)
This tool generates a QR code and returns its base64 encoding.
Parameters:
text
(required): Text content to convert to QR codebox_size
(optional): Pixel size of each box, default 10border
(optional): Number of border boxes, default 4fill_color
(optional): Foreground color, default "black"back_color
(optional): Background color, default "white"return_data_url
(optional): Whether to return Data URL format, default falseYou can test the MCP client with:
python test_mcp_client.py
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.
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.
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"
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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