jena-mcp-server
Provides a working connection to Apache Jena Fuseki, enabling SPARQL queries and updates, Graph Store Protocol operations for reading, writing, and dropping named graphs, bulk RDF loading from disk, and dataset/server administration such as listing, creating, deleting, backing up, and compacting datasets.
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., "@jena-mcp-server run a SPARQL query to list all classes used 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.
jena-mcp-server
Give a language model a working connection to Apache Jena Fuseki: SPARQL queries and updates, whole named graphs over the Graph Store Protocol, bulk RDF loading from disk, and dataset administration — sixteen tools over the Model Context Protocol.
┌─ your MCP client ─┐ ┌─ jena-mcp-server ─┐ ┌─ Fuseki ────────┐
│ Claude Code, │ stdio │ 16 tools │ HTTP │ SPARQL │
│ Claude Desktop, │◄──────►│ graphs as │◄──────►│ Graph Store │
│ Cursor, … │ │ resources │ │ /$/ admin │
└───────────────────┘ └───────────────────┘ └─────────────────┘Why this exists
A triplestore is an awkward thing to hand to a model. The obvious approach — one tool that takes a SPARQL string — falls over in practice for three reasons, and this server is built around all three:
Unbounded queries flood the context. SELECT ?s ?p ?o WHERE { ?s ?p ?o } is
the first thing anyone writes against an unfamiliar graph. Over a dataset of
1 600 triples it serialises to roughly 630 000 characters — about 157 000 tokens
in a single tool result. Here a SELECT without its own LIMIT gets one, every
result has a character ceiling, and anything genuinely large goes to a file
instead.
SPARQL is the wrong tool for whole graphs. Reading a graph with CONSTRUCT
puts it through the query parser and back out as a result set; replacing one
means DELETE followed by an INSERT DATA carrying the entire content as query
text. The Graph Store Protocol does both in one request, and this server exposes
it directly — including loading a .ttl file from disk, which never enters the
conversation at all.
Administration is where the sharp edges are. Fuseki answers 405, not 404,
for a dataset that does not exist. Without a way to list datasets, that error is
indistinguishable from a wrong endpoint path. And CREATE GRAPH on TDB2 returns
200 while creating nothing you can observe — an empty graph and a missing graph
are the same thing. Both are documented in the tool descriptions, where the
model will actually read them.
Related MCP server: mcp-sparql
Install
npm install -g jena-mcp-serverOr from source:
git clone https://github.com/MatthiasVanDE/jena-mcp-server.git
cd jena-mcp-server && npm install && npm run buildNode 20 or newer. One runtime dependency: the MCP SDK.
Connect it
Claude Code
claude mcp add jena \
-e JENA_ENDPOINT=http://localhost:3030 \
-e JENA_DATASET=mydata \
-- npx -y jena-mcp-serverClaude Desktop — in claude_desktop_config.json:
{
"mcpServers": {
"jena": {
"command": "npx",
"args": ["-y", "jena-mcp-server"],
"env": {
"JENA_ENDPOINT": "http://localhost:3030",
"JENA_DATASET": "mydata",
"JENA_USERNAME": "admin",
"JENA_PASSWORD": "…"
}
}
}
}Putting a password in a client config file means it sits there in plain text. docs/configuration.md shows a two-line wrapper that keeps it in one place instead.
The sixteen tools
Querying |
|
Graphs |
|
Datasets |
|
Server |
|
Named graphs are also exposed as MCP resources, so a client can pull one in without composing a query.
Full reference: docs/tools.md.
Two settings worth knowing before you start
JENA_FILES_DIR is the only directory the file tools may touch, and until
you set it they refuse to run. That is deliberate: a tool that "loads a file into
the triplestore" is, unfenced, a tool that can ship any readable file on the
machine to a remote server.
JENA_READ_ONLY=true hides the seven writing tools rather than refusing
them on call. A model does not attempt what it is not offered.
Everything else: docs/configuration.md.
Documentation
from zero to a graph you can query | |
every tool, argument and failure mode | |
all settings, and how to keep secrets out of config files | |
schema sync, bulk loading, exploring an unknown graph | |
why it is built this way |
Development
npm run build # compile
npm test # unit tests, no server needed
npm run check # bothThe unit tests cover the parts where being wrong is quiet: which SPARQL form a string is, when a row cap may be appended, and what the file sandbox lets through.
Licence and acknowledgement
MIT — see LICENSE.
This is an independent implementation. It was written after working with ramuzes/mcp-jena (MIT, © 2025 ramuz), which demonstrated the idea of an MCP server for Jena; no code from it is included here, but credit for the starting point belongs there.
Available Tools
16 toolsbackup_datasetA
Start a server-side backup of a dataset.
The backup is written on the server, into Fuseki's backups directory, and runs in the background: this returns a task id to poll with task_status.
Do this before anything destructive. There is no undo for drop_graph or delete_dataset.
Listed as a read tool deliberately -- it copies data out, it does not change it, so it stays available when the server runs read-only.
Inputs: dataset.
compact_datasetA
Compact a TDB2 dataset, reclaiming space held by superseded data.
Runs in the background; poll with task_status. delete_old removes the pre-compaction copy once it succeeds, which frees the most space and cannot be undone.
Only meaningful for TDB2 datasets.
Inputs: dataset, delete_old.
create_datasetA
Create a dataset on the server.
kind "tdb2" (the default) is persistent and survives a restart; "mem" is in-memory and is gone when the server stops -- useful for a scratch space, and a trap if you meant to keep the data.
Fuseki writes a configuration file for the new dataset, so it comes back after a restart. A dataset created this way has the stock endpoints: sparql, query, update, data and get.
Inputs: name (required), kind.
dataset_statsA
Size and shape of a dataset: triple counts, graphs, classes and properties.
A quick orientation for a store you have not seen before -- how much is in it, how it is divided over graphs, and which types and predicates dominate.
Inputs: top, dataset.
delete_datasetA
Remove a dataset from the server and delete its files. Irreversible.
This is not "unmount": the data on disk goes too. Take a backup first if there is anything in it you would miss.
Inputs: name (required), confirm (required).
describe_resourceB
Everything the store knows about one IRI, in both directions.
Returns the triples where the IRI is the subject and, unless you turn it off, those where it is the object -- which is usually where the interesting part is, because it shows what points at the thing.
Faster to reach for than writing the query by hand, and it names the graph each triple came from.
Inputs: iri (required), limit, dataset, incoming.
drop_graphA
Delete a named graph and everything in it. There is no undo.
Run backup_dataset first if the contents matter.
A 404 means the graph was already empty, which on TDB2 means it did not exist.
Inputs: graph (required), dataset.
list_datasetsA
List the datasets on this Fuseki server and the endpoints each offers.
Reach for this first when a call fails with 405. Fuseki answers 405 -- not 404 -- for a dataset name it does not know, which reads like "wrong method" when it actually means "no such dataset".
The endpoint names matter too. A dataset configured through an assembler file often exposes only "sparql", while Fuseki's stock configuration also accepts "query". This shows which one you have.
Inputs: no named parameters.
list_graphsA
List the named graphs in a dataset, with a triple count for each.
Only graphs holding at least one triple appear, and on TDB2 that is the whole story: an empty graph is indistinguishable from one that was never created. If a graph you just made is missing, it has no triples yet.
The default graph is reported separately, because a query without a GRAPH clause reads that one -- and on a store without a union default graph it is often empty while the named graphs are full.
Inputs: dataset.
load_rdf_fileA
Load an RDF file from the sandbox into a dataset.
Accepts Turtle, N-Triples, TriG, N-Quads, JSON-LD and RDF/XML; the media type comes from the extension. TriG and N-Quads carry their own graph names, so do not pass a target graph with those -- the file decides.
This exists so that bulk RDF never has to pass through the conversation. A 44 kB ontology rewritten as INSERT DATA costs roughly 11 000 tokens; here it costs none.
Inputs: file (required), mode, graph, dataset.
read_graphA
Fetch one named graph whole, as Turtle.
One HTTP request, and it never touches the query parser -- the right way to read a graph you intend to inspect or copy. A CONSTRUCT returns the same triples but has to be parsed as a query first.
A 404 here means the graph holds no triples. That is not an error about the endpoint.
Graphs get large quickly; pass out_file for anything beyond a few hundred triples.
Inputs: graph, format, dataset, out_file.
server_infoA
Version, uptime and per-dataset request statistics.
Worth a call at the start of a session to confirm you are talking to the server you think you are -- a wrong endpoint that happens to answer is otherwise hard to spot.
Inputs: dataset.
sparql_queryA
Run a read-only SPARQL query (SELECT, CONSTRUCT, ASK or DESCRIBE).
Forms: SELECT returns rows, CONSTRUCT and DESCRIBE return triples, ASK returns a boolean. WHERE is optional -- "SELECT ?s { ?s ?p ?o }" is valid SPARQL.
Property paths are the reason to reach for SPARQL over a REST API: a/b sequence ?s foaf:knows/foaf:name ?name a|b alternative ?s (rdfs:label|skos:prefLabel) ?label a* zero or more ?s skos:broader* ?ancestor a+ one or more ?s rdfs:subClassOf+ ?super a? zero or one ^a inverse ?child ^ex:hasParent ?parent !a negated ?s !rdf:type ?o
Named graphs: GRAPH { ?s ?p ?o }, or GRAPH ?g { ... } to range over all of them. Note that a query without a GRAPH clause reads the default graph, which on many datasets is empty unless the store is configured with a union default graph.
Results are capped. A SELECT without its own LIMIT gets one appended (see default_limit), because an unbounded exploration query over even a small dataset can return hundreds of thousands of characters. Pass limit: 0 to lift the cap deliberately, and out_file to send a large result to disk instead of through the conversation.
Inputs: query (required), limit, dataset, out_file.
sparql_updateA
Run a SPARQL Update: INSERT, DELETE, LOAD, CLEAR, CREATE, DROP, COPY, MOVE or ADD.
To create a named graph, insert into it: INSERT DATA { GRAPH { "o" } }
CREATE GRAPH on its own is not enough on TDB2. It answers 200, but a graph with no triples does not exist as far as anything else is concerned -- list_graphs will not show it and the Graph Store Protocol answers 404 for it.
For replacing a whole graph from a file, write_graph and load_rdf_file are better: they do not put the RDF through this conversation.
Inputs: update (required), dataset.
task_statusA
The state of a background task started by backup_dataset or compact_dataset.
A task that has finished reports a "finished" timestamp; one still running does not.
Inputs: task_id (required).
write_graphA
Replace or extend one named graph with RDF you supply.
mode "replace" (the default) makes the graph exactly what you send: whatever was in it is gone. mode "merge" adds to what is there.
Replacing per graph is how a versioned schema is kept in sync -- one graph per module, so that updating one cannot wipe another.
Give the RDF either inline (content) or from a file (file). Prefer the file for anything beyond a handful of triples: it goes straight to the server instead of through the conversation.
Inputs: file, mode, graph, content, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Most tools have clearly distinct purposes (e.g., load_rdf_file vs write_graph vs sparql_update), but read_graph and describe_resource overlap somewhat in retrieving graph data, and sparql_query could be used for many read operations. Descriptions help clarify boundaries, so ambiguity is minimal.
Predominantly snake_case verb_noun pattern (e.g., load_rdf_file, create_dataset, drop_graph), but a few names like dataset_stats and task_status are noun-first rather than verb-first. Still, the convention is mostly consistent and readable.
16 tools is well-scoped for a Jena/Fuseki MCP server covering dataset management, graph operations, querying, and background tasks. Each tool earns its place without redundancy.
Covers most lifecycle operations: create/delete datasets, load/write/read graphs, SPARQL query/update, backup, compact, and task status. Missing a direct tool to list all triples or export a dataset, but these can be achieved via SPARQL. Minor gaps exist but core workflows are covered.
Related MCP Connectors
OAuth-protected, read-only-by-default MCP server for provenance-labeled QuillCaddie project memory.
Authenticated MCP access to the AIKI open knowledge commons.
- ORANO MCP ServerDeprecatedio.github.infotik
Read-only MCP server exposing a user ORANO library to their own AI agent.
The knowledge base your AI reads and writes, under your rules — over MCP, EU-hosted.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that connects AI agents to Apache Jena, enabling them to execute SPARQL queries and updates against RDF data stored in Jena Fuseki.8MIT
- AlicenseAqualityCmaintenanceMCP server exposing SPARQL query functionalities for LLMs, enabling query execution, validation, and graph exploration across SPARQL endpoints.729 PyPIMIT
- FlicenseNot gradedqualityCmaintenanceExposes a DuckDB-backed MCP server that lets an agent fetch a dataset's schema and run read-only SQL queries against it. All execution is filtered server-side, enforcing single-statement, read-only safety independent of the calling model's behavior.1-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query and modify RDF data, list named graphs, and access pre-built SPARQL templates on a Fuseki server, with optional HTTP Basic authentication.MIT