Get the FREE Ultimate OpenClaw Setup Guide →

mcp -sparql

An MCP server for querying SPARQL endpoint.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ekzhu-mcp-server-sparql uvx mcp-server-sparql --endpoint https://query.wikidata.org/sparql

How to use

This MCP server provides a SPARQL querying interface for a configured SPARQL endpoint. The example uses the Wikidata SPARQL endpoint, enabling you to run SPARQL queries against a live data source via the MCP framework. The server exposes a tool named 'query' that accepts a SPARQL query string and returns results in JSON format. To use it, start the server with the uvx runner and then invoke the query tool with your SPARQL string to retrieve results.

Once running, you can send a SPARQL query to the endpoint, for example by passing a valid SELECT query to the query tool. The MCP layer handles communicating with the endpoint, performing the query, and returning the JSON results, so you don’t need to manage endpoint connections directly in your client code.

How to install

Prerequisites

  • Python 3.8+ installed on your system
  • Access to install Python packages (pip or pipx)

Installation steps

  1. Install the uvx runner (example using pipx):
pipx install uvx
  1. Verify installation:
uvx --version
  1. Create the MCP configuration file (optional but recommended to document endpoints). You can reuse the example from the README or adapt the endpoint as needed. Save as mcp-config.json (or another name you prefer).

  2. Run the MCP server using the configuration. With the provided endpoint example, you can start the server as:

uvx mcp-server-sparql --endpoint https://query.wikidata.org/sparql
  1. Interact with the server via its tools (e.g., the 'query' tool) by supplying a SPARQL string. For example:
SELECT ?item WHERE { ?item a ?type } LIMIT 10

Notes:

  • Ensure the endpoint URL is reachable from your network and supports SPARQL over HTTP/HTTPS.
  • You may need to add environment variables for authentication or quotas if your endpoint requires them.

Additional notes

Tips and common considerations:

  • Endpoint stability: Public SPARQL endpoints may rate-limit or throttle queries; plan for retry/backoff in client apps.
  • Timeout handling: SPARQL queries can be long-running; configure timeouts appropriately for production use.
  • Endpoint security: Use HTTPS endpoints when possible and avoid sending sensitive queries over unsecured networks.
  • Environment variables: If your deployment environment requires, you can pass additional options or credentials via environment variables supported by uvx or your runtime configuration.
  • Documentation: Keep the mcp-server-sparql endpoint updated in your config if the remote endpoint changes (e.g., different query URL or parameters).
  • Debugging: If queries fail, test the endpoint directly with a simple curl or a SPARQL client to isolate issues between the MCP layer and the endpoint.

Related MCP Servers

Sponsor this space

Reach thousands of developers