Skip to main content

Local image bed MCP Server — exposes local images via HTTP for inline display in AI clients

Project description

MCP Image Server

本地图床 MCP Server,通过 HTTP 服务将本地图片暴露为可访问的 URL,用于在 Cherry Studio 等支持 Markdown 渲染的 AI 客户端中内联显示图片。

工作原理

  1. 以 MCP Server 形式运行,由 Cherry Studio 自动管理进程生命周期
  2. 启动后在本地开启 HTTP 图片服务(默认端口 18090)
  3. AI 通过系统提示词知道 URL 格式,直接输出 Markdown 图片链接
  4. 客户端渲染 Markdown 时自动从本地 HTTP 服务加载图片
AI 输出: ![照片](http://localhost:18090/image?path=E%3A%5Cphotos%5Ctest.png&t=1713936000)
         ↓
Cherry Studio 渲染 Markdown
         ↓
浏览器请求 localhost:18090 → HTTP 服务读取本地文件 → 返回图片

安装

推荐使用 uv tool install,无需克隆仓库,任意电脑一行命令搞定:

uv tool install git+https://gitee.com/xiaoye12345/image-server.git

或用 pip(需要先激活你想要的虚拟环境):

pip install git+https://gitee.com/xiaoye12345/image-server.git

安装完成后会自动注册 mcp-image-server 命令,MCP 配置中直接引用命令名即可,无需填写任何路径

配置

Cherry Studio MCP 服务器

通过 JSON 导入:

{
  "mcpServers": {
    "image-server": {
      "type": "stdio",
      "command": "mcp-image-server"
    }
  }
}

系统提示词

在 Cherry Studio 的系统提示词中添加:

当需要显示本地图片时,直接用 Markdown 图片格式输出:
![描述](http://localhost:18090/image?path=<URL编码的文件绝对路径>&t=<文件修改时间戳>)
路径中的中文、空格等特殊字符必须 URL 编码。
`t` 参数为文件修改时间戳,用于避免缓存导致图片更新后显示旧版本。
示例:![风景](http://localhost:18090/image?path=E%3A%5Cphotos%5Ctest.png&t=1713936000)

升级

uv tool install --upgrade git+https://gitee.com/xiaoye12345/image-server.git

环境变量

变量 默认值 说明
IMAGE_SERVER_PORT 18090 HTTP 服务监听端口

URL 格式

http://localhost:18090/image?path=<URL编码的文件路径>&t=<文件修改时间戳>
  • path:URL 编码的本地图片绝对路径
  • t:伪参数,值为文件修改时间戳(秒),用于打破缓存。图片更新后时间戳改变,URL 不同,浏览器不会使用缓存。服务端忽略此参数。

支持的图片格式:.png .jpg .jpeg .gif .svg .webp .bmp

License

MIT

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

mcp_image_server-0.1.0.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

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

mcp_image_server-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_image_server-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_image_server-0.1.0.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for mcp_image_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2da461c712e893c02e6e13ce9a33c6d317f2584a075de2e2435fa714d080750
MD5 72924796f9b27f3257eaf833029459ba
BLAKE2b-256 a77bf2ec70bab3017754e1b5f2952e58f3176baa156663f7a9fdb6817f47a57f

See more details on using hashes here.

File details

Details for the file mcp_image_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_image_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3427aaadbbba281320a547bae2e5123cad26b41dca7118fa5560120c1d276891
MD5 37f19bfacf44a05c27e5357aaf93f379
BLAKE2b-256 7352818712cae2036d5f8fd9c7c25e6cfc90d2b60eb4f122e50f37b8053d231b

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