image-relay-mcp

image-relay-mcp

Fetches images from allowed hosts (e.g., Hugging Face Spaces) and returns them as inline content to Claude, bypassing the sandbox's network restrictions.

Category
访问服务器

README

image-relay-mcp

A tiny MCP server with one job: fetch an image from an allowed host (Hugging Face Space outputs) server-side, and hand it back as inline image content — so Claude gets the bytes directly through the MCP connector, without going through its code-execution sandbox's domain-restricted network.

Tested locally with @modelcontextprotocol/sdk v1.29 and Node 18+.

Why this works

Claude's code-execution sandbox (the one used to build files) only has outbound access to a small package-manager allowlist. Custom MCP connectors are a separate path — they run on your own server, so they have normal internet access. This tool exploits that: it does the fetching on your infrastructure, then returns the result as an MCP image content block, which Claude can read directly from the tool result.

Files

  • server.js — the whole thing. One tool: fetch_image({ url }).
  • test-client.mjs — local smoke test, talks to localhost:3000/mcp.
  • package.json — two dependencies: @modelcontextprotocol/sdk, express.

Security notes (read before deploying)

  • Host allowlist: ALLOWED_HOST_SUFFIXES in server.js restricts which domains this will fetch from. It ships set to .hf.space and huggingface.co. Don't widen this to arbitrary URLs — an open fetch-any-URL relay is an SSRF vector.
  • Optional auth: set the RELAY_AUTH_TOKEN env var on your host to require a Authorization: Bearer <token> header. Recommended once this is public, since anyone with the URL could otherwise call it.
  • Size cap: hard-capped at 15MB per image (MAX_BYTES) so nothing huge gets base64-encoded into a response.
  • Stateless by design (sessionIdGenerator: undefined) — no server-side session state to leak or clean up.

Run locally

npm install
npm start
# listening on :3000, POST /mcp
node test-client.mjs   # optional smoke test

Deploy (pick one — all have a free tier)

Any plain Node 18+ host works, since this only needs express + fetch.

Render (easiest, free web service):

  1. Push this folder to a GitHub repo.
  2. render.com → New → Web Service → connect the repo.
  3. Build command: npm install. Start command: npm start.
  4. Once live, your MCP endpoint is https://<your-app>.onrender.com/mcp.

Railway / Fly.io: same idea — Node buildpack, expose $PORT, start command npm start.

Your own VPS: npm install --production && RELAY_AUTH_TOKEN=xxx npm start behind a reverse proxy (Caddy/nginx) for TLS.

Connect it to Claude

  1. claude.ai → Settings → Connectors → Add custom connector
  2. URL: https://<your-deployed-host>/mcp
  3. If you set RELAY_AUTH_TOKEN, add it as a header/auth value when the connector setup prompts for one.
  4. In a chat: "use my image-relay connector to fetch <hf.space url>" — or just paste the url once it's a named tool Claude can see.

Note: custom connectors require a paid Claude plan (Pro or above).

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选