Data source: Wikidata (Wikimedia)
Overview
Wikidata wraps Wikidata (Wikimedia), handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-wikidata": {
"url": "https://context.gnist.ai/mcp/wikidata/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (5)
search_wikidata_entity
Search Wikidata for entities by name or alias. Resolves a natural-language label to one or more Wikidata QIDs. Use this as the entry point before calling get_wikidata_entity or get_wikidata_linked_ids. Args: label: Name or phrase to search for (e.g. "Barack Obama", "Apple Inc"). language: BCP-47 language code for labels and descriptions. Default "en". limit: Maximum results to return (1–20, default 5). Returns: Dictionary with 'count' and 'results' list. Each result has qid, label, description, and aliases.
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | required | Name or phrase to search for (e.g. "Barack Obama", "Apple Inc"). |
language | string | optional | BCP-47 language code for labels and descriptions. Default "en". (default: en) |
limit | integer | optional | Maximum results to return (1–20, default 5). (default: 5) |
curl -X POST "https://context.gnist.ai/mcp/wikidata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_wikidata_entity", "arguments": {"label": "Barack Obama"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/wikidata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'label': 'Barack Obama'},
'name': 'search_wikidata_entity'}},
)
print(resp.json())
get_wikidata_entity
Fetch a Wikidata entity with its statements, normalized to human-readable form. Returns the entity's label, description, aliases, and all non-deprecated statements as {property_label: [values]} pairs. Property labels are resolved to English names (e.g. "P569" → "date of birth"). Args: qid: Wikidata item ID (e.g. "Q76" for Barack Obama, "Q312" for Apple Inc). Returns: Entity metadata including statements dict. Statement values are normalized: dates as YYYY-MM-DD, quantities as numbers, entities as "Label (QID)", coordinates as "lat, lon".
| Parameter | Type | Required | Description |
|---|---|---|---|
qid | string | required | Wikidata item ID (e.g. "Q76" for Barack Obama, "Q312" for Apple Inc). |
curl -X POST "https://context.gnist.ai/mcp/wikidata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_wikidata_entity", "arguments": {"qid": "Q76"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/wikidata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'qid': 'Q76'}, 'name': 'get_wikidata_entity'}},
)
print(resp.json())
get_wikidata_linked_ids
Return all external database identifiers for a Wikidata entity. Fetches all external-id type statements: IMDb, VIAF, ISNI, MusicBrainz, GeoNames, OpenCorporates, Freebase, PubMed, ORCID, and many others. This is the bridge between Wikidata and every other database in the MCP toolbox. Args: qid: Wikidata item ID (e.g. "Q76" for Barack Obama). Returns: Dictionary with 'qid', 'label', 'wikidata_url', and 'identifiers' — a flat map of {database_name: identifier_value}.
| Parameter | Type | Required | Description |
|---|---|---|---|
qid | string | required | Wikidata item ID (e.g. "Q76" for Barack Obama). |
curl -X POST "https://context.gnist.ai/mcp/wikidata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_wikidata_linked_ids", "arguments": {"qid": "Q76"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/wikidata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'qid': 'Q76'}, 'name': 'get_wikidata_linked_ids'}},
)
print(resp.json())
wikidata_sparql
Execute a SPARQL query against the Wikidata Query Service. Use for complex relational queries not covered by other tools — e.g. "all EU heads of state born after 1970", "Nobel Prize winners in physics since 2000", "companies headquartered in Oslo with stock exchange listings". The Wikidata SPARQL endpoint uses Blazegraph. Queries must use Wikidata prefixes: - wd: (entities), wdt: (direct claims), wikibase:, rdfs:label Example: SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } Args: query: SPARQL SELECT query string. Must be valid SPARQL 1.1. timeout_s: Query timeout in seconds (default 30, max 55). Returns: Dictionary with 'columns' list and 'rows' list. Each row is a {variable: value} dict with string values.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | required | SPARQL SELECT query string. Must be valid SPARQL 1.1. |
timeout_s | integer | optional | Query timeout in seconds (default 30, max 55). (default: 30) |
curl -X POST "https://context.gnist.ai/mcp/wikidata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "wikidata_sparql", "arguments": {"query": "renewable energy"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/wikidata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'query': 'renewable energy'},
'name': 'wikidata_sparql'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/wikidata/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/wikidata/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
search_wikidata_entity to find items, then get_wikidata_entity to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.FAQ
What data does Wikidata provide?
Structured knowledge base — entities, properties, and relationships from Wikidata. It exposes 5 tools: search_wikidata_entity, get_wikidata_entity, get_wikidata_linked_ids, wikidata_sparql, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the Wikidata API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.