Sponsored by Deepsite.site

Screenshot Server

Created By
KunihiroS8 months ago
Content

Screenshot Server (File Path Focused)

This project provides an MCP (Modular Communication Protocol) server designed to capture screenshots and facilitate their use by other processes or AI assistants, primarily by saving the screenshot to a file and returning its absolute path.

Core Problem & Solution

Directly interpreting screenshot image data sent via MCP by AI assistants proved unreliable in testing. This server adopts a more robust workflow:

  1. An MCP Host (like an AI assistant) calls the take_screenshot_and_return_path tool.
  2. This server captures the screen, saves it as images/latest_screenshot.jpg on the machine where the server is running.
  3. The server returns the absolute file path (e.g., C:\Users\YourUser\...\latest_screenshot.jpg) to the saved image.
  4. The MCP Host receives this path.
  5. The MCP Host can then pass this file path (potentially converting it if needed, e.g., Windows path to WSL path) to another specialized MCP server (or tool) responsible for image analysis or processing. That server reads the file directly from the shared filesystem.

Available Tools

This server currently offers the following tools:

  • take_screenshot_and_return_path()

    • Primary Use: The recommended tool for the workflow described above.
    • Action: Takes a screenshot, saves it to a fixed location (images/latest_screenshot.jpg relative to where the server script is running), and returns the absolute path to the saved file.
    • Returns: str - The absolute path (e.g., a Windows path) or a string starting with "failed: " on error.
    • Example Return: "C:\\Users\\YourUser\\projects\\screenshot-server\\images\\latest_screenshot.jpg"
  • take_screenshot_path(path: str = "./", name: str = "screenshot.jpg")

    • Primary Use: When you need to specify the exact save location and filename.
    • Action: Takes a screenshot and saves it to the location specified by the path and name arguments on the server machine.
    • Parameters:
      • path (str, optional): Directory to save the file. Defaults to the server's working directory.
      • name (str, optional): Filename for the screenshot. Defaults to screenshot.jpg.
    • Returns: str - "success" or "failed: [error message]".
    • Example Call: Requesting to save to C:\temp\myscreen.jpg would involve calling the tool with path="C:\\temp" and name="myscreen.jpg".

Setup and Usage

1. Prerequisites

  • Python 3.x: Required on the machine where the server will run.
  • Dependencies: Install using uv:
    uv sync
    
    Required libraries include mcp[cli]>=1.4.1, pyautogui, and Pillow.

2. Running the Server

This server is typically launched by an MCP Host (like an AI assistant client) based on its configuration. Manual execution is usually only for direct testing.

3. Environment Considerations (Especially WSL2)

Crucial Point: pyautogui needs access to the graphical environment of the screen it's capturing. If you want to capture the Windows screen but run your MCP Host (AI Assistant) in WSL2, you must run this screenshot.py server directly on Windows, not inside WSL2.

Recommended WSL2 Host -> Windows Server Setup:

  1. Project Location: Place this screenshot-server project folder on your Windows filesystem (e.g., C:\Users\YourUser\projects\screenshot-server).

  2. Windows Dependencies: Install Python, uv, and the project dependencies (using uv sync -p C:\path\to\python.exe) directly on Windows within the project folder.

  3. MCP Host Configuration (in WSL): Configure your MCP Host (running in WSL) to launch the server on Windows using PowerShell. Update your mcp_settings.json (or equivalent):

    {
      "mcpServers": {
        "Screenshot-server": { // Or your preferred server name
          "command": "powershell.exe", // Execute PowerShell from WSL
          "args": [
            "-Command",
            // Command executed by PowerShell: Change dir, then run server with uv
            "Invoke-Command -ScriptBlock { cd '<YOUR_WINDOWS_PROJECT_PATH>'; & '<YOUR_WINDOWS_UV_PATH>' run screenshot.py }"
          ]
        }
      }
    }
    
    • Replace <YOUR_WINDOWS_PROJECT_PATH>: The full path to the project folder on Windows.
    • Replace <YOUR_WINDOWS_UV_PATH>: The full path to uv.exe on Windows.

4. Workflow Example (AI Assistant)

  1. AI Assistant uses use_mcp_tool to call take_screenshot_and_return_path on the Screenshot-server.
  2. Receives the Windows path: "C:\\Users\\...\\images\\latest_screenshot.jpg"
  3. Converts path if necessary (e.g., to /mnt/c/Users/.../images/latest_screenshot.jpg if the AI Host is in WSL).
  4. AI Assistant uses use_mcp_tool to call an image analysis server/tool, passing the (converted) file path as an argument.
  5. The image analysis server reads the file and performs its task.

File Structure

  • screenshot.py: The core MCP server script.
  • README.md: This documentation file.
  • pyproject.toml: Project definition and dependencies for uv.
  • uv.lock: Dependency lock file.
  • .gitignore: Git ignore configuration.
  • .python-version: (Optional) Python version specifier for tools like pyenv.
  • server.log: Log file generated by the server.
  • images/: Default directory created to store screenshots (e.g., latest_screenshot.jpg).

Server Config

{
  "mcpServers": {
    "Screenshot-server": {
      "command": "powershell.exe",
      "args": [
        "-Command",
        "Invoke-Command -ScriptBlock { cd '<YOUR_WINDOWS_PROJECT_PATH>'; & '<YOUR_WINDOWS_UV_PATH>' run screenshot.py }"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
CursorThe AI Code Editor
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs