Skip to main content
Glama
README.md
# media-scout-mcp

[English](README.md) · [简体中文](README.zh-CN.md)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![MCP Streamable HTTP](https://img.shields.io/badge/MCP-Streamable%20HTTP-0ea5e9.svg)](https://modelcontextprotocol.io) [![Cloudflare Workers](https://img.shields.io/badge/Deploy-Cloudflare%20Workers-f38020.svg)](wrangler.jsonc)

A multi-source **free & commercial media search MCP server** in native TypeScript for **AI video editing, design, and content creation agents**. Runs on **Cloudflare Workers (single Worker + static Admin UI + D1)** or **Docker (Node 24 + SQLite)**.

- **3 Aggregated MCP Tools** (`POST /mcp`): `search_images`, `search_videos`, and `search_audio` concurrently query **22 cloud providers** and return normalized results with `commercial_ok` and `attribution_required` flags.
- **Smart Routing**: Supports `image_type="icon"` (Iconify 150+ SVG icon sets) and `image_type="gif"` (KLIPY); Chinese image queries automatically route to `cn_web` while skipping English-only museum catalogs.
- **Dual Auth**: `Authorization: Bearer <token>` for IDEs/CLIs plus full **OAuth 2.0** (`authorization_code` + PKCE, `client_credentials`, `refresh_token`, `/.well-known/*`) for web connectors.
- **Bilingual Admin Console (`/admin`)**: Per-card **Enable** master switch, parallel **Test All & Sync** (auto-disables failing cards), scheduled Cron health checks, masked key management, and IP security controls.

## Data Sources (22 Providers)

- **Keyless & Enabled by Default**: Wikimedia Commons (img/vid/aud), NASA (img/vid), Mixkit (vid/aud), Internet Archive (vid), iNaturalist (CC0/CC-BY wildlife), Iconify (`icon`), Chinese 4-engine web search (`cn_web`, non-commercial).
- **Free API Key / Client ID**: Pexels, Pixabay, Unsplash, Openverse (audio keyless; key recommended for images), Coverr, Freesound, Jamendo, KLIPY (`gif`).
- **Paid Commercial APIs (Optional)**: Freepik, Shutterstock, Epidemic Sound (free dev tier available).
- **Opt-in Museums (Disabled by Default)**: Cleveland Museum of Art, The Met, Art Institute of Chicago, V&A Museum.

<details>
<summary>Full 22-provider capability &amp; license matrix</summary>

| source | API Key / Env | Capabilities | Content & License |
|---|---|---|---|
| `pexels` | `PEXELS_API_KEY` | Images + Video | Pexels License (commercial free, no attribution required) |
| `pixabay` | `PIXABAY_API_KEY` | Images + Video | Pixabay Content License (commercial free, no attribution required) |
| `unsplash` | `UNSPLASH_ACCESS_KEY` | Images | Unsplash License (commercial free, no attribution required) |
| `openverse` | Keyless audio; `OPENVERSE_API_KEY` for images | Images + Audio | Per-item CC license (`commercial_ok` & `attribution_required`) |
| `coverr` | `COVERR_API_KEY` | Video + Music | Coverr License (free tier requires attribution) |
| `freesound` | `FREESOUND_API_KEY` | Audio (SFX) | Creative Commons (CC0 / CC-BY, free API key) |
| `jamendo` | `JAMENDO_CLIENT_ID` | Audio (BGM) | Creative Commons (free non-commercial; commercial license available) |
| `freepik` | `FREEPIK_API_KEY` (Paid API) | Images | Freepik API commercial license |
| `klipy` | `KLIPY_API_KEY` | Images (`image_type=gif`) | KLIPY API (free key, animated GIFs & stickers) |
| `epidemicsound` | `EPIDEMIC_SOUND_API_KEY` (Paid API) | Audio (BGM + SFX) | Epidemic Sound commercial license (free dev tier available) |
| `shutterstock` | `SHUTTERSTOCK_API_TOKEN` (Paid API) | Images + Video + Audio | Shutterstock commercial license |
| `wikimedia` | Keyless (on by default) | Images + Video + Audio | CC / Public Domain (includes OGG/MP3 audio) |
| `nasa` | Keyless (on by default) | Images + Video | Public Domain (NASA) |
| `cleveland` | Keyless (off by default) | Images | Cleveland Museum of Art (CC0) |
| `met` | Keyless (off by default) | Images | The Metropolitan Museum of Art (CC0) |
| `artic` | Keyless (off by default) | Images | Art Institute of Chicago (CC0 / IIIF) |
| `vam` | Keyless (off by default) | Images | Victoria and Albert Museum (editorial / non-commercial) |
| `inaturalist` | Keyless (on by default) | Images | iNaturalist wildlife photos (filtered to CC0 / CC-BY) |
| `archive` | Keyless (on by default) | Video | Internet Archive Prelinger Public Domain |
| `mixkit` | Keyless (on by default) | Video + Audio | Mixkit License (commercial free, no attribution required) |
| `iconify` | Keyless (on by default) | Images (`image_type=icon`) | 150+ open-source SVG icon sets |
| `cn_web` | Keyless (on by default) | Images | Bing CN / Baidu / Sogou / 360 (`web_search_non_commercial` ⚠️) |

</details>

## Quick Deployment

### 1. Cloudflare Workers via GitHub Actions (Recommended)

[.github/workflows/deploy.yml](.github/workflows/deploy.yml) automatically lints, builds, migrates D1, deploys the single Worker (including `/admin`), and syncs Secrets.

1. In GitHub: **Settings → Environments → New environment**, create an environment named **`cf`**.
2. Add under **Environment secrets** (all provider keys & toggles can be configured later in `/admin`):
   - `CLOUDFLARE_API_TOKEN` (Required — Workers Scripts, D1, Account permissions)
   - `CLOUDFLARE_ACCOUNT_ID` (Required)
   - `ADMIN_USER` / `ADMIN_PASS` (Optional — leave unset to create the admin account on first visit to `/admin`)

### 2. Docker (Single Container with Admin UI + SQLite)

```bash
cp .env.example .env   # Optional; everything can also be configured in /admin
docker compose up -d --build
```

Endpoints: `http://127.0.0.1:8000/mcp` · `http://127.0.0.1:8000/admin` · `http://127.0.0.1:8000/health` (SQLite persisted at `./data/media-scout.sqlite`).

<details>
<summary>Advanced deployment: Manual Cloudflare CLI &amp; GitHub Actions Docker/SSH</summary>

#### Manual Cloudflare Workers Deployment
```bash
npm install && npm run lint && npm run typecheck && npm run build
npx wrangler d1 create media-scout-db   # Put database_id into wrangler.jsonc
npm run db:migrate:remote
npx wrangler secret put MCP_AUTH_TOKEN
npm run deploy:worker
```

#### GitHub Actions Docker Image &amp; Optional SSH Deploy
[.github/workflows/docker.yml](.github/workflows/docker.yml) runs `lint`, `typecheck`, `build:docker`, live container smoke tests, and pushes multi-arch images (`linux/amd64`, `linux/arm64`) to `ghcr.io/<owner>/<repo>:latest`. Optional secrets:
- `DOCKERHUB_USERNAME` / `DOCKERHUB_TOKEN` (also mirror to Docker Hub; `DOCKERHUB_REPO` customizable)
- `DEPLOY_HOST` / `DEPLOY_USER` / `DEPLOY_SSH_KEY` (auto-deploy via SSH; `DEPLOY_PORT` default `22`, `DEPLOY_PATH` default `/opt/media-scout-mcp`)

</details>

## Environment Variables

Precedence: **Environment Variables / Worker Secrets > Database (D1 / SQLite) > Defaults**. Non-empty env vars/secrets override database values and appear read-only in `/admin`; unset keys can be edited anytime in `/admin` without redeploying.

<details>
<summary>Full environment variable reference</summary>

| Variable | Default | Scope | Description |
|---|---|---|---|
| `ADMIN_USER` / `ADMIN_PASS` | Empty | All | Admin console credentials (leave empty for first-visit setup) |
| `APP_SECRET` | Empty | All | Session cookie HMAC secret (auto-generated in DB if empty) |
| `MCP_AUTH_TOKEN` | Empty | All | Bearer token for `/mcp` and `/admin/api/*` |
| `OAUTH_CLIENT_ID` / `OAUTH_CLIENT_SECRET` | Empty | All | OAuth 2.0 client credentials |
| `OAUTH_REDIRECT_ALLOWLIST` | Empty | All | Comma-separated allowed OAuth redirect origins (empty = any http/https) |
| `PUBLIC_MCP_URL` | Empty | All | Default endpoint URL shown in `/admin` |
| `ADMIN_ORIGIN` | Empty | Worker | Allowed CORS origin for cross-origin admin API access |
| `TRUST_PROXY` | `0` | Docker | Set `1` behind a reverse proxy to trust `cf-connecting-ip` / `x-forwarded-for` |
| `PEXELS_API_KEY` / `PIXABAY_API_KEY` / `UNSPLASH_ACCESS_KEY` | Empty | All | Free image/video provider keys |
| `OPENVERSE_API_KEY` / `ENABLE_OPENVERSE` | Empty / `0` | All | Openverse key (audio is keyless; `ENABLE_OPENVERSE=1` allows 5 req/hr anon images) |
| `COVERR_API_KEY` / `FREESOUND_API_KEY` / `JAMENDO_CLIENT_ID` / `KLIPY_API_KEY` | Empty | All | Free video, audio, and GIF provider keys |
| `FREEPIK_API_KEY` / `SHUTTERSTOCK_API_TOKEN` / `EPIDEMIC_SOUND_API_KEY` | Empty | All | Commercial / Paid API provider keys |
| `ENABLE_<SOURCE>` | Varies | All | Lock global source switch (`0` / `1`), e.g. `ENABLE_CN_SEARCH=0`, `ENABLE_CLEVELAND=1` |
| `ENABLE_<CAT>_<SOURCE>` | Empty | All | Per-category toggle lock, e.g. `ENABLE_IMAGES_PEXELS=0` |
| `HTTP_TIMEOUT_MS` / `USER_AGENT` / `LOG_LEVEL` | `15000` / Built-in / `INFO` | All | Upstream HTTP timeout, User-Agent, and log level |
| `MCP_HOST` / `MCP_PORT` / `DB_PATH` | `0.0.0.0` / `8000` / `/app/data/media-scout.sqlite` | Docker | Container bind address, port, and SQLite path |

</details>

<details>
<summary>Architecture &amp; extending plugins</summary>

```text
src/plugins/
├── types.ts        # ImagePlugin / VideoPlugin / AudioPlugin interfaces
├── index.ts        # PluginRegistry (collects plugins, resolves aliases & filters)
├── images/         # 16 image providers
├── videos/         # 8 video providers
├── audio/          # 8 audio providers
└── shared/         # Shared upstream API helpers
```

Add a provider by creating a plugin file under `images/`, `videos/`, or `audio/` and exporting it in that folder's `index.ts` — no changes needed to the MCP protocol layer or aggregator.

</details>

## MCP Client Configuration

```json
{
  "mcpServers": {
    "media-scout": {
      "type": "streamable-http",
      "url": "https://<your-endpoint>/mcp",
      "headers": {
        "Authorization": "Bearer <your-MCP_AUTH_TOKEN>"
      }
    }
  }
}
```

For web connectors using **OAuth 2.0**, point to `https://<your-endpoint>/mcp` with the `Client ID` and `Client Secret` from `/admin`.

## Compliance Notice

20 providers use official APIs; `cn_web` (`commercial_ok=false`) and `mixkit` parse public web results/pages and can be disabled with one click in `/admin`. Always verify `license`, `commercial_ok`, and `attribution_required` on each asset before publishing.