| Filename | Latest commit message | Latest commit date |
|---|---|---|
Apply host-provided safe area insets as padding on main containers across all examples. This ensures content doesn't render under system UI elements like phone notches. React apps use `useState` + `onhostcontextchanged` handler with initial fetch via `getHostContext()` in `useEffect`. Vanilla JS apps apply padding in the handler and invoke it after `connect()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
| .. | ||
| .gitignore | ||
| README.md | ||
| requirements.txt | ||
| server.py | ||
| widget.html | ||
QR Code MCP Server
A minimal Python MCP server that generates customizable QR codes with an interactive widget UI.
Features
- Generate QR codes from any text or URL
- Customizable colors, size, and error correction
- Interactive widget that displays in MCP-UI enabled clients
- Supports both HTTP (for web clients) and stdio (for Claude Desktop)
Quick Start
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run server (HTTP mode)
python server.py
# → QR Server listening on http://localhost:3108/mcp
Usage
HTTP Mode (for basic-host / web clients)
python server.py
Connect from basic-host:
SERVERS='["http://localhost:3108/mcp"]' bun serve.ts
Stdio Mode (for Claude Desktop)
python server.py --stdio
Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"qr": {
"command": "/path/to/qr-server/.venv/bin/python",
"args": ["/path/to/qr-server/server.py", "--stdio"]
}
}
}
Docker (accessing host server from container)
http://host.docker.internal:3108/mcp
Tool: generate_qr
Generate a QR code with optional customization.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
string | (required) | The text or URL to encode |
box_size |
int | 10 | Size of each box in pixels |
border |
int | 4 | Border size in boxes |
error_correction |
string | "M" | Error correction level: L/M/Q/H |
fill_color |
string | "black" | Foreground color (hex or name) |
back_color |
string | "white" | Background color (hex or name) |
Error Correction Levels
| Level | Recovery | Use Case |
|---|---|---|
| L | 7% | Clean environments |
| M | 15% | General use (default) |
| Q | 25% | Industrial/outdoor |
| H | 30% | Adding logos/damage-prone |
Example Inputs
Basic:
{ "text": "https://example.com" }
Styled:
{
"text": "https://claude.ai",
"fill_color": "#CC785C",
"back_color": "#FFF8F5",
"box_size": 12,
"border": 3
}
Dark Mode:
{
"text": "Hello World",
"fill_color": "#E0E0E0",
"back_color": "#1a1a1a",
"box_size": 15,
"border": 2
}
WiFi QR Code:
{
"text": "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;",
"error_correction": "H",
"box_size": 10
}
Architecture
qr-server/
├── server.py # MCP server (FastMCP + uvicorn)
├── widget.html # Interactive UI widget
├── requirements.txt
└── README.md
Protocol
The widget uses MCP Apps SDK protocol:
- Widget sends
ui/initializerequest - Host responds with capabilities
- Widget sends
ui/notifications/initialized - Host sends
ui/notifications/tool-resultwith QR image - Widget renders image and sends
ui/notifications/size-changed
Dependencies
mcp[cli]- MCP Python SDK with FastMCPqrcode[pil]- QR code generation with Pillowuvicorn- ASGI server (included with mcp)starlette- CORS middleware (included with mcp)
License
MIT
