# Wikidata MCP

> Wikidata provides direct, structured access to the world's largest open knowledge graph. Run complex SPARQL queries, perform semantic vector searches for entities and properties, or fetch detailed facts about any item. Manage verifiable data relationships right from your agent.

## Overview
- **Category:** the-unthinkable
- **Price:** Free
- **Tags:** knowledge-graph, sparql, structured-data, semantic-search, data-retrieval, open-data

## Description

You can treat Wikidata like a massive, interconnected database that speaks naturally with your AI client. Instead of asking your agent to guess at a fact based on general knowledge, you tell it to look up the source directly. You'll find everything from historical dates and scientific concepts to people's documented achievements. The tool lets you run deep SPARQL queries across millions of linked items—the kind of complex relationship mapping that generic AI models just can't do reliably. It also supports modern vector search, so if you know what you mean but not the exact keywords, your agent finds it anyway. When you connect this MCP through Vinkius, you get to tap into all these capabilities from one place, making structured data retrieval a natural part of any workflow.

## Tools

### create_statement
Adds a new statement (fact) to an existing Wikidata item when provided with write permissions.

### execute_sparql
Runs sophisticated SPARQL queries to find relationships and patterns across the entire dataset.

### get_item_statements
Retrieves every known property and statement linked to a specific Wikidata item ID.

### get_item
Pulls the core details and metadata for any specified Wikidata Item using its unique identifier.

### get_similarity_score
Compares a piece of text against an entity to calculate how semantically similar they are.

### search_items_vector
Performs hybrid searches across items, finding matches based on both keywords and overall meaning.

### search_properties_vector
Searches for properties (types of facts) using a mix of keywords and semantic understanding.

### set_item_description
Updates the main textual description of an item on Wikidata when provided with write permissions.

## Prompt Examples

**Prompt:** 
```
Search for Wikidata items related to 'artificial neural networks' using vector search.
```

**Response:** 
```
I've performed a vector search for 'artificial neural networks'. The most relevant item is 'artificial neural network' (Q192713), described as a computational model inspired by biological neural networks. Other related items include 'deep learning' (Q197536) and 'machine learning' (Q11660).
```

**Prompt:** 
```
Run a SPARQL query to find the 5 most populated cities in Brazil.
```

**Response:** 
```
Executing the SPARQL query... The 5 most populated cities in Brazil are: 1. São Paulo (Q174), 2. Rio de Janeiro (Q8678), 3. Brasília (Q2844), 4. Salvador (Q36851), and 5. Fortaleza (Q43463).
```

**Prompt:** 
```
Get all statements for the Wikidata item Q42.
```

**Response:** 
```
I've retrieved the statements for Douglas Adams (Q42). Key statements include: instance of 'human' (P31), occupation 'writer' (P106), and notable work 'The Hitchhiker's Guide to the Galaxy' (P800).
```

## Capabilities

### Querying relationships with SPARQL
Execute complex queries to map patterns and find specific links between entities across the entire knowledge graph.

### Retrieving verified facts by Item ID
Fetch all known statements, properties, and data points associated with a specific entity on Wikidata.

### Searching by meaning (Semantic Search)
Find relevant entities or properties based on the underlying concept of your query, not just keyword matches.

### Updating knowledge records
Add new statements, descriptions, or relationships to Wikidata items (requires OAuth access).

## Use Cases

### Fact-Checking Academic Research
A student needs to verify a claim about a historical figure's primary occupation. Instead of relying on generalized LLM knowledge, they ask their agent to run `get_item` and then use `get_item_statements` against the specific person's ID to pull only verifiable records.

### Building Product Knowledge Bases
A developer wants to build a tool that connects related software concepts. They run multiple `search_properties_vector` queries to map out all associated technical terms and relationships, ensuring their internal data structure matches the global standard.

### Complex Data Discovery
A journalist is researching economic trends across several continents. They use `execute_sparql` to write a query that finds patterns linking 'population growth' with 'infrastructure spending' in multiple regions simultaneously, something impossible with simple chat prompts.

### Semantic Data Lookup
A marketing analyst needs data on 'early 20th-century photography techniques.' They use `search_items_vector` because the exact term might not be in the graph, but the semantic similarity engine guides them to the correct related items.

## Benefits

- Go beyond simple keyword matching. Use `search_items_vector` to find entities related by meaning, which is crucial when you're brainstorming or defining abstract concepts.
- Map complex relationships instantly. With `execute_sparql`, you can ask the system to find patterns—like 'all famous writers who lived in London and wrote about space travel.'
- Get all the verifiable facts on a subject. Running `get_item_statements` provides a complete breakdown of an item's known properties, letting you build comprehensive profiles.
- Automate data enrichment by finding structured knowledge. Use `get_item` to pull core details for any entity, feeding clean data directly into your application logic.
- Contribute verified information. If you have new facts about an item, use `create_statement` or `set_item_description` (with OAuth) to update the graph.

## How It Works

The bottom line is that your AI client gains a direct pipeline into highly structured, globally verifiable knowledge data.

1. Subscribe to the MCP and provide your User Agent identifier as required by Wikimedia policy.
2. If you need to write data back to Wikidata, connect an OAuth 2.0 Access Token.
3. Your agent can then execute complex queries or retrieve specific facts directly from this connection.

## Frequently Asked Questions

**How do I use Wikidata with my agent for general fact retrieval?**
Use the `get_item` tool first. This fetches all core metadata and statements for any item ID, giving you a comprehensive overview of its known properties.

**Can I run complex queries using execute_sparql in my chat client?**
Yes, `execute_sparql` allows your agent to run advanced queries against the entire knowledge graph. This is how you find patterns that simple searches miss.

**What's the difference between searching items and searching properties with Wikidata?**
Use `search_items_vector` when you want to find an entity (a person, place, or thing). Use `search_properties_vector` when you are looking for a specific type of fact or relationship.

**Is Wikidata MCP useful for updating data?**
Yes, if you have write access via OAuth, you can use tools like `create_statement` or `set_item_description` to add new facts or update existing descriptions.

**Do I need a specific item ID to get all statements?**
You must provide the unique Wikidata Item ID (e.g., Q42) to use `get_item_statements`. This tells the system exactly which entity's data you want.