ext-apps/examples/qr-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Olivier Chafik 8a877b36b4
feat(debug-server): add interactive debug server example (#321)
* feat(examples): add debug-server example

A comprehensive debug/development server for testing MCP Apps SDK features:
- Vanilla TypeScript UI with collapsible panels
- Message visualization (sent, received, errors)
- Server tool calling interface
- Multiple tool endpoints for testing

* refactor(debug-server): convert to React

- Replace vanilla TypeScript with React components
- Add comprehensive Host Styles panel showing all CSS variables grouped by category
- Use React hooks (useApp, useHostStyles, useAutoResize)
- Cleaner state management with useReducer for event log
- Collapsible sections for better organization
- CSS modules for scoped styling

* fix(debug-server): correct server name in main.ts

* Revert "refactor(debug-server): convert to React"

This reverts commit 5d22d2daa9a98ba412892447202ef10fbdb62f5b.

* fix(debug-server): update default values for multipleBlocks and includeMeta

* fix(debug-server): correct serve script and server name

- serve script now runs main.ts instead of server.ts
- Updated server name to 'Debug Server'
- Fixed npx command in comment

* fix: increase maxHeight to 6000px and add tools capability to debug app

- basic-host: Increase maxHeight from 600 to 6000px
- debug-server: Add tools capability to enable oncalltool/onlisttools handlers

* fix(debug-server): use consistent callback names for event tracking

Event types now match callback names (ontoolinput, ontoolresult, etc.)
so the Callback Status panel shows correct counts and payloads.

* feat(debug-server): add Update (Image) button for model context

* feat(debug-server): add expandable event log entries

- Click on any event log row to expand/collapse
- Arrow indicator rotates when expanded
- Full JSON payload shown indented in pre block
- Max height with scroll for large payloads

* style(debug-server): format long line in fullPayload function

* test(debug-server): add to E2E tests and screenshot specs

* chore: regenerate package-lock.json for cross-platform compatibility

* update dep
2026-01-23 12:39:40 +00:00
..
.gitignore Add QR code Python MCP server example (#105) 2025-12-09 19:20:08 +01:00
grid-cell.png feat(qr-server): use Python SDK meta parameter for resource CSP metadata (#303) 2026-01-19 19:11:42 +00:00
package.json feat(debug-server): add interactive debug server example (#321) 2026-01-23 12:39:40 +00:00
README.md docs: standardize UI terminology to use "view" consistently (#325) 2026-01-23 04:36:52 +02:00
server.py docs: standardize UI terminology to use "view" consistently (#325) 2026-01-23 04:36:52 +02:00

QR Code MCP Server

A minimal Python MCP server that generates customizable QR codes with an interactive view UI.

Screenshot

MCP Client Configuration

First, clone the repository:

git clone https://github.com/modelcontextprotocol/ext-apps.git

Then add to your MCP client configuration (stdio transport), replacing the path with your clone location:

{
  "mcpServers": {
    "qr": {
      "command": "uv",
      "args": [
        "run",
        "/path/to/ext-apps/examples/qr-server/server.py",
        "--stdio"
      ]
    }
  }
}

Features

  • Generate QR codes from any text or URL
  • Customizable colors, size, and error correction
  • Interactive view that displays in MCP-UI enabled clients
  • Supports both HTTP (for web clients) and stdio (for MCP clients)

Prerequisites

This server uses uv for dependency management. Install it first:

curl -LsSf https://astral.sh/uv/install.sh | sh

Quick Start

# Run server (HTTP mode) - uv handles dependencies automatically
uv run server.py
# → QR Code Server listening on http://localhost:3108/mcp

Usage

HTTP Mode (for basic-host / web clients)

uv run server.py

Connect from basic-host:

SERVERS='["http://localhost:3108/mcp"]' bun serve.ts

Stdio Mode (for MCP clients)

uv run server.py --stdio

See MCP Client Configuration above for how to add this server to your MCP client.

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, deps inline via PEP 723)
├── view.html    # Interactive UI view
└── README.md

Protocol

The view uses MCP Apps SDK protocol:

  1. The view sends ui/initialize request
  2. Host responds with capabilities
  3. The view sends ui/notifications/initialized
  4. Host sends ui/notifications/tool-result with QR image
  5. The view renders image and sends ui/notifications/size-changed

Dependencies

Dependencies are declared inline in server.py using PEP 723 and managed by uv:

  • mcp - MCP Python SDK with FastMCP
  • qrcode[pil] - QR code generation with Pillow
  • uvicorn - ASGI server
  • starlette - CORS middleware

License

MIT