图像处理与屏幕捕捉服务

一个跨平台的图像处理和屏幕捕捉MCP服务器,支持AI代理与图像交互并捕捉屏幕截图。

  • by alexFrankfurt
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 alexFrankfurt/mcp-images

使用说明

MCP图像

一个跨平台的图像处理和屏幕捕获MCP服务器,使AI代理能够与图像交互并捕获屏幕截图。源自https://github.com/IA-Programming/mcp-images

特性

  • 图像获取:从URL或本地文件路径获取和处理图像
  • 跨平台截图:在Windows、macOS和Linux上捕获屏幕截图
  • 图像压缩:自动压缩大图像,同时保持质量
  • 视觉支持:以适合LLM视觉模型的格式返回图像
  • 灵活的输出:直接在响应中流式传输图像或保存到文件路径

工具

fetch_images

从URL或本地文件路径获取并处理图像,以适合LLM的格式返回它们。

# returns MCP Image objects (default)
await fetch_images(image_sources: List[str])

# write processed images to file paths
await fetch_images(image_sources: List[str], output_mode="file", output_path="C:/images/output.png")
await fetch_images(image_sources: List[str], output_mode="file", output_path="C:/images/output_dir/")

参数:

  • image_sources:图像URL或本地文件路径列表
  • output_mode:输出目的地- "stream" 返回图像作为响应(默认), "file" 写信给 output_path
  • output_path:文件输出模式的文件路径或目录路径。对于多个图像,这应该是一个目录。对于单个图像,可以是特定的文件路径。

snapshot

捕获当前屏幕或加载图像文件,并可选择将其返回以进行LLM分析。

此工具模仿Windows MCP快照功能,但可跨平台工作。它捕获当前屏幕状态,并可选择返回屏幕截图图像,以便LLM在以下情况下进行分析 use_vision 这是真的。或者,您可以提供一个图像文件路径来加载和分析。

# Stream mode (default) - returns image in response
await snapshot(use_vision: bool = False, image_file: str = None)

# File mode - saves image to specified path
await snapshot(use_vision=True, output_mode="file", output_path="C:/screenshots/screen.png")

参数:

  • use_vision:如果为True,则在响应中包含图像以进行视觉分析
  • image_file:从中加载图像而不是捕获屏幕的可选文件路径
  • output_mode:输出目的地- "stream" 返回图像作为响应(默认), "file" 写信给 output_path
  • output_path:保存图像时的文件路径 output_mode 是 "file"

mouse_rect

在当前鼠标位置周围捕获一个小矩形,并将其作为图像返回。

此工具捕获以当前鼠标光标为中心的矩形区域的屏幕截图 位置,具有指定的宽度和高度。这有助于获得特写镜头 当前鼠标指针下的内容。

# Stream mode (default)
await mouse_rect(width: int = 100, height: int = 100)

# File mode
await mouse_rect(width=200, height=200, output_mode="file", output_path="C:/screenshots/mouse_rect.png")

参数:

  • width:要捕获的矩形的宽度(默认值:100像素)
  • height:要捕获的矩形的高度(默认值:100像素)
  • output_mode:输出目的地- "stream" 返回图像作为响应(默认), "file" 写信给 output_path
  • output_path:保存图像时的文件路径 output_mode 是 "file"

mouse_move_screenshot

将鼠标移动到指定位置,并在目标位置返回带有视觉指示器的屏幕截图。

此工具将鼠标光标移动到指定坐标,捕获屏幕截图 在该位置周围,并添加一个视觉指示器(红色十字准线)来显示确切的位置 鼠标位置,因为使用屏幕截图方法并不总是可以捕获光标。

# Stream mode (default)
await mouse_move_screenshot(x: int, y: int, width: int = 200, height: int = 200)

# File mode
await mouse_move_screenshot(x=100, y=200, output_mode="file", output_path="C:/screenshots/move_screenshot.png")

参数:

  • x:将鼠标移动到的X坐标
  • y:将鼠标移动到的Y坐标
  • width:位置周围要捕获的矩形的宽度(默认值:200像素)
  • height:位置周围要捕获的矩形的高度(默认值:200像素)
  • output_mode:输出目的地- "stream" 返回图像作为响应(默认), "file" 写信给 output_path
  • output_path:保存图像时的文件路径 output_mode 是 "file"

mouse_click

将鼠标移动到指定位置并单击。

此工具将鼠标光标移动到指定坐标并执行单击 使用请求的按钮。

await mouse_click(x: int, y: int, button: str = "left")

参数:

  • x:要单击的X坐标
  • y:要单击的Y坐标
  • button:单击鼠标按钮,其中之一 left, right,或 middle

安装

pip install -e .

用法

{
  "mcpServers": {
    "image": {
      "command": "uv",
        "args": ["--directory", "/path/to/mcp-image", "run", "mcp_image.py"]
    }
  }
}

服务器可以作为MCP服务器运行:

mcp-image

或者以编程方式:

from mcp_image import main
main()

依赖项

  • httpx
  • 主控程序
  • 枕头
  • 海量存储系统
  • 皮乌古伊
  • psutil

许可证

麻省理工学院