Skip to main content
Glama
zzaebok

Wikidata MCP Server

by zzaebok

get_metadata

Retrieve English labels and descriptions for Wikidata entities using entity IDs. Specify language codes for multi-language support. Simplify metadata extraction from Wikidata.

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. It queries the Wikidata API to retrieve the label and description for a given entity ID in the specified language.
    @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}
  • src/server.py:117-117 (registration)
    The @server.tool() decorator registers the get_metadata function as an MCP tool.
    @server.tool()
  • The docstring and type hints define the input schema (entity_id: str, language: str='en') and output (Dict[str, str]) for the tool.
    """ 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. """

Other Tools

Related Tools

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