Skip to main content
Glama
joelgombin

MCP Wikidata Server

by joelgombin

get_entity

Retrieve detailed information about Wikidata entities using entity IDs, with options to specify language, properties, and output format.

Instructions

Get detailed information about a Wikidata entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYesWikidata entity ID (Q123, P456)
languageNoLanguage code (default: en)en
propertiesNoSpecific properties to include
simplifiedNoReturn simplified format (default: false)

Implementation Reference

  • Main handler function that executes the Wikidata API request to retrieve entity details using wbgetentities action, handles optional properties and simplification.
    async def get_entity(
        self,
        entity_id: str,
        language: str = "en",
        properties: Optional[List[str]] = None,
        simplified: bool = False
    ) -> Dict[str, Any]:
        params = {
            "action": "wbgetentities",
            "ids": entity_id,
            "languages": language,
            "format": "json",
        }
    
        if properties:
            params["props"] = "|".join(properties)
    
        data = await self._make_request(self.config.wikibase_api_url, params)
        
        if "entities" not in data or entity_id not in data["entities"]:
            raise ValueError(f"Entity {entity_id} not found")
    
        entity_data = data["entities"][entity_id]
        
        if simplified:
            return self._simplify_entity(entity_data, language)
        
        return {"entity": entity_data}
  • Helper function to simplify the entity data structure for easier consumption, extracting labels, descriptions, and property values.
    def _simplify_entity(self, entity_data: Dict[str, Any], language: str) -> Dict[str, Any]:
        entity = {
            "id": entity_data.get("id"),
            "labels": {},
            "descriptions": {},
            "properties": {}
        }
    
        if "labels" in entity_data:
            entity["labels"] = {
                lang: label["value"] 
                for lang, label in entity_data["labels"].items()
            }
    
        if "descriptions" in entity_data:
            entity["descriptions"] = {
                lang: desc["value"] 
                for lang, desc in entity_data["descriptions"].items()
            }
    
        if "claims" in entity_data:
            for prop_id, claims in entity_data["claims"].items():
                prop_values = []
                for claim in claims:
                    if "mainsnak" in claim and "datavalue" in claim["mainsnak"]:
                        value = claim["mainsnak"]["datavalue"]["value"]
                        if isinstance(value, dict) and "id" in value:
                            prop_values.append({
                                "value": value["id"],
                                "label": value.get("label", value["id"])
                            })
                        else:
                            prop_values.append({"value": str(value)})
                
                if prop_values:
                    entity["properties"][prop_id] = prop_values
    
        return {"entity": entity}
  • Registration of the 'get_entity' tool in the MCP tools list, including description and input schema.
    Tool(
        name="get_entity",
        description="Get detailed information about a Wikidata entity",
        inputSchema={
            "type": "object",
            "properties": {
                "entity_id": {
                    "type": "string",
                    "description": "Wikidata entity ID (Q123, P456)"
                },
                "language": {
                    "type": "string",
                    "description": "Language code (default: en)",
                    "default": "en"
                },
                "properties": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Specific properties to include"
                },
                "simplified": {
                    "type": "boolean",
                    "description": "Return simplified format (default: false)",
                    "default": False
                }
            },
            "required": ["entity_id"]
        }
    ),
  • Input schema definition for the 'get_entity' tool, specifying parameters like entity_id (required), language, properties, and simplified.
    inputSchema={
        "type": "object",
        "properties": {
            "entity_id": {
                "type": "string",
                "description": "Wikidata entity ID (Q123, P456)"
            },
            "language": {
                "type": "string",
                "description": "Language code (default: en)",
                "default": "en"
            },
            "properties": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Specific properties to include"
            },
            "simplified": {
                "type": "boolean",
                "description": "Return simplified format (default: false)",
                "default": False
            }
        },
        "required": ["entity_id"]
    }
  • Dispatcher in call_tool method that invokes the client.get_entity implementation based on tool name.
    elif name == "get_entity":
        result = await self.client.get_entity(**arguments)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get detailed information') but doesn't clarify aspects like whether this is a read-only operation, potential rate limits, authentication needs, or error handling. For a tool with no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently conveys the core purpose without any unnecessary words. It's front-loaded and appropriately sized for a straightforward retrieval tool, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on usage context, behavioral traits, and output expectations, which are important for an agent to invoke it correctly without structured support.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so parameters like 'entity_id', 'language', 'properties', and 'simplified' are well-documented in the schema itself. The description adds no additional semantic context beyond implying retrieval of 'detailed information', which aligns with the schema but doesn't provide extra value like usage examples or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('detailed information about a Wikidata entity'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'get_relations' or 'search_entities', which likely also retrieve entity information but with different scopes or methods.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'find_by_property', 'get_relations', and 'search_entities', there's no indication of when this specific 'get_entity' tool is preferred, such as for retrieving core entity data by ID versus searching or querying relationships.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/joelgombin/mcp-wikidata'

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