Skip to main content
Glama
zzaebok

Wikidata MCP Server

by zzaebok

get_metadata

Retrieve English labels and descriptions for Wikidata entities by providing their entity ID and optional language code.

Instructions

Retrieve the English label and description for a given Wikidata entity ID. Args: entity_id (str): The entity ID to retrieve metadata for. language (str): The language code for the label and description (default is "en"). Use ISO 639-1 codes. Returns: dict: A dictionary containing the label and description of the entity, if available.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYes
languageNoen

Implementation Reference

  • The handler function for the 'get_metadata' tool, decorated with @server.tool() for registration. It fetches the label and description of a Wikidata entity using the Wikidata API.
    @server.tool() async def get_metadata(entity_id: str, language: str = "en") -> Dict[str, str]: """ Retrieve the English label and description for a given Wikidata entity ID. Args: entity_id (str): The entity ID to retrieve metadata for. language (str): The language code for the label and description (default is "en"). Use ISO 639-1 codes. Returns: dict: A dictionary containing the label and description of the entity, if available. """ params = { "action": "wbgetentities", "ids": entity_id, "props": "labels|descriptions", "languages": language, # specify the desired language "format": "json", } async with httpx.AsyncClient() as client: response = await client.get(WIKIDATA_URL, params=params) response.raise_for_status() data = response.json() entity_data = data.get("entities", {}).get(entity_id, {}) label = ( entity_data.get("labels", {}).get(language, {}).get("value", "No label found") ) descriptions = ( entity_data.get("descriptions", {}) .get(language, {}) .get("value", "No label found") ) return {"Label": label, "Descriptions": descriptions}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zzaebok/mcp-wikidata'

If you have feedback or need assistance with the MCP directory API, please join our Discord server