mcp-wikipedia
by jermatic1
README.md
# mcp-wikipedia
An MCP server for searching Wikipedia's [Vital Articles](https://en.wikipedia.org/wiki/Wikipedia:Vital_articles), the roughly 50,000 most important English articles, from a local index.
## Setup
Copy `.env.example` to `.env` and set a User-Agent with your contact details, which Wikipedia asks clients to send.
## Run
Requires [uv](https://docs.astral.sh/uv/) and [Task](https://taskfile.dev/).
```sh
task setup
task serve
```
The first run downloads the article list, streams the 37 GB English Wikipedia dataset keeping only the Vital Articles, and builds the index in `./data`. If interrupted, it resumes where it left off. Later runs start immediately.
The server listens at `http://localhost:8000/mcp`.
## Docker
Set `UID` and `GID` in `.env` to your user and group IDs so the files in `./data` belong to you. Then:
```sh
mkdir data
docker compose up -d
```
## Tools
- `search(query, limit=5)`: find articles by keywords or title; tolerates small typos. Returns title, description, start of the summary, Wikidata ID, Vital level, and topic.
- `get_article(title, section=None)`: an article's summary, infobox facts, and section headings. Pass `section` to also get that section's text.
## Evaluate
Create `data/questions.tsv` with a question and the expected article title per line, separated by a tab, then run `task evaluate` to see how often the expected article is in the top 3 results.
## Refresh the article list
The Vital list is fetched as it stood on the dataset's snapshot date, so its titles match the dataset. To move to a newer dataset, update `REVISION` and `SNAPSHOT` in `src/mcp_wikipedia/download.py`, then:
```sh
task vital --force
task serve
```
The articles are downloaded again for the new list and the index is rebuilt. With Docker: `docker compose exec wikipedia task vital --force`, then `docker compose restart`.
## Development
```sh
task check # tests, lint, formatting
```
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues