glam/mcp_servers/wikidata_auth/README.md
2025-11-19 23:25:22 +01:00

3.1 KiB

Enhanced Wikidata MCP Server with Authentication

This is an enhanced version of the Wikidata MCP server that supports API token authentication for increased rate limits.

Features

  • API Token Authentication - 5,000 requests/hour (vs 500 without token)
  • Wikimedia User-Agent Policy Compliant
  • All standard Wikidata tools (search, SPARQL, metadata)
  • Heritage Institution Identifiers - Get ISIL, VIAF, GND codes

Rate Limits

Authentication Rate Limit
No token 500 requests/hour
Personal API token 5,000 requests/hour
Bot account Unlimited

Setup

1. Get API Token

  1. Visit: https://api.wikimedia.org/wiki/Special:AppManagement
  2. Click "Create a personal API token"
  3. Fill in:
    • Name: GLAM Data Extraction
    • Description: Heritage institution data enrichment
    • Grants: Select "Read" permissions
  4. Copy the token

2. Configure Environment

Add to /Users/kempersc/apps/glam/.env:

WIKIDATA_API_TOKEN=your_actual_token_here
WIKIMEDIA_CONTACT_EMAIL=your@email.com

3. Install Dependencies

cd /Users/kempersc/apps/glam/mcp_servers/wikidata_auth
uv venv
source .venv/bin/activate  # On macOS/Linux
uv pip install -e .

4. Configure Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "wikidata-auth": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/Users/kempersc/apps/glam/mcp_servers/wikidata_auth",
        "python",
        "server.py"
      ],
      "env": {
        "WIKIDATA_API_TOKEN": "${WIKIDATA_API_TOKEN}",
        "WIKIMEDIA_CONTACT_EMAIL": "${WIKIMEDIA_CONTACT_EMAIL}"
      }
    }
  }
}

Available Tools

search_entity(query: str)

Search for Wikidata entity IDs.

Example: search_entity("Rijksmuseum")"Q190804"

search_property(query: str)

Search for Wikidata property IDs.

Example: search_property("ISIL code")"P791"

get_properties(entity_id: str)

Get all properties for an entity.

Example: get_properties("Q190804")["P31", "P17", "P131", ...]

get_metadata(entity_id: str, language: str = "en")

Get label and description.

Example: get_metadata("Q190804", "en"){"Label": "Rijksmuseum", "Description": "national museum in Amsterdam"}

get_identifiers(entity_id: str)

Get external identifiers (ISIL, VIAF, etc.).

Example: get_identifiers("Q190804"){"ISIL": "NL-AmRMA", "VIAF": "148691498", ...}

execute_sparql(sparql_query: str)

Execute SPARQL queries.

Example:

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P791 "NL-AmRMA" .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Usage in GLAM Project

This MCP is designed for the GLAM Data Extraction project to:

  • Enrich heritage institution records with Wikidata identifiers
  • Resolve GHCID collisions using Q-numbers
  • Validate institution names and locations
  • Cross-reference with authoritative identifiers (ISIL, VIAF)

License

MIT License (based on https://github.com/zzaebok/mcp-wikidata)