Skip to main content

Wayland MCP server (Python, uvx-compatible)

Project description

Wayland MCP Server (Work in Progress)

Note: This package was created because existing screenshot solutions didn't work reliably on my Wayland setup. Key differentiators:

  • Works consistently across Wayland and X11
  • Minimal visual/sound disruption during capture
  • Configurable timeouts for slower systems
  • Custom VLM integration for analysis
  • Advanced input simulation:
    • Typing, key presses, clicks
    • Mouse dragging between coordinates
    • Vertical/horizontal scrolling
    • Cross-platform support
  • Clean, well-documented codebase

A robust Wayland screenshot and analysis tool with MCP (Model Control Protocol) integration.

Input Control Options

This package offers mouse/keyboard control as an optional feature. The system will try these methods in order:

  1. Preferred: python-evdev (no special permissions required if /dev/uinput is accessible)

    pip install evdev
    
  2. Fallback: ydotool (requires admin permissions):

    sudo apt install ydotool
    sudo usermod -aG input $USER
    systemctl --user enable --now ydotoold
    
  3. X11 Systems: PyAutoGUI will be used automatically

Note:

  • Input control is not required for core screenshot and analysis functionality
  • On Wayland, ensure your user has access to /dev/uinput for best results
  • The python-evdev method is preferred as it doesn't require special permissions

Features

  • Silent Screenshot Capture: Minimal visual/sound disruption
  • Multi-Platform Support: Works on X11 and Wayland
  • VLM Integration: AI-powered screenshot analysis
  • MCP Tools:
    • capture_screenshot: Silent fullscreen/region capture
    • analyze_screenshot: AI analysis of screenshots
    • capture_and_analyze: Combined capture+analysis
    • compare_images: Visual diff tool

Installation

pip install wayland-mcp

Configuration

  1. Create ~/.roo/mcp.json:
{
  "mcpServers": {
    "wayland-screenshot": {
      "command": "uvx",
      "args": [
        "wayland-mcp"
      ],
      "env": {
        "OPENROUTER_API_KEY": "your-api-key",
        "WAYLAND_MCP_PORT": "4999"
      }
    }
  }
}

XAUTHORITY for X11/Wayland Mouse Control

If you want the MCP server to control the mouse (e.g., with xdotool), you must set the correct XAUTHORITY environment variable so the server can authenticate with your X session.

How to find your XAUTHORITY file:

  1. Open a terminal in your graphical session (e.g., VSCode terminal).

  2. Run:

    echo $XAUTHORITY

This will print the path to your current X session's authority file. For example:

/run/user/1000/.mutter-Xwaylandauth.XXXXXX

How to set it in .roo/mcp.json:

Add the following to the "env" section for your MCP server:

"XAUTHORITY": "/run/user/1000/.mutter-Xwaylandauth.XXXXXX"

Replace the path with the value you found from the terminal.

This ensures the MCP server can authenticate with your X server and allows tools like xdotool to work from the server process, just as they do in your terminal.

  1. Set environment variables (optional):
export MCP_CONFIG_DIR=/path/to/config

Usage

from wayland_mcp import WaylandMCP

mcp = WaylandMCP()
result = mcp.capture_and_analyze("Describe this screenshot")

Development

git clone https://github.com/your-repo/wayland-mcp
cd wayland-mcp
pip install -e .

License

GPT3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wayland_mcp-0.2.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wayland_mcp-0.2.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file wayland_mcp-0.2.2.tar.gz.

File metadata

  • Download URL: wayland_mcp-0.2.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for wayland_mcp-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b2da977cf0d8640f1f1be9e0fc4ea1f37b77934eb4dd9184cd6adbf12034e1a9
MD5 4b62a08d54ea19a0d3b8fde883f68fb5
BLAKE2b-256 941aff7c6e9fefe64b3e8fdaf4fcb1e4d13a4d1175b867d58fbaecbc82209754

See more details on using hashes here.

File details

Details for the file wayland_mcp-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: wayland_mcp-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for wayland_mcp-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f2130d6fff451e72b7e3e523ca74ac0cb6048ca0f32d810b530a6d2a3180f5ea
MD5 108b077b3d5b451214dbfa4a05aa3d26
BLAKE2b-256 14c40ef78b99d51b2f787b7240089ae7c5d31f9bc73761536f3f7c0e03676f00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page