图像读取处理服务

一个基于MCP协议的图像读取处理服务,支持本地和远程图像的加载、调整大小和分析。

  • by k2sebeom
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 k2sebeom/image-reader-mcp

使用说明

图像读取MCP(模块/控制器/处理单元,具体含义需根据上下文确定)

一个用于读取和处理本地及远程图像的模型上下文协议(MCP)服务器。该服务器使大型语言模型(LLMs)能够从文件路径或URL加载、调整大小并分析图像。

关键特性

  • 本地图像支持从本地文件系统路径读取图像
  • 远程图像支持从URL获取并处理图像
  • 自动调整大小可配置的图像缩放功能,以实现最佳处理效果
  • 多种格式支持常见图像格式(JPEG、PNG、GIF、BMP 等)
  • 错误处理针对缺失文件和网络问题的健壮错误处理

要求

  • Python 3.12 或更高版本
  • VS Code、Cursor、Windsurf、Claude Desktop 或任何其他MCP客户端

安装

uvx --from git+https://github.com/k2sebeom/image-reader-mcp@main image-reader-mcp

配置

在您的MCP客户端配置中添加服务器:

{
  "mcpServers": {
    "image-reader": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/k2sebeom/image-reader-mcp@main", "image-reader-mcp"]
    }
  }
}

工具

图像处理

  • 读取本地图像从本地文件路径读取并处理图像

    • file_path (必需):本地图像文件的绝对路径
    • image_size (可选):调整格式为“宽度x高度”(默认:“128x128”)
  • 读取远程图像从远程URL获取并处理图像

    • url (必填):远程图像的URL
    • timeout (可选):请求超时时间(以秒为单位)(默认:30)
    • image_size (可选):调整格式为“宽度x高度”(默认:“128x128”)

使用示例

读取本地图像

# Read a local image with default size
read_local_image("/path/to/image.jpg")

# Read a local image with custom size
read_local_image("/path/to/image.png", "256x256")

读取远程图像

# Fetch an image from URL
read_remote_image("https://example.com/image.jpg")

# Fetch with custom timeout and size
read_remote_image("https://example.com/image.png", timeout=60, image_size="512x512")

发展

本地安装

git clone https://github.com/k2sebeom/image-reader-mcp.git
cd image-reader-mcp
uv sync

运行测试

uv run pytest

许可证

这个项目采用MIT许可证授权。