Skip to main content
Glama

MCP Virtual User

Docker 容器中的一个合成人类。它有耳朵、嘴巴、眼睛和双手。

这是什么?

一个完全自包含的环境,模拟真实用户通过语音和浏览器与 Web 应用交互。它具有:

  • 虚拟麦克风 — MCP 可以注入音频(TTS 或原始音频),任何应用都会认为声音来自硬件麦克风

  • 虚拟扬声器 — MCP 可以捕获并转写操作系统播放的任何音频

  • 真实浏览器 — 由 Playwright 控制的 Chromium,带有持久的登录会话

  • 真实显示器 — Xvfb + VNC,用于调试(实时观察正在发生的情况)

  • MCP 接口 — 所有功能通过 Streamable HTTP 以工具的形式暴露

Related MCP server: Lotus MCP

使用场景

  • 测试 ChatGPT 语音模式 — 将“今天天气怎么样?”注入麦克风,捕获 ChatGPT 的语音回复,转写文本并断言

  • 测试 Gemini Live — 对 Google 的语音 AI 执行同样的流程

  • 测试我们的 Mobile Mesh UI — 针对我们自己的应用进行完整的端到端语音对话测试

  • 任何支持语音的 Web 应用 — 只要它使用浏览器的麦克风/扬声器,我们就能测试

Architecture

┌─────────────────────────────────────────────────────────────┐
│  Docker Container                                            │
│                                                             │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  MCP Server (port 8360)                              │    │
│  │                                                     │    │
│  │  Audio Tools:                                       │    │
│  │    tts_to_mic(text)     → Piper TTS → virtual mic   │    │
│  │    transcribe_speakers() → parec → Whisper STT      │    │
│  │    inject_audio(b64)    → raw audio → virtual mic   │    │
│  │    capture_audio(secs)  → raw audio from speakers   │    │
│  │    wait_for_speech()    → detect + transcribe       │    │
│  │                                                     │    │
│  │  Browser Tools:                                     │    │
│  │    browser_navigate, click, type, screenshot, etc.  │    │
│  │    browser_grant_mic_permission(origin)             │    │
│  │                                                     │    │
│  │  Screen Tools:                                      │    │
│  │    screen_screenshot, screen_size, vnc_url          │    │
│  └──────────┬──────────────────────────┬───────────────┘    │
│             │                          │                     │
│  ┌──────────▼──────────┐  ┌───────────▼───────────────┐    │
│  │  PulseAudio         │  │  Playwright + Chromium    │    │
│  │                     │  │                           │    │
│  │  virtual_mic ◀──────│──│── browser reads as mic    │    │
│  │  (pipe-source)      │  │                           │    │
│  │                     │  │  browser plays audio ──▶  │    │
│  │  virtual_speaker ───│──│── captured via .monitor   │    │
│  │  (null-sink)        │  │                           │    │
│  └─────────────────────┘  └───────────────────────────┘    │
│                                                             │
│  ┌─────────────────────┐  ┌───────────────────────────┐    │
│  │  Xvfb :99           │  │  x11vnc + noVNC          │    │
│  │  1920x1080x24       │  │  port 5900 / 6080        │    │
│  └─────────────────────┘  └───────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

快速开始

# Build and start
docker compose up -d --build

# Watch the virtual display (open in your browser)
open http://localhost:6080/vnc.html?autoconnect=true

# Test the MCP server
curl http://localhost:8360/mcp -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"health","arguments":{}}}'

# Run smoke tests
bash test-smoke.sh

首次配置(一次性)

# 1. Build and start
docker compose up -d --build

# 2. Open VNC in your browser to see the desktop
open http://localhost:6080/vnc.html?autoconnect=true

# 3. In the VNC window, Chromium is running. Log into:
#    - https://chat.openai.com (ChatGPT)
#    - https://gemini.google.com (Gemini)

# 4. Export cookies to DragonsKeep so they persist
bash scripts/export-browser-cookies.sh

# 5. Done! Future container starts auto-inject the stored sessions.

运行测试

# Infrastructure tests (no login required)
cd tests && pip install -r requirements.txt
pytest test_audio_roundtrip.py test_browser.py -v

# ChatGPT conversation tests (requires login)
pytest test_conversations.py -v -m chatgpt --timeout=120

# Gemini conversation tests
pytest test_conversations.py -v -m gemini --timeout=120

# Our Mesh UI conversation tests
pytest test_conversations.py -v -m meshui --timeout=120

# All conversation tests
pytest test_conversations.py -v --timeout=120

示例:测试 ChatGPT 语音模式

# From any MCP client (Kiro, our mesh agent, etc.)

# 1. Navigate to ChatGPT
browser_navigate("https://chat.openai.com")

# 2. Grant mic permission
browser_grant_mic_permission("https://chat.openai.com")

# 3. Click the voice mode button
browser_click("[data-testid='voice-mode-button']")

# 4. Speak a question (injected into the virtual mic)
tts_to_mic("What is the capital of France?")

# 5. Wait for ChatGPT to respond and transcribe what it says
response = wait_for_speech(timeout_seconds=15)
# response == "The capital of France is Paris."

# 6. Assert
assert "Paris" in response

会话管理

登录会话持久保存在 ./data/browser-profile/(挂载卷)中。

对于 ChatGPT/Gemini 的认证令牌,请使用 DragonsKeep:

  1. 在 DragonsKeep 中将 Cookie 以 chatgpt-session / gemini-session 的形式存储

  2. 容器启动时,将它们注入浏览器配置

或者:通过 VNC(http://localhost:6080)手动登录一次,会话将保留。

端口

端口

服务

8360

MCP 服务器(Streamable HTTP)

6080

noVNC(基于浏览器的 VNC 查看器)

5900

VNC 直连

MCP 工具

音频

工具

说明

tts_to_mic

合成文本 → 注入为麦克风输入

transcribe_speakers

捕获扬声器输出 → 转写为文本

inject_audio

将原始音频字节推送到虚拟麦克风

capture_audio

从虚拟扬声器录制原始音频

wait_for_speech

检测扬声器中的语音,等待其结束后转写

浏览器

工具

说明

browser_navigate

导航到 URL

browser_click

点击元素

browser_type

在输入框中键入文本

browser_press_key

按下键盘按键

browser_screenshot

截图页面

browser_get_text

获取页面文本内容

browser_evaluate

执行 JavaScript

browser_wait_for_text

等待文本出现

browser_url

获取当前 URL

browser_grant_mic_permission

允许某个来源使用麦克风

屏幕

工具

说明

screen_screenshot

全桌面截图

screen_size

获取显示分辨率

vnc_url

获取实时 VNC 查看器 URL

Maintenance

ActivityMaintained
ResponsivenessSyncing

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI assistants to perform automated web testing by controlling a Chrome browser to navigate, interact with pages, capture screenshots, extract console logs, and simulate mobile devices for responsive design testing.
    7
    ISC
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables creation of reusable browser automation skills through demonstration by recording user actions in a browser while narrating, then converting those workflows into executable skills that can be invoked through natural language.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables automated end-to-end testing and verification of web applications through natural language, with self-healing selectors and dual-mode execution.
    15
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables plain-English browser automation via an MCP server, allowing agents to run objectives or test suites in a real browser without selectors or scripts.
    98 npm
    3
    Apache 2.0