Skip to main content
Glama
Image Search MCP
by EngDawood
README.md
# image-search-mcp

MCP server for **Wikimedia Commons photo search** — freely-licensed raster
images with attribution, on Cloudflare Workers. Public and keyless: no API
key, no signup, no auth.

This fills the gap next to Dawood's
[design-mcp-server](https://github.com/EngDawood/design-mcp-server), whose
Wikimedia provider is SVG-only. Here the default is **photos** (jpg, png,
webp, gif); SVG is opt-in.

## Result shape

Every search result always carries the same fields — `title`,
`file_page_url`, `file_url`, `thumbnail_url`, `width`, `height`, `mime`,
`license`, `artist`, `credit`, `attribution` — with `null` where the API
gave nothing (instead of the key being absent). `file_page_url` always
resolves, falling back to a constructed Commons wiki URL when the API
omits it. The attribution line uses the artist, falling back to the
credit field when no artist is recorded.

Paging: `next_offset` steps by the requested `limit`, and `total_count`
is the API's total *before* the client-side mime filter (a page can hold
fewer than `limit` images when non-matching mimes are filtered out).

## Tools

| Tool | What it does |
|---|---|
| `wikimedia_search_images` | Search Commons for photos. Params: `query` (required), `limit` (default 12, max 50), `offset`, `filetype` (`photos` default, `svg`, `all`). Every result carries the file URL, a 640px thumbnail, dimensions, licence, author, and a ready attribution line. |
| `wikimedia_get_image` | Full info for one file by title (with or without the `File:` prefix): URLs, dimensions, description, and the complete attribution block (artist, credit, licence, usage terms). Returns an error result when the file is missing. |

Both tools call the official MediaWiki Action API on
`commons.wikimedia.org/w/api.php` (`generator=search`, `gsrnamespace=6`,
`prop=imageinfo`, `iiprop=url|size|mime|extmetadata`) with a descriptive
`User-Agent`. No upstream key is needed.

## Use it

Once deployed, point any MCP client at the `/mcp` endpoint:

```bash
# Claude Code
claude mcp add --transport http image-search https://image-search-mcp.<your-subdomain>.workers.dev/mcp
```

```json
// Claude Desktop / Cursor (.cursor/mcp.json, claude_desktop_config.json)
{
  "mcpServers": {
    "wikimedia-images": {
      "type": "http",
      "url": "https://image-search-mcp.<your-subdomain>.workers.dev/mcp"
    }
  }
}
```

## Develop

```bash
npm install
npm test          # vitest
npm run typecheck # tsc --noEmit
npm run dev       # wrangler dev on :8787
```

## Deploy

```bash
npx wrangler login   # one-time browser OAuth
npx wrangler deploy  # → https://image-search-mcp.<your-subdomain>.workers.dev
```

Optional: set a custom domain in the Cloudflare dashboard, or a route in
`wrangler.toml`. No secrets are needed — the Commons API is keyless.

## Attribution

Borrowed patterns (all MIT) are credited in [`THIRD_PARTY.md`](THIRD_PARTY.md):
iolab-mcp-collection's `wikimedia-mcp` (Commons API shape, attribution
reader), wikipedia-recent-changes-mcp (plain-`fetch` Worker skeleton and
hand-rolled JSON-RPC handler), and wikimedia-image-search-mcp (search +
metadata pattern). The thumbnail-composite idea from the last one is
intentionally not built — compositing images is not practical inside a
Worker.

## License

MIT — see [`LICENSE`](LICENSE).