Yet Sparql Mcp Server
About
MCP SPARQL Server is a high-performance, configurable server that connects to any SPARQL endpoint and provides enhanced functionality including result formatting and caching. It's built on top of the MCP (Message Carrying Protocol) framework to provide a seamless, language-agnost
Details
- Author
- yet-market
- Downloads
- 227
- Categories
- Other
Jump to
- Connects to any SPARQL-compliant endpoint
- Supports SELECT, ASK, CONSTRUCT, and DESCRIBE queries
- Outputs JSON, simplified JSON, or tabular formats
- Configurable caching with LRU, LFU, and FIFO strategies
- Deployable as foreground process, daemon, or systemd service
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Yet Sparql Mcp ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install via pip install mcp-server-sparql or from source. Start the server by specifying a SPARQL endpoint: mcp-server-sparql --endpoint URL. Queries are sent using the MCP client with JSON actions that include a query_string and optional format parameter. The server can run in foreground mode, as a background daemon, or as a systemd service.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"yet sparql mcp server": [
{
"name": "sparql",
"command": "python3",
"args": [
"/path/to/server.py",
"--endpoint",
"https://data.legilux.public.lu/sparqlendpoint",
"--format",
"simplified",
"--cache-enabled",
"true",
"--cache-ttl",
"300",
"--cache-strategy",
"lru"
],
"env": {
"SPARQL_ENDPOINT": "https://data.legilux.public.lu/sparqlendpoint",
"SPARQL_TIMEOUT": "30",
"SPARQL_MAX_RESULTS": "1000",
"SPARQL_CACHE_ENABLED": "true",
"SPARQL_CACHE_TTL": "300",
"SPARQL_CACHE_MAX_SIZE": "100",
"SPARQL_CACHE_STRATEGY": "lru",
"PYTHONPATH": "/path/to/project/directory"
},
"transport": "stdio"
}
]
}
}
McpServers
[
{
"name": "sparql",
"command": "python3",
"args": [
"/path/to/server.py",
"--endpoint",
"https://data.legilux.public.lu/sparqlendpoint",
"--format",
"simplified",
"--cache-enabled",
"true",
"--cache-ttl",
"300",
"--cache-strategy",
"lru"
],
"env": {
"SPARQL_ENDPOINT": "https://data.legilux.public.lu/sparqlendpoint",
"SPARQL_TIMEOUT": "30",
"SPARQL_MAX_RESULTS": "1000",
"SPARQL_CACHE_ENABLED": "true",
"SPARQL_CACHE_TTL": "300",
"SPARQL_CACHE_MAX_SIZE": "100",
"SPARQL_CACHE_STRATEGY": "lru",
"PYTHONPATH": "/path/to/project/directory"
},
"transport": "stdio"
}
]
DefaultServer
"sparql"
MCP SPARQL Server
<div align="center">
A flexible and powerful SPARQL-enabled server for MCP (Message Carrying Protocol)
</div>
🌟 Overview
MCP SPARQL Server is a high-performance, configurable server that connects to any SPARQL endpoint and provides enhanced functionality including result formatting and caching. It's built on top of the MCP (Message Carrying Protocol) framework to provide a seamless, language-agnostic interface for querying semantic data.
✨ Features
- Universal Endpoint Support: Connect to any SPARQL-compliant endpoint
- Full SPARQL Support: Execute any valid SPARQL query (SELECT, ASK, CONSTRUCT, DESCRIBE)
- Intelligent Result Formatting:
- Standard JSON (compatible with standard SPARQL clients)
- Simplified JSON (easier to work with in applications)
- Tabular format (ready for display in UI tables)
- High-Performance Caching:
- Multiple cache strategies (LRU, LFU, FIFO)
- Configurable TTL (time-to-live)
- Cache management tools
- Flexible Deployment Options:
- Run in foreground mode
- Run as a background daemon
- Deploy as a systemd service
- Comprehensive Configuration:
- Command-line arguments
- Environment variables
- No hardcoded values
📋 Requirements
- Python 3.8 or newer
- SPARQLWrapper library
- mcp framework
- pydantic for configuration
- python-daemon for background execution
🚀 Installation
From Source
# Clone the repository
git clone https://github.com/yet-ai/mcp-server-sparql.git
cd mcp-server-sparql
Install the package
pip install -e .
From PyPI
pip install mcp-server-sparql
Using the Installation Script
For a full installation with systemd service setup:
# Download the repository
git clone https://github.com/yet-ai/mcp-server-sparql.git
cd mcp-server-sparql
Run the installation script (as root for systemd service)
sudo ./install.sh
🔍 Usage
Basic Usage
Start the server by specifying a SPARQL endpoint:
mcp-server-sparql --endpoint https://dbpedia.org/sparql
Running as a Daemon
To run the server as a background process:
mcp-server-sparql --endpoint https://dbpedia.org/sparql --daemon \
--log-file /var/log/mcp-sparql.log \
--pid-file /var/run/mcp-sparql.pid
Using with Systemd
If installed with systemd support:
1. Configure your endpoint in the environment file:
sudo nano /etc/mcp-sparql/env
2. Start the service:
sudo systemctl start sparql-server
3. Enable on boot:
sudo systemctl enable sparql-server
Client Query Examples
After starting the server, you can query it using the MCP client:
Basic Query
echo '{"query_string": "SELECT WHERE { ?s ?p ?o } LIMIT 5"}' | mcp claude
Query with Specific Format
echo '{"query_string": "SELECT WHERE { ?s ?p ?o } LIMIT 5", "format": "tabular"}' | mcp claude
Complex Query Example
echo '{
"query_string": "PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?email WHERE { ?person foaf:name ?name . OPTIONAL { ?person foaf:mbox ?email } } LIMIT 5",
"format": "simplified"
}' | mcp claude
Cache Management
# Get cache statistics
echo '{"action": "stats"}' | mcp cache
Clear the cache
echo '{"action": "clear"}' | mcp cache
⚙️ Configuration
Command-line Arguments
<table>
<thead>
<tr>
<th>Argument</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>--endpoint URL</code></td>
<td>SPARQL endpoint URL</td>
<td>Required</td>
</tr>
<tr>
<td><code>--timeout SECONDS</code></td>
<td>Request timeout in seconds</td>
<td>30</td>
</tr>
<tr>
<td><code>--format FORMAT</code></td>
<td>Result format (json, simplified, tabular)</td>
<td>json</td>
</tr>
<tr>
<td><code>--cache-enabled BOOL</code></td>
<td>Enable result caching</td>
<td>true</td>
</tr>
<tr>
<td><code>--cache-ttl SECONDS</code></td>
<td>Cache time-to-live in seconds</td>
<td>300</td>
</tr>
<tr>
<td><code>--cache-max-size SIZE</code></td>
<td>Maximum cache size</td>
<td>100</td>
</tr>
<tr>
<td><code>--cache-strategy STRATEGY</code></td>
<td>Cache replacement strategy (lru, lfu, fifo)</td>
<td>lru</td>
</tr>
<tr>
<td><code>--pretty-print</code></td>
<td>Pretty print JSON output</td>
<td>false</td>
</tr>
<tr>
<td><code>--include-metadata BOOL</code></td>
<td>Include query metadata in results</td>
<td>true</td>
</tr>
<tr>
<td><code>--daemon</code></td>
<td>Run as a background daemon</td>
<td>false</td>
</tr>
<tr>
<td><code>--log-file FILE</code></td>
<td>Log file location when running as a daemon</td>
<td>/var/log/mcp-sparql-server.log</td>
</tr>
<tr>
<td><code>--pid-file FILE</code></td>
<td>PID file location when running as a daemon</td>
<td>/var/run/mcp-sparql-server.pid</td>
</tr>
</tbody>
</table>
Environment Variables
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>SPARQL_ENDPOINT</code></td>
<td>SPARQL endpoint URL</td>
<td>None (required)</td>
</tr>
<tr>
<td><code>SPARQL_TIMEOUT</code></td>
<td>Request timeout in seconds</td>
<td>30</td>
</tr>
<tr>
<td><code>SPARQL_FORMAT</code></td>
<td>Default result format</td>
<td>json</td>
</tr>
<tr>
<td><code>SPARQL_CACHE_ENABLED</code></td>
<td>Enable caching</td>
<td>true</td>
</tr>
<tr>
<td><code>SPARQL_CACHE_TTL</code></td>
<td>Cache time-to-live in seconds</td>
<td>300</td>
</tr>
<tr>
<td><code>SPARQL_CACHE_MAX_SIZE</code></td>
<td>Maximum cache size</td>
<td>100</td>
</tr>
<tr>
<td><code>SPARQL_CACHE_STRATEGY</code></td>
<td>Cache replacement strategy</td>
<td>lru</td>
</tr>
<tr>
<td><code>SPARQL_PRETTY_PRINT</code></td>
<td>Pretty print JSON output</td>
<td>false</td>
</tr>
<tr>
<td><code>SPARQL_INCLUDE_METADATA</code></td>
<td>Include query metadata in results</td>
<td>true</td>
</tr>
</tbody>
</table>
📊 Result Formats
The server supports three different output formats:
1. JSON Format (default)
Returns the standard SPARQL JSON results format with optional metadata.
{
"head": {
"vars": ["s", "p", "o"]
},
"results": {
"bindings": [
{
"s": { "type": "uri", "value": "http://example.org/resource" },
"p": { "type": "uri", "value": "http://example.org/property" },
"o": { "type": "literal", "value": "Example Value" }
}
]
},
"metadata": {
"variables": ["s", "p", "o"],
"count": 1,
"query": "SELECT WHERE { ?s ?p ?o } LIMIT 1"
}
}
2. Simplified Format
Returns a simplified JSON structure that's easier to work with, converting variable bindings into simple key-value objects.
{
"type": "SELECT",
"results": [
{
"s": "http://example.org/resource",
"p": "http://example.org/property",
"o": "Example Value"
}
],
"metadata": {
"variables": ["s", "p", "o"],
"count": 1,
"query": "SELECT WHERE { ?s ?p ?o } LIMIT 1"
}
}
3. Tabular Format
Returns results in a tabular format with columns and rows, suitable for table display.
…
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



