Skip to main content
Glama
joelgombin

MCP Wikidata Server

by joelgombin

find_by_property

Search Wikidata entities using specific property-value pairs to locate relevant data entries based on defined criteria.

Instructions

Find entities by property and value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertyYesProperty ID (P123)
valueYesProperty value to search for
languageNoLanguage code (default: en)en
limitNoMaximum number of results

Implementation Reference

  • The core handler function that implements the find_by_property tool logic by constructing and executing a SPARQL query to find Wikidata entities matching the specified property and value.
    async def find_by_property( self, property: str, value: str, language: str = "en", limit: int = 10 ) -> Dict[str, Any]: query = f""" SELECT ?item ?itemLabel WHERE {{ ?item wdt:{property} "{value}" . SERVICE wikibase:label {{ bd:serviceParam wikibase:language "{language}" . }} }} LIMIT {limit} """ result = await self.sparql_query(query) entities = [] for binding in result.get("results", {}).get("bindings", []): entities.append({ "id": binding.get("item", {}).get("value", "").split("/")[-1], "label": binding.get("itemLabel", {}).get("value", "") }) return {"entities": entities}
  • The JSON schema defining the input parameters for the find_by_property tool, including property, value (required), language, and limit.
    inputSchema={ "type": "object", "properties": { "property": { "type": "string", "description": "Property ID (P123)" }, "value": { "type": "string", "description": "Property value to search for" }, "language": { "type": "string", "description": "Language code (default: en)", "default": "en" }, "limit": { "type": "integer", "description": "Maximum number of results", "default": 10, "maximum": 100 } }, "required": ["property", "value"] }
  • Registers the find_by_property tool in the MCP tool definitions list, specifying its name, description, and input schema.
    Tool( name="find_by_property", description="Find entities by property and value", inputSchema={ "type": "object", "properties": { "property": { "type": "string", "description": "Property ID (P123)" }, "value": { "type": "string", "description": "Property value to search for" }, "language": { "type": "string", "description": "Language code (default: en)", "default": "en" }, "limit": { "type": "integer", "description": "Maximum number of results", "default": 10, "maximum": 100 } }, "required": ["property", "value"] } )
  • Dispatches the tool call to the client handler in the WikidataTools.call_tool method.
    elif name == "find_by_property": result = await self.client.find_by_property(**arguments)

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