mcp-offline-wikipedia
Provides offline search and retrieval of Wikipedia articles using Kiwix .zim files, enabling LLMs to access full Wikipedia content without internet.
README
Offline Wikipedia MCP Server 📚🔌
A fast, completely offline Model Context Protocol (MCP) server that connects local or cloud LLMs to locally downloaded Kiwix archives (.zim files).
This project bridges the gap between Large Language Models (running locally in LM Studio, Claude Desktop, or Cursor) and massive offline knowledge bases. By using the official Python MCP SDK and libzim, your LLM can search and read full Wikipedia articles — and any other Kiwix archive — without an internet connection.
✨ Features
- 🔍 Smart search — uses full-text index search with automatic fallback to title/prefix search
- 📚 Multi-archive support — point at a folder and every
.zimfile inside is loaded automatically - 📄 Direct article lookup — retrieve a specific article by exact title, bypassing search
- 🏷️ Source labelling — results show which archive they came from (e.g.
[wikipedia_en_wp1-0.8_nopic_2026-04]) - 🧹 Clean output — strips HTML, scripts, tables, citation numbers
[1], and[edit]markers - ✂️ Configurable truncation — prevent context-window overflows with
WIKI_MAX_CHARS - 🔒 Thread-safe — double-checked locking for safe use in concurrent MCP environments
- 📦 Any
.zimfile — works with Wikipedia, Wiktionary, Stack Overflow, and other Kiwix archives
🛠️ Tools Exposed to the LLM
| Tool | Description |
|---|---|
search_wikipedia(query, num_results) |
Search all loaded archives using full-text index with fallback to title/prefix search |
get_article(title) |
Fetch a specific article by its exact title, searching across all loaded archives |
📥 Step 1 — Download Kiwix .zim Archives
Because LLMs only process text, it is highly recommended to download "nopic" (no pictures) versions to save disk space.
- Go to the Kiwix Library: https://library.kiwix.org/?lang=eng&q=wikipedia
- Recommended files:
- Wikipedia English (wp1/Mini, nopic) — most important articles, no images (~2 GB)
- Wikipedia English (Maxi, nopic) — full Wikipedia, no images (~22 GB)
- Save all
.zimfiles into a single dedicated folder (e.g.~/kiwix-zim/). The server will load every.zimfile in that folder automatically.
⚠️ macOS users: Do not store your
.zimfiles inside~/Documents,~/Desktop, or~/Downloads. macOS restricts app access to those folders and will cause anError opening ZIM file. Use your home directory or a custom folder instead (e.g.~/kiwix-zim/).
🚀 Step 2 — Installation
git clone https://github.com/Rome-NotBeepBoop/mcp-offline-wikipedia.git
cd mcp-offline-wikipedia
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
⚙️ Step 3 — Configure Your MCP Client
Replace the example paths below with your actual paths.
⚠️ Always use the full path to the venv Python (
venv/bin/python), not the systempython3. This guarantees the correctlibzimversion is used.
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"offline-wikipedia": {
"command": "/absolute/path/to/mcp-offline-wikipedia/venv/bin/python",
"args": ["/absolute/path/to/mcp-offline-wikipedia/mcp_wiki_server.py"],
"env": {
"WIKI_ZIM_DIR": "/absolute/path/to/your/kiwix-zim/",
"WIKI_MAX_CHARS": "15000"
}
}
}
}
Cursor
Add the following to your Cursor MCP config (.cursor/mcp.json):
{
"mcpServers": {
"offline-wikipedia": {
"command": "/absolute/path/to/mcp-offline-wikipedia/venv/bin/python",
"args": ["/absolute/path/to/mcp-offline-wikipedia/mcp_wiki_server.py"],
"env": {
"WIKI_ZIM_DIR": "/absolute/path/to/your/kiwix-zim/"
}
}
}
}
LM Studio
In LM Studio, go to Developer → mcp.json and fill in:
{
"mcpServers": {
"offline-wikipedia": {
"command": "/absolute/path/to/mcp-offline-wikipedia/venv/bin/python",
"args": ["/absolute/path/to/mcp-offline-wikipedia/mcp_wiki_server.py"],
"env": {
"WIKI_ZIM_DIR": "/absolute/path/to/your/kiwix-zim/",
"WIKI_MAX_CHARS": "15000"
}
}
}
}
🌍 Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
WIKI_ZIM_DIR |
✅ Preferred | — | Path to a folder — every .zim file inside is loaded |
WIKI_ZIM_PATH |
Legacy | — | Path to a single .zim file (use WIKI_ZIM_DIR instead) |
WIKI_MAX_CHARS |
No | 15000 |
Max characters returned per article |
WIKI_ZIM_DIRtakes priority overWIKI_ZIM_PATHif both are set.
❓ Troubleshooting
Neither WIKI_ZIM_DIR nor WIKI_ZIM_PATH is set
→ Make sure the env block is present in your MCP client config with the correct variable name.
ZIM archive not found at: ...
→ Double-check the path. On Windows, use forward slashes or escaped backslashes: C:/Users/you/kiwix-zim/.
macOS: Error opening ZIM file even though the file exists and the path is correct
→ macOS restricts app access to ~/Documents, ~/Desktop, and ~/Downloads without explicit permission. LM Studio (and the Python process it spawns) may be silently blocked. Two fixes:
- Quick fix: Move your
.zimfiles to~/kiwix-zim/or any other folder you created yourself, and updateWIKI_ZIM_DIRaccordingly. - Proper fix: Go to System Settings → Privacy & Security → Files and Folders and grant LM Studio access to the folder containing your
.zimfiles.
Error opening ZIM file — but the file opens fine in a Python terminal
→ LM Studio is using a different Python than your terminal. Always use the venv Python in your MCP config (venv/bin/python), not the system python3. Verify it has the right libzim:
/absolute/path/to/venv/bin/python -c "import libzim; print('ok')"
Server starts but the LLM says it can't find any articles
→ Some .zim files don't have a full-text index. The server will automatically fall back to title search, but results may be less accurate for vague queries. Try using the exact article title.
High memory usage
→ Each .zim archive is loaded on first use. Larger archives (Maxi) will use more RAM. The Mini/nopic version is recommended for most use cases.
🤝 Contributing
Contributions are welcome! Please open an issue first to discuss what you'd like to change. Pull requests should target the main branch.
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-improvement) - Commit your changes (
git commit -m 'Add some improvement') - Push to your branch (
git push origin feature/my-improvement) - Open a Pull Request
📜 License
This project is licensed under the MIT License — see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。