Skip to main content
Glama

find_by_property

Search Wikidata entities using specific property values to retrieve relevant results, with options to filter by language and limit the number of outputs.

Instructions

Find entities by property and value

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "language": { "default": "en", "description": "Language code (default: en)", "type": "string" }, "limit": { "default": 10, "description": "Maximum number of results", "maximum": 100, "type": "integer" }, "property": { "description": "Property ID (P123)", "type": "string" }, "value": { "description": "Property value to search for", "type": "string" } }, "required": [ "property", "value" ], "type": "object" }

Implementation Reference

  • The core handler function implementing the find_by_property tool logic. Constructs a SPARQL query to find entities matching the given property and value, executes it via sparql_query, and formats the results.
    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}
  • Registers the 'find_by_property' tool in get_tool_definitions, defining 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"] } )
  • MCP tool dispatcher in call_tool method that invokes the client handler for find_by_property.
    elif name == "find_by_property": result = await self.client.find_by_property(**arguments)
  • Input schema definition for the find_by_property tool.
    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"] }

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