mcp-server-qlever
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-qlever show me the most frequent predicates in the dataset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-qlever
A Model Context Protocol (MCP) server for the QLever SPARQL engine. Connect Claude Code or any MCP-compatible client to knowledge graphs powered by QLever.
Features
Execute SPARQL queries with formatted text or raw JSON output
Explore dataset schemas by listing predicates ordered by frequency
Look up entities by IRI with outgoing and incoming triples
Search for entities by label using full-text matching
Predicate and class completion from what actually exists in the index
Query plan analysis without execution
Geographic search (radius / bounding box) via GeoSPARQL functions
SPARQL 1.1 Update with dry-run preview and safety guards
Input sanitization: IRI validation and SPARQL injection prevention
Works with any QLever instance (local Docker, self-hosted, or public)
Related MCP server: RDF4J MCP Server
Quick Start
Pick your scenario:
A) You already have a QLever endpoint
claude mcp add qlever -- npx -y mcp-server-qlever -e http://your-qlever:7019Done. Claude can now query your knowledge graph.
B) You want everything from scratch (QLever + MCP)
docker compose -f docker-compose.allinone.yml up -d --wait
claude mcp add qlever -- npx -y mcp-server-qlever -e http://localhost:7019This starts QLever with a small test dataset and connects the MCP server to it.
C) You want real-world data (e.g. German National Library)
cd examples/gnd
docker compose up -d --wait
claude mcp add gnd -- npx -y mcp-server-qlever -e http://localhost:7020First run downloads and indexes the GND Werk authority data (~90 MB, ~3.5M triples) automatically.
See examples/gnd/ for details.
Installation
There are several ways to install and run the server. Pick whichever fits your setup.
npx (no install)
npx mcp-server-qlever --endpoint http://localhost:7019npm (global)
npm install -g mcp-server-qlever
mcp-server-qlever --endpoint http://localhost:7019Docker
docker run --rm -i ghcr.io/xorwell/mcp-server-qlever:latest \
--endpoint http://host.docker.internal:7019Use --network=host on Linux to reach a QLever instance on localhost:
docker run --rm -i --network=host ghcr.io/xorwell/mcp-server-qlever:latest \
--endpoint http://localhost:7019Environment variables work too:
docker run --rm -i --network=host \
-e QLEVER_ENDPOINT=http://localhost:7019 \
-e QLEVER_ACCESS_TOKEN=my-token \
ghcr.io/xorwell/mcp-server-qlever:latestFrom source
git clone https://github.com/XORwell/mcp-server-qlever.git
cd mcp-server-qlever
npm install
npm run build
node dist/index.js --endpoint http://localhost:7019Requirements: Node.js 20+ (all methods), or Docker/Podman (Docker method).
Configuration
Claude Code (CLI)
# Project-scoped
claude mcp add qlever -- npx -y mcp-server-qlever --endpoint http://localhost:7019
# User-scoped (all projects)
claude mcp add -s user qlever -- npx -y mcp-server-qlever --endpoint http://localhost:7019Using the Docker image instead of npx:
claude mcp add qlever -- docker run --rm -i --network=host \
ghcr.io/xorwell/mcp-server-qlever:latest --endpoint http://localhost:7019Verify:
claude mcp listClaude Code (VS Code / Cursor)
Edit .vscode/settings.json:
{
"claude-code.mcpServers": {
"qlever": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "--endpoint", "http://localhost:7019"]
}
}
}Or with Docker:
{
"claude-code.mcpServers": {
"qlever": {
"command": "docker",
"args": [
"run", "--rm", "-i", "--network=host",
"ghcr.io/xorwell/mcp-server-qlever:latest",
"--endpoint", "http://localhost:7019"
]
}
}
}Manual configuration (any MCP client)
Add to ~/.claude.json or .claude/settings.json:
{
"mcpServers": {
"qlever": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "--endpoint", "http://localhost:7019"]
}
}
}With access token via env:
{
"mcpServers": {
"qlever": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "--endpoint", "http://localhost:7019"],
"env": {
"QLEVER_ACCESS_TOKEN": "your-token-here"
}
}
}
}Multiple endpoints
Register several QLever instances under different names:
{
"mcpServers": {
"qlever-wikidata": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "-e", "http://localhost:7019"]
},
"qlever-osm": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "-e", "http://localhost:7020"]
},
"qlever-dblp": {
"command": "npx",
"args": ["-y", "mcp-server-qlever", "-e", "http://localhost:7021"]
}
}
}Tool Reference
Tool | Description | Key Parameters |
| Execute SPARQL and get formatted text results |
|
| Execute SPARQL and get raw JSON response |
|
| Retrieve dataset metadata (triple count, predicates, etc.) | -- |
| Look up all triples for an entity by IRI |
|
| Full-text search for entities by label |
|
| List available predicates ordered by frequency |
|
| Suggest predicate or class IRIs containing a search term, ordered by usage |
|
| Run a query without returning rows and show its execution tree (sizes, timings) |
|
| List all named graphs with triple counts |
|
| Search QLever's text index for entity-keyword co-occurrence |
|
| Geographic search (radius or bounding box) via GeoSPARQL |
|
| Execute SPARQL 1.1 Update (requires access token) |
|
Prompts
Prompt | Description |
| Step-by-step workflow for discovering an unknown QLever dataset |
| Validated workflow for SPARQL Update operations with dry-run preview |
QLever-Specific Features
This server goes beyond generic SPARQL access by exposing QLever's unique capabilities:
Predicate and class completion -- The
sparql_autocompletetool uses QLever'sql:has-predicatepattern to suggest predicates (or classes) that actually exist in the index, ordered by usage.Query plan analysis -- The
analyze_querytool returns QLever's runtime information (execution tree with estimated vs. actual sizes and per-operation timings). QLever has no plan-only mode, so the query is executed, but no rows are returned.Full-text search -- The
search_fulltexttool uses QLever's SPARQL+Text extension to find entities co-occurring with keywords in the text corpus.Spatial queries -- The
spatial_querytool uses QLever'sgeof:distance,geof:latitudeandgeof:longitudefunctions on WKT point literals; radius results include the distance in km.Safe SPARQL Update -- The
sparql_updatetool includes a dry run that echoes the statement without sending it, aconfirmrequirement for everyDROPandCLEAR, and access token enforcement.
Security
All user-controlled inputs are sanitized before interpolation into SPARQL:
String literals are escaped for
\ " \n \r \tto prevent SPARQL injectionIRIs are validated against RFC 3987 (rejects
<>"{}|\^`and control characters)Predicates are validated with a strict regex matching prefixed names or safe full IRIs
SPARQL Update requires explicit access token and flags destructive operations
Environment Variables
Variable | Description | Default |
| QLever API URL (fallback if | -- |
| Access token for privileged operations | -- |
| Default query timeout (e.g. |
|
CLI flags take precedence over environment variables.
CLI Usage
mcp-server-qlever --endpoint <url> [options]
Options:
-e, --endpoint <url> QLever API endpoint URL (required)
-t, --access-token <tok> Access token for privileged operations
--timeout <duration> Default query timeout (default: 30s)
-h, --help Show help message
-v, --version Show versionRunning QLever with Docker
QLever requires a two-step process: build an index from RDF data, then serve it.
Preconfigured dataset
docker run -it --name qlever-wikidata -p 7019:7019 adfreiburg/qlever:latest bash
# Inside the container:
qlever setup-config wikidata # or: olympics, dblp, osm-planet, uniprot, ...
qlever get-data # downloads the dataset
qlever index # builds the index (may take minutes to hours)
qlever start # starts the SPARQL server on port 7019Custom RDF data
docker run -it --name qlever-custom -p 7019:7019 \
-v /path/to/your/data:/data \
adfreiburg/qlever:latest bash
# Inside the container:
qlever-index -i /data/myindex -f /data/mydata.nt -F nt -s /data/settings.json
qlever-server -i /data/myindex -p 7019 -m 4GBSee the QLever documentation for details on dataset configuration, index settings, and performance tuning.
Examples
The examples/ directory contains ready-to-use setups for specific datasets:
Example | Dataset | Triples | Setup |
GND Werk (Deutsche Nationalbibliothek) | ~3.5M |
|
Each example includes a docker-compose.yml that downloads, converts, and indexes the data
automatically on first run. Subsequent starts are instant (index persisted in Docker volume).
Want to add your own dataset? Copy any example directory and adjust the data source URL.
Development
git clone https://github.com/XORwell/mcp-server-qlever.git
cd mcp-server-qlever
npm install
npm run buildTesting
The project has 336 tests across three layers:
# Unit tests only (no Docker needed)
npm run test:unit
# Integration tests against real QLever (scientists dataset)
docker compose -f docker-compose.test.yml up -d --wait
npm run test:integration
docker compose -f docker-compose.test.yml down -v
# E2E tests over real MCP stdio transport (GND dataset, 390K triples)
# First, generate the test fixture from DNB open data:
pip install ijson
curl -o /tmp/gnd-werk.jsonld.gz https://data.dnb.de/opendata/authorities-gnd-werk_lds_20260217.jsonld.gz
python3 scripts/jsonld-to-nt.py -i /tmp/gnd-werk.jsonld.gz --limit 50000 > test/fixtures/gnd/gnd-werk-sample.nt
docker compose -f docker-compose.gnd.yml up -d --wait
npm run build
npm run test:e2e
docker compose -f docker-compose.gnd.yml down -v
# Everything at once
npm run test:ci # unit + integration (scientists)
npm run test:ci:gnd # all tests including E2E (GND)Layer | Tests | What it covers |
Unit | 291 | All tools, client, security (SPARQL injection, IRI validation, bounds, timeouts) |
Integration | 31 | Real QLever queries against scientists and GND authority data |
E2E | 29 | Real MCP server process over stdio, all 12 tools + 2 prompts against live QLever |
Building the Docker image
docker build -t mcp-server-qlever:local .
docker run --rm mcp-server-qlever:local --helpLicense
Links
QLever -- High-performance SPARQL engine (University of Freiburg)
QLever Documentation -- Setup guides and API reference
Model Context Protocol -- MCP specification
GitHub Issues -- Bug reports and feature requests
Available Tools
12 toolsanalyze_query
Analyze how QLever evaluates a SPARQL query. The query IS executed (QLever has no plan-only mode) but no result rows are returned. Shows the query execution tree with estimated vs. actual sizes, per-operation timings and the total result size. Use a short timeout for potentially expensive queries.
Inputs: query (required), timeout.
describe_entity
Look up all triples where a given IRI appears as subject or object. Returns both outgoing properties (where the entity is the subject) and incoming references (where it is the object). Accepts full IRIs (e.g. 'http://www.wikidata.org/entity/Q42') or prefixed names if the dataset supports them.
Inputs: iri (required), limit.
get_index_stats
Retrieve metadata about the QLever index: dataset name, number of triples, predicates, subjects, and objects. Useful for understanding the scope of the knowledge graph before querying.
Inputs: no named parameters.
get_predicates
List the predicates (properties) available in the dataset, ordered by frequency. Useful for exploring an unfamiliar knowledge graph and understanding its schema before writing queries.
Inputs: limit, timeout.
list_named_graphs
List named graphs in the dataset. Call this before graph-scoped queries or updates.
Inputs: limit.
search_entities
Search for entities by name or label using SPARQL text matching. Works with datasets that have rdfs:label or schema:name predicates. Returns matching entities with their labels.
Inputs: search_term (required), limit, label_predicate.
search_fulltext
Search QLever's text index for entities co-occurring with keywords. Different from search_entities which matches labels. Requires text index.
Inputs: keywords (required), limit, filter_type.
sparql_autocomplete
Use this BEFORE sparql_query when unsure which predicates or classes exist. Suggests predicate or class IRIs from the dataset that contain the given text, ordered by how often they are used. For entities, use search_entities.
Inputs: search_term (required), kind, limit.
sparql_query
Execute a SPARQL query against the configured QLever endpoint. Supports SELECT, ASK, CONSTRUCT, and DESCRIBE query forms. Returns results as a formatted table with timing information.
Inputs: query (required), timeout, max_rows.
sparql_query_json
Execute a SPARQL query and return the raw QLever JSON response. Useful when you need structured data for further processing (result arrays, timing breakdown, total result count).
Inputs: query (required), timeout, max_rows.
sparql_update
Execute a SPARQL 1.1 Update. REQUIRES access token. Use dry_run:true to preview. dry_run:true only echoes the statement without contacting QLever. Any DROP or CLEAR requires confirm:true.
Inputs: update (required), confirm, dry_run, graph_uri.
spatial_query
Find entities within a geographic area (GeoSPARQL geof: functions on WKT point literals). Supports radius and bounding box modes.
Inputs: params (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Query your own knowledge graph from any MCP client. The graph lives in a database you own.
Repository knowledge graph MCP server for codebase understanding and debugging.
MCP server for querying BrainKB, a knowledge base for neuroscience knowledge graphs.
MCP server for the Seline Analytics API
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceThe Model Context Protocol (MCP) server provides a conversational interface for the exploration and analysis of RDF Turtle Knowledge Graph in Local File mode or SPARQL Endpoint.56MIT
- AlicenseAqualityCmaintenanceAn MCP server that enables AI-powered exploration of RDF data and SPARQL querying via RDF4J. It provides tools for executing queries, searching knowledge graph resources, and retrieving schema summaries.131MIT
- AlicenseAqualityCmaintenanceMCP server exposing SPARQL query functionalities for LLMs, enabling query execution, validation, and graph exploration across SPARQL endpoints.722 PyPIMIT
- FlicenseNot gradedqualityCmaintenanceRead-only MCP server for querying an evidence-aware knowledge vault with temporal and provenance-aware data, supporting agent memory and semantic graph projections.-