Skip to main content
Glama

search_entities

Find Wikidata entities using text queries, filter by type (item/property), and control results with language codes and limits via the MCP Wikidata Server.

Instructions

Search for entities in Wikidata by text query

Input Schema

NameRequiredDescriptionDefault
languageNoLanguage code (default: en)en
limitNoMaximum number of results (default: 10, max: 50)
queryYesSearch term
typeNoEntity type filter (item, property)

Input Schema (JSON Schema)

{ "properties": { "language": { "default": "en", "description": "Language code (default: en)", "type": "string" }, "limit": { "default": 10, "description": "Maximum number of results (default: 10, max: 50)", "maximum": 50, "type": "integer" }, "query": { "description": "Search term", "type": "string" }, "type": { "description": "Entity type filter (item, property)", "enum": [ "item", "property" ], "type": "string" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • Core handler function that executes the search_entities tool by querying Wikidata's wbsearchentities API endpoint, processing the response, and returning formatted entity results.
    async def search_entities( self, query: str, language: str = "en", limit: int = 10, type: Optional[str] = None ) -> Dict[str, Any]: params = { "action": "wbsearchentities", "search": query, "language": language, "limit": min(limit, self.config.max_results), "format": "json", } if type: params["type"] = type data = await self._make_request(self.config.wikibase_api_url, params) entities = [] for item in data.get("search", []): entities.append({ "id": item.get("id"), "label": item.get("label"), "description": item.get("description", ""), "url": f"https://www.wikidata.org/entity/{item.get('id')}" }) return {"entities": entities}
  • Registers the search_entities tool with MCP framework, defining its name, description, and input schema for validation.
    Tool( name="search_entities", description="Search for entities in Wikidata by text query", inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "Search term" }, "language": { "type": "string", "description": "Language code (default: en)", "default": "en" }, "limit": { "type": "integer", "description": "Maximum number of results (default: 10, max: 50)", "default": 10, "maximum": 50 }, "type": { "type": "string", "description": "Entity type filter (item, property)", "enum": ["item", "property"] } }, "required": ["query"] }
  • Defines the input schema for the search_entities tool, specifying parameters like query (required), language, limit, and type with types, descriptions, defaults, and constraints.
    inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "Search term" }, "language": { "type": "string", "description": "Language code (default: en)", "default": "en" }, "limit": { "type": "integer", "description": "Maximum number of results (default: 10, max: 50)", "default": 10, "maximum": 50 }, "type": { "type": "string", "description": "Entity type filter (item, property)", "enum": ["item", "property"] } }, "required": ["query"] }
  • MCP tool dispatcher/handler that receives tool calls and delegates search_entities execution to the WikidataClient instance.
    if name == "search_entities": result = await self.client.search_entities(**arguments) elif name == "get_entity":

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

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