MCP Wikidata Server

MCP Wikidata Server

Provides access to Wikidata for Large Language Models through the Model Context Protocol, offering tools for entity search, detailed retrieval, SPARQL queries, relation exploration, and property-based searches.

Category
访问服务器

README

MCP Wikidata Server

Un serveur Model Context Protocol (MCP) qui fournit un accès aux données Wikidata pour les Large Language Models.

🔧 Fonctionnalités

  • 5 outils MCP pour interagir avec Wikidata :

    • search_entities : Recherche textuelle d'entités
    • get_entity : Récupération détaillée d'entités par ID
    • sparql_query : Exécution de requêtes SPARQL personnalisées
    • get_relations : Exploration des relations d'entités
    • find_by_property : Recherche par propriété-valeur
  • APIs supportées :

    • Wikibase API (recherche et récupération d'entités)
    • SPARQL Query Service (requêtes complexes)
    • Support multilingue et cache intelligent

📋 Prérequis

  • Python 3.10+
  • uv (gestionnaire de paquets Python moderne)

📦 Installation

1. Cloner le projet

git clone https://github.com/joelgombin/mcp-wikidata.git
cd mcp-wikidata

2. Installer les dépendances

uv sync

3. Tester l'installation

uv run python test_connection.py

⚙️ Configuration avec Claude Desktop

Configuration recommandée (portable)

Ajoutez cette configuration à votre fichier Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json sur macOS) :

{
  "mcpServers": {
    "mcp-wikidata": {
      "command": "/path/to/your/mcp-wikidata/run_mcp_wikidata.sh",
      "args": []
    }
  }
}

Important : Remplacez /path/to/your/mcp-wikidata/ par le chemin absolu vers votre dossier d'installation.

Alternative avec uv direct

Si vous préférez une configuration sans script wrapper :

{
  "mcpServers": {
    "mcp-wikidata": {
      "command": "uv",
      "args": ["run", "mcp-wikidata"],
      "cwd": "/path/to/your/mcp-wikidata",
      "env": {
        "PATH": "/usr/local/bin:/usr/bin:/bin:~/.local/bin"
      }
    }
  }
}

🧪 Tests et vérification

Test avec MCP Inspector

npx @modelcontextprotocol/inspector uv run mcp-wikidata

Tests manuels des APIs

uv run python test_manual.py

Test client MCP complet

uv run python test_mcp_client.py

🔧 Utilisation des outils

search_entities

Recherche d'entités par texte :

{
  "query": "Einstein",
  "language": "en",
  "limit": 5,
  "type": "item"
}

get_entity

Récupération d'entité par ID :

{
  "entity_id": "Q937",
  "language": "en", 
  "simplified": true
}

sparql_query

Requête SPARQL personnalisée :

{
  "query": "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" . } } LIMIT 10",
  "format": "json"
}

get_relations

Relations d'une entité :

{
  "entity_id": "Q937",
  "relation_type": "outgoing",
  "limit": 20
}

find_by_property

Recherche par propriété :

{
  "property": "P106",
  "value": "physicist",
  "limit": 10
}

⚙️ Configuration avancée

Variables d'environnement

Créez un fichier .env basé sur .env.example :

# User-Agent pour les requêtes API
WIKIDATA_USER_AGENT=MCP-Wikidata/0.1.0

# Limitation du taux de requêtes (par minute)
WIKIDATA_RATE_LIMIT=60

# Timeout des requêtes en secondes
WIKIDATA_TIMEOUT=30

# TTL du cache en secondes
WIKIDATA_CACHE_TTL=3600

# Nombre maximum de résultats par requête
WIKIDATA_MAX_RESULTS=50

# Langue par défaut
WIKIDATA_DEFAULT_LANGUAGE=en

Logs de debug

Pour diagnostiquer des problèmes :

uv run mcp-wikidata --log-level DEBUG

🔧 Dépannage

Erreur "server disconnected" dans Claude Desktop

  1. Vérifiez l'installation d'uv :

    which uv
    # Doit retourner un chemin comme /Users/username/.local/bin/uv
    
  2. Testez le script wrapper :

    ./run_mcp_wikidata.sh --help
    
  3. Vérifiez les permissions :

    chmod +x run_mcp_wikidata.sh
    
  4. Redémarrez Claude Desktop après modification de la configuration

Erreur "spawned uv ENOENT"

Cette erreur indique que Claude Desktop ne trouve pas la commande uv. Le script wrapper run_mcp_wikidata.sh résout automatiquement ce problème en cherchant uv dans plusieurs emplacements courants.

Logs de diagnostic

Les logs détaillés sont disponibles dans :

  • Console de MCP Inspector
  • Fichiers de log Claude Desktop (selon votre OS)
  • Sortie stderr du serveur MCP

📁 Structure du projet

mcp-wikidata/
  ├ mcp_wikidata/           # Package principal
     ├ __init__.py
     ├ server.py           # Serveur MCP principal
     ├ config.py           # Configuration
     ├ tools.py            # Définitions des outils MCP
     └ wikidata_client.py  # Client API Wikidata
  ├ tests/                  # Tests
  ├ run_mcp_wikidata.sh    # Script wrapper (recommandé)
  ├ test_*.py              # Scripts de test
  ├ pyproject.toml         # Configuration du projet
  ├ .env.example           # Variables d'environnement
  └ README.md

🤝 Contribution

Les contributions sont bienvenues ! N'hésitez pas à :

  • Signaler des bugs
  • Proposer des améliorations
  • Ajouter de nouveaux outils MCP
  • Améliorer la documentation

📄 Licence

MIT License - voir le fichier LICENSE pour plus de détails.

📚 Ressources utiles


Généré avec Claude Code 🚀

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选