Skip to main content
Glama
README.md
# BOOTH Lens MCP

A remote [Model Context Protocol](https://modelcontextprotocol.io/) server for
[BOOTH Lens](https://booth.catlee.fun) — image and text search for BOOTH outfits,
clothing, and hair.

This repository contains only the **MCP adapter**. It calls the public BOOTH Lens
HTTP API; it does not contain the search model, weights, catalog data, or account
database.

## Hosted endpoint

```text
https://booth.catlee.fun/mcp/
```

The endpoint uses MCP Streamable HTTP. Anonymous access is rate-limited by client
IP. Query images are sent ephemerally and are not stored by the service.

## Tools

| Tool | What it does |
|---|---|
| `search_by_text` | Natural-language search (Chinese, English, Japanese), clothing or hair |
| `search_by_image` | Visual search from raw base64 or a `data:image/...` URL |
| `search_by_image_url` | Visual search from a public http(s) image URL |
| `health` | Check which search pools are loaded |

Results include `item_id`, `name`, `url`, `image_url`, `hearts`, item tags,
and a similarity score. Public BOOTH URLs are returned; images are not copied.

## Use the hosted server

### Claude Code

```bash
claude mcp add --transport http booth-lens https://booth.catlee.fun/mcp/
```

### Cursor

`~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "booth-lens": {
      "url": "https://booth.catlee.fun/mcp/"
    }
  }
}
```

### VS Code

`.vscode/mcp.json`:

```json
{
  "servers": {
    "booth-lens": {
      "type": "http",
      "url": "https://booth.catlee.fun/mcp/"
    }
  }
}
```

### Clients that only speak stdio

Bridge the remote endpoint with [`mcp-remote`](https://www.npmjs.com/package/mcp-remote):

```json
{
  "mcpServers": {
    "booth-lens": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://booth.catlee.fun/mcp/"]
    }
  }
}
```

If your client does not follow redirects, keep the trailing slash in the URL.

## Example prompts

- `Find a white blouse with a ribbon for a VRM avatar.`
- `Search hair: long silver twin tails.`
- `Use this image to find the outfit: ...`

## Self-host the adapter

The adapter only needs outbound access to a BOOTH Lens API.

```bash
python -m venv .venv
. .venv/bin/activate
pip install -e .
BOOTH_LENS_API_URL=https://booth.catlee.fun \
BOOTH_MCP_PUBLIC_HOST=localhost \
booth-lens-mcp
```

The MCP endpoint is then:

```text
http://127.0.0.1:8002/mcp/
```

### Docker

```bash
docker build -t booth-lens-mcp .
docker run --rm -p 8002:8002 \
  -e BOOTH_MCP_PUBLIC_HOST=localhost \
  booth-lens-mcp
```

Behind a reverse proxy, set `BOOTH_MCP_PUBLIC_HOST` to the public hostname so
the MCP transport security allowlist accepts the `Host` header.

### Configuration

| Variable | Default | Meaning |
|---|---|---|
| `BOOTH_LENS_API_URL` | `https://booth.catlee.fun` | Backend API base URL |
| `BOOTH_MCP_PUBLIC_HOST` | `localhost` | Public hostname for transport security |
| `BOOTH_MCP_HOST` | `127.0.0.1` | Listen address |
| `BOOTH_MCP_PORT` | `8002` | Listen port |
| `BOOTH_MCP_RATE_LIMIT` | `120` | Per-IP MCP requests per minute; `0` disables |
| `BOOTH_MCP_MAX_BODY_BYTES` | `33554432` | Max MCP request body |
| `BOOTH_MCP_MAX_IMAGE_BYTES` | `20971520` | Max decoded image size |
| `BOOTH_MCP_REQUEST_TIMEOUT` | `120` | Backend request timeout (seconds) |

See `.env.example`.

## Privacy and limits

- No login or account data is exposed through MCP.
- Query images are forwarded ephemerally; the backend is called with
  `ephemeral=true` for image and URL searches.
- Only public catalog metadata and BOOTH image URLs are returned.
- MCP requests are limited per IP; the backend applies its own search limits too.
- Responses can be slower when the GPU queue is busy; clients should allow
  long-running tool calls.

## Not included

- Search model checkpoints, LoRA weights, and catalog data
- BOOTH images or a mirror of BOOTH content
- The BOOTH Lens web UI, accounts, favorites, or history

BOOTH Lens is an independent project and is not affiliated with BOOTH.

## Development

```bash
pip install -e ".[dev]"
pytest
```

The adapter uses the official Python MCP SDK (`mcp>=2.3`) and FastAPI.

## License

MIT. See [LICENSE](LICENSE).