WI

Wikipedia Context MCP Server for LLMs

Retrieve Wikipedia context for LLMs with an MCP server that supplies accurate, cited background to improve model responses.

Quick Install
npx -y @Rudra-ravi/wikipedia-mcp

Overview

The Wikipedia Context MCP Server supplies accurate, citeable Wikipedia background for large language models (LLMs) using the Model Context Protocol (MCP). Instead of asking an LLM to “know” facts, you can attach precise, source-linked context from Wikipedia so the model can generate answers grounded in verifiable material. This reduces hallucination and makes outputs easier to trace back to primary sources.

The server runs as a lightweight HTTP service that fetches, caches, and formats Wikipedia content into MCP-compatible resources. It supports direct title lookups, search-based retrieval, and returns context blocks with citations and metadata that LLM orchestration layers can consume and attach to prompts or toolkits.

Repository: https://github.com/Rudra-ravi/wikipedia-mcp

Features

  • Retrieve Wikipedia summaries, sections, and citations formatted for MCP consumption
  • Title-based fetch and search-based retrieval (keyword / semantic)
  • MCP-compliant resource responses (id, title, content, url, citation metadata)
  • Caching layer to reduce API hits and improve latency
  • Simple HTTP API suitable for integration with LLM prompt pipelines and RAG systems
  • Configurable via environment variables and runnable via Docker

Installation / Configuration

Clone the repository and run with your preferred stack. The examples below are generic—check the project README for exact commands.

Clone:

git clone https://github.com/Rudra-ravi/wikipedia-mcp.git
cd wikipedia-mcp

Run with Docker:

# build
docker build -t wikipedia-mcp .

# run (example)
docker run -p 8080:8080 \
  -e PORT=8080 \
  -e CACHE_TTL=3600 \
  wikipedia-mcp

Run locally (typical Python/Node style examples):

# Python (if the project is Python-based)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export PORT=8080
python -m wikipedia_mcp

# Node.js (if the project is Node-based)
npm install
export PORT=8080
npm start

Example .env

PORT=8080
CACHE_TTL=3600          # seconds
WIKI_API_URL=https://en.wikipedia.org/w/api.php
CORS_ORIGINS=*          # or specific origins

Available Resources

The server exposes HTTP endpoints that return MCP-style resources. Typical endpoints include:

PathMethodDescription
/healthGETHealth check
/searchGETKeyword search across Wikipedia (query param: q)
/contextGETFetch MCP context for a title or page id (params: title, pageid)
/resourcesPOSTAccepts a list of queries and returns matching MCP resources in bulk

Example: GET a context by title

curl "http://localhost:8080/context?title=Ada_Lovelace"

Example response (MCP-like JSON)

{
  "id": "wiki:en:Ada_Lovelace",
  "title": "Ada Lovelace",
  "content": "Augusta Ada King, Countess of Lovelace ...",
  "url": "https://en.wikipedia.org/wiki/Ada_Lovelace",
  "source": "wikipedia",
  "citation": {
    "type": "web",
    "url": "https://en.wikipedia.org/wiki/Ada_Lovelace"
  },
  "retrieved_at": "2026-04-10T12:00:00Z"
}

Note: Field names and exact format follow MCP conventions so orchestration layers can attach these resources as context bundles.

Use Cases

  • Retrieval-Augmented Generation (RAG)

    • Retrieve the most relevant Wikipedia pages as MCP resources, attach them to prompts, and let an LLM produce answers citing the original page URLs.
    • Example: Search for “photosynthesis” → return page summaries and section extracts → LLM composes an explanation that references the Wikipedia URL.
  • Grounded Q&A and Chatbots

    • When a user asks a factual question, fetch the corresponding Wikipedia article and include it as a context resource to ensure the answer is verifiable.
    • Example Prompt Flow: [system preface] + [context resource: Chlorophyll section] + user question.
  • Fact-checking and Source Attribution

    • Use the citation metadata returned by the MCP server to add inline citations to model responses or to build an audit trail for claims.
  • Tooling for LLM plugins or agents

    • Expose concise, cited background documents to agent toolchains that evaluate external evidence before taking actions.

Integration Tips

  • Cache aggressively: Wikipedia pages are stable; use a sensible TTL to reduce latency and API hits.
  • Chunk long pages: Break long articles into sections to keep context sizes manageable for model input windows.
  • Attach metadata: Always include source URLs and retrieval timestamps so downstream systems can show provenance.
  • Rate limits: If making large-scale queries, respect the Wikipedia API rate guidance and consider a local mirror or bulk dumps for high-throughput needs.

For exact API parameters, response schemas, and deployment scripts, see the project repository: https://github.com/Rudra-ravi/wikipedia-mcp.

Tags:ai-ml