The MCP Server for Apache Jena provides a connection between AI agents and Apache Jena, enabling SPARQL query capabilities for RDF data. This server implements the Model Context Protocol, allowing AI agents like Cursor or Claude to access and query semantic data stored in Jena Fuseki.
Clone the repository:
git clone https://github.com/ramuzes/mcp-jena.git
cd mcp-jena
Install dependencies:
npm install
Build the TypeScript code:
npm run build
Build the Docker image:
docker build -t mcp-jena .
Run with Docker:
docker run -e JENA_FUSEKI_URL=http://your-jena-server:3030 -e DEFAULT_DATASET=your_dataset mcp-jena
Run with default settings (localhost:3030 for Jena, 'ds' for dataset):
npm start
Use custom Jena endpoint, dataset, and authentication:
npm start -- --endpoint http://your-jena-server:3030 --dataset your_dataset --username your_username --password your_password
With short flags:
npm start -- -e http://your-jena-server:3030 -d your_dataset -u your_username -p your_password
You can configure the server using environment variables:
JENA_FUSEKI_URL
: URL of your Jena Fuseki server (default: http://localhost:3030)DEFAULT_DATASET
: Default dataset name (default: ds)JENA_USERNAME
: Username for HTTP Basic authenticationJENA_PASSWORD
: Password for HTTP Basic authenticationPORT
: Port for the MCP server (default: 8080)API_KEY
: API key for MCP server authenticationThe MCP server provides these tools for interacting with Jena:
Use execute_sparql_query
to run SPARQL queries against the Jena dataset.
Example query:
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object
}
LIMIT 10
Use execute_sparql_update
to modify RDF data in the dataset.
Example update:
PREFIX ex: <http://example.org/>
INSERT DATA {
ex:subject1 ex:predicate1 "object1" .
ex:subject2 ex:predicate2 42 .
}
Use list_graphs
to see all available named graphs in the dataset.
Use sparql_query_templates
to get pre-built templates for various purposes:
SELECT ?subject ?predicate ?object
FROM NAMED <http://example.org/graph1>
WHERE {
GRAPH <http://example.org/graph1> {
?subject ?predicate ?object
}
}
LIMIT 10
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.