Skip to main content

MCP server exposing SPARQL query functionalities for LLMs

Project description

mcp-sparql — MCP server exposing SPARQL query functionalities for LLMs.

PyPI Python Ruff

mcp-name: io.github.daedalus/mcp-sparql

Install

pip install mcp-sparql

Usage

As an MCP Server

Add to your MCP configuration (e.g., ~/.config/claude/mcp.json):

{
  "mcpServers": {
    "mcp-sparql": {
      "command": "mcp-sparql"
    }
  }
}

Available Tools

Tool Description
sparql_query Execute SPARQL SELECT queries (table or JSON output)
sparql_ask Execute SPARQL ASK queries (boolean result)
sparql_construct Execute SPARQL CONSTRUCT queries (Turtle or JSON-LD)
sparql_describe Execute SPARQL DESCRIBE queries (Turtle or JSON-LD)
sparql_validate Validate SPARQL query syntax without executing
sparql_list_graphs List named graphs on a SPARQL endpoint
sparql_get_prefixes Get common prefixes for a SPARQL endpoint

Examples

Query Wikidata:

sparql_query:
  endpoint: "https://query.wikidata.org/sparql"
  query: "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5 . ?item rdfs:label ?itemLabel . FILTER(LANG(?itemLabel) = 'en') } LIMIT 5"

Check if an entity exists:

sparql_ask:
  endpoint: "https://query.wikidata.org/sparql"
  query: "ASK { wd:Q42 wdt:P31 wd:Q5 }"

Validate a query:

sparql_validate:
  query: "SELECT ?s WHERE { ?s ?p ?o }"

List named graphs:

sparql_list_graphs:
  endpoint: "https://query.wikidata.org/sparql"

Get common prefixes:

sparql_get_prefixes:
  endpoint: "https://query.wikidata.org/sparql"

Resources

Resource URI Description
Common Prefixes sparql://common-prefixes Standard SPARQL namespace prefixes

API

sparql_query

Execute a SPARQL SELECT query.

Parameters:

  • endpoint (str): SPARQL endpoint URL
  • query (str): SPARQL SELECT query
  • timeout (int, default=30): Query timeout in seconds
  • output_format (str, default="table"): "table" for Markdown, "json" for JSON
  • headers (dict, optional): HTTP headers for authentication
  • max_rows (int, default=1000): Maximum result rows

sparql_ask

Execute a SPARQL ASK query. Returns "true" or "false".

sparql_construct

Execute a SPARQL CONSTRUCT query. Returns RDF triples.

Additional parameters:

  • output_format (str, default="turtle"): "turtle" or "json"

sparql_describe

Execute a SPARQL DESCRIBE query. Returns RDF description.

sparql_validate

Validate SPARQL query syntax without executing.

sparql_list_graphs

List available named graphs on a SPARQL endpoint.

sparql_get_prefixes

Get commonly used prefixes for a SPARQL endpoint.

Development

git clone https://github.com/daedalus/mcp-sparql.git
cd mcp-sparql
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint + type check
prospector --with-tool ruff --with-tool mypy --with-tool pylint src/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_sparql-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_sparql-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_sparql-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_sparql-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_sparql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 844fc3bb32154672dabb4dca3e83cb280f19d07bef5a9fdcca500e5a340d55a9
MD5 b23444da6d17f78f60acc8fe3ac9d070
BLAKE2b-256 301d5a09fefe7e649bb21ca67f7f47aafba9dc45c02583c771d81d93ae43365c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_sparql-0.1.0.tar.gz:

Publisher: pypi-publish.yml on daedalus/mcp-sparql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_sparql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_sparql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_sparql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e216f303285dc5f07f15313aa955ef9f12cb08dc51cd73247a205e9ddef39f35
MD5 05844b286da2245b7f51f1a0270e523b
BLAKE2b-256 8d26dbbc42b56a24a3718e03a05fcacd806d1255ecea0ec1a522bb9cc5f5f2df

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_sparql-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/mcp-sparql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page