Skip to main content
Glama
Wikimedia Commons MCP Server

Wikimedia Commons MCP Server

by irfandemir00
README.md
# Wikimedia Commons MCP Server

Model Context Protocol (MCP) server for searching, inspecting, and safely downloading media from [Wikimedia Commons](https://commons.wikimedia.org/wiki/Main_Page).

## Features

- **10 Read/Download Tools**:
  - `search_files`: CirrusSearch with keyword, `fileType`, `category`, `hasStatement` (`P180=...`), sort order, and pagination.
  - `get_file_details`: Original & thumbnail URLs, dimensions, MIME, SHA-1, license/attribution, author, description, categories, and EXIF metadata.
  - `preview_image`: Size-bounded raster thumbnail returned as MCP `ImageContent` for visual inspection.
  - `search_categories`: Full-text category search with subcategory/file counts.
  - `browse_category`: List subcategories, files, or pages inside any Commons category.
  - `get_picture_of_the_day`: Today's (or any `YYYY-MM-DD`) Picture of the Day with localized caption and file details.
  - `get_structured_data`: Wikibase MediaInfo (`M<pageId>`) multilingual captions and statements with resolved Wikidata labels.
  - `search_nearby`: Coordinate + radius search for geotagged files.
  - `get_file_usage`: Global usage across Wikipedia and sister Wikimedia projects.
  - `download_file`: Sandboxed local download into `COMMONS_DOWNLOAD_DIR` with path traversal protection, size caps, and SHA-1 verification for originals.
- **2 MCP Resources**:
  - `commons://potd`
  - `commons://file/{title}`

## Configuration

| Variable                     | Default                             | Description                                              |
| ---------------------------- | ----------------------------------- | -------------------------------------------------------- |
| `COMMONS_DOWNLOAD_DIR`       | `~/Downloads/wikimedia-commons`     | Sandbox root directory for `download_file`               |
| `WIKIMEDIA_USER_AGENT`       | `wikimedia-commons-mcp/0.1.0 (...)` | Descriptive `User-Agent` header per Wikimedia API policy |
| `COMMONS_REQUEST_TIMEOUT_MS` | `15000`                             | HTTP request timeout (`1000..120000` ms)                 |
| `COMMONS_MAX_DOWNLOAD_BYTES` | `52428800`                          | Max download size in bytes (default 50 MB)               |
| `COMMONS_MAX_PREVIEW_BYTES`  | `2097152`                           | Max inline preview size in bytes (default 2 MB)          |
| `COMMONS_CACHE_TTL_MS`       | `300000`                            | In-memory read cache TTL (`0` disables caching)          |
| `COMMONS_CACHE_MAX_ENTRIES`  | `250`                               | Maximum cached entries                                   |

## Development

```bash
npm install
npm run build
npm run verify
```

## Example `mcp_config.json`

```json
{
  "mcpServers": {
    "wikimedia-commons": {
      "command": "node",
      "args": ["/path/to/wikimedia-commons-mcp/dist/cli.js"],
      "env": {
        "WIKIMEDIA_USER_AGENT": "wikimedia-commons-mcp/0.1.0 (https://commons.wikimedia.org/wiki/Main_Page)"
      }
    }
  }
}
```

TDQS

A3.9/5.0

Scored across 10 tools

Disambiguation4/5

Each tool targets a distinct action-resource pair (keyword search, category search, category browsing, geo search, metadata, structured data, usage, preview, download, POTD), so an agent can generally pick correctly. The only mild overlaps are preview_image vs. download_file (both fetch file content) and search_files vs. browse_category (both enumerate files), but the descriptions clearly separate them by output form and entry point.

Naming Consistency5/5

All names follow a consistent snake_case verb_noun pattern (get_file_details, search_files, browse_category, download_file, preview_image). The only stylistic outlier is the longer noun in get_picture_of_the_day, which is still the same convention.

Tool Count5/5

Ten tools is a well-scoped surface for a media repository server, with each tool covering a genuinely different capability (discovery, metadata, structured data, geo, retrieval). There are no obvious filler or redundant entries.

Completeness4/5

The surface covers discovery (keyword, category, geo), metadata, structured MediaInfo, image preview, file download with integrity checks, usage tracking, and POTD—solid coverage for a read-only Commons client. Minor gaps exist around batch/multi-file operations and higher-level discovery (e.g., related/similar media or category tree traversal beyond one level), which agents can work around via pagination.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues