Desktop MCP

Desktop MCP

Enables AI assistants to capture and analyze screen content across multi-monitor setups with smart image optimization. Provides screenshot capabilities and detailed monitor information for visual debugging, UI analysis, and desktop assistance.

Category
访问服务器

README

🖥️ Desktop MCP

A Model Context Protocol (MCP) server for desktop operations, providing AI assistants with the ability to capture and analyze screen content across multi-monitor setups.

Features

  • 📸 Multi-Monitor Screenshot Support: Capture screenshots from any region across all connected displays
  • 🖥️ Screen Information: Get detailed information about all connected monitors (resolution, position, dimensions)
  • 🎨 Smart Image Optimization: Automatic compression and resizing for AI context efficiency
  • 🔄 Dual Mode Operation: Run as an MCP server or as a standalone web API
  • FastAPI Powered: Built on modern, fast, and well-documented FastAPI framework

Installation

Prerequisites

  • Python 3.8 or higher
  • Windows, macOS, or Linux

Setup

  1. Clone the repository:
git clone https://github.com/yourusername/desktop-mcp.git
cd desktop-mcp
  1. Install dependencies:
pip install -r requirements.txt

Usage

MCP Mode (Default)

Run as an MCP server for use with AI assistants like Claude Desktop:

python -m app.main

Web Mode

Run as a standalone web API with interactive documentation:

python -m app.main --web

This will:

  • Start the server at http://localhost:8000
  • Automatically open the interactive API docs in your browser
  • Enable live reload for development

Configuration

Adding to Claude Desktop

Add this configuration to your Claude Desktop MCP settings file (typically at ~/.cursor/mcp.json or %APPDATA%/.cursor/mcp.json):

{
  "mcpServers": {
    "Desktop MCP": {
      "command": "python",
      "args": ["-m", "app.main"],
      "cwd": "/path/to/desktop-mcp"
    }
  }
}

API Reference

Endpoints

GET /desktop/screens

Get information about all connected monitors.

Response:

[
  {
    "x": 0,
    "y": 0,
    "width": 1920,
    "height": 1080,
    "name": "\\\\.\\DISPLAY1",
    "is_primary": true,
    "width_mm": 527,
    "height_mm": 296
  }
]

POST /desktop/screenshot

Capture a screenshot of a specific region.

Parameters:

  • x (int): X coordinate of top-left corner
  • y (int): Y coordinate of top-left corner
  • width (int): Width of capture region
  • height (int): Height of capture region
  • context_mode (string, optional): Image quality mode
    • minimal (default): 600px max, 30% quality - for basic UI detection
    • normal: 800px max, 50% quality - for detailed UI inspection
    • detailed: 1200px max, 70% quality - for pixel-perfect UI analysis

Request Body:

{
  "x": 0,
  "y": 0,
  "width": 1920,
  "height": 1080
}

Response:

{
  "context": [
    {
      "type": "image",
      "source": {
        "type": "base64",
        "media_type": "image/webp",
        "data": "UklGRi..."
      }
    }
  ]
}

Usage Examples

Example 1: Capture Primary Monitor

import requests

# Get screen info
screens = requests.get("http://localhost:8000/desktop/screens").json()
primary = next(s for s in screens if s["is_primary"])

# Capture primary screen
screenshot = requests.post(
    "http://localhost:8000/desktop/screenshot",
    params={"context_mode": "normal"},
    json={
        "x": primary["x"],
        "y": primary["y"],
        "width": primary["width"],
        "height": primary["height"]
    }
).json()

Example 2: Capture Specific Region

# Capture a 800x600 region starting at position (100, 100)
screenshot = requests.post(
    "http://localhost:8000/desktop/screenshot",
    params={"context_mode": "minimal"},
    json={
        "x": 100,
        "y": 100,
        "width": 800,
        "height": 600
    }
).json()

Example 3: Multi-Monitor Setup

# For a 3-monitor horizontal setup (each 1920x1080):
# Left monitor: x=0, y=0
# Center monitor: x=1920, y=0
# Right monitor: x=3840, y=0

# Capture right monitor
screenshot = requests.post(
    "http://localhost:8000/desktop/screenshot",
    params={"context_mode": "detailed"},
    json={
        "x": 3840,
        "y": 0,
        "width": 1920,
        "height": 1080
    }
).json()

Use Cases with AI Assistants

When integrated with AI assistants like Claude:

  • Visual Debugging: "Can you see what error message is on my screen?"
  • UI/UX Analysis: "What do you think of this design layout?"
  • Tutorial Assistance: "I'm stuck on this step, can you see what I'm doing wrong?"
  • Code Review: "Can you review the code visible on my screen?"
  • Accessibility Testing: "Is this UI accessible and well-organized?"

Development

Project Structure

desktop-mcp/
├── app/
│   ├── __init__.py
│   ├── main.py              # Application entry point
│   ├── api/
│   │   ├── __init__.py
│   │   └── desktop.py       # Desktop API routes
│   └── schemas/
│       ├── __init__.py
│       ├── enums.py         # Context mode enums
│       ├── rect.py          # Rectangle schema
│       └── screeninfo.py    # Screen info schema
├── requirements.txt
└── README.md

Running Tests

# Run the server in web mode for testing
python -m app.main --web

# Visit http://localhost:8000/docs to test endpoints

Requirements

  • fastapi - Modern web framework
  • fastmcp - MCP protocol implementation
  • uvicorn - ASGI server
  • screeninfo - Monitor information retrieval
  • pyautogui - Screenshot capture
  • pillow - Image processing
  • pydantic - Data validation

Security Considerations

⚠️ Important: This tool provides direct access to screen content. When deploying:

  • Only expose to trusted networks
  • Consider authentication mechanisms for production use
  • Be mindful of sensitive information in screenshots
  • Use appropriate context modes to minimize data transfer

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use this project for personal or commercial purposes.

Troubleshooting

Screenshot Capture Fails

  • Linux: Ensure you have the required X11 libraries installed
  • macOS: Grant screen recording permissions in System Preferences
  • Windows: Run with appropriate privileges if capturing protected content

Multi-Monitor Issues

  • Use GET /desktop/screens first to verify monitor coordinates
  • Remember that coordinates are based on virtual desktop layout
  • Monitors may be arranged horizontally, vertically, or in custom configurations

Performance Optimization

  • Use minimal context mode for frequent captures
  • Capture only the necessary region instead of full screens
  • Consider caching screen information instead of querying repeatedly

Support

For issues, questions, or suggestions, please open an issue on GitHub.


Made with ❤️ for enhancing AI assistant capabilities

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选