{"_id":"@comunica/mcp-sparql","_rev":"2-4af2d36812e13857d628e4ebda136f5e","name":"@comunica/mcp-sparql","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@comunica/mcp-sparql","version":"1.0.0","keywords":["mcp","agentic","comunica","sparql","engine","query","update","sparql engine","sparql query","sparql update","sparql 1.1","sparql 1.2"],"license":"MIT","_id":"@comunica/mcp-sparql@1.0.0","maintainers":[{"name":"joachimvh","email":"joachimvh@gmail.com"},{"name":"rubensworks","email":"rubensworks@gmail.com"},{"name":"rubenverborgh","email":"ruben@verborgh.org"},{"name":"dexagod","email":"dedecker.ruben@gmail.com"},{"name":"jeswr","email":"jmwright.045@gmail.com"}],"homepage":"https://comunica.dev/","bugs":{"url":"https://github.com/comunica/comunica-feature-mcp/issues"},"bin":{"comunica-mcp-sparql":"bin/mcp.js"},"dist":{"shasum":"dae10f78c726a1e161361eae73efcf2535283f54","tarball":"https://registry.npmjs.org/@comunica/mcp-sparql/-/mcp-sparql-1.0.0.tgz","fileCount":6,"integrity":"sha512-zkeYnmk7/vfD/7x5ZX7Zubl7wAIlJelrL88AfQEM+7c1VuLkP1GqAv8ZUq5yX98xozOPvlE56hrY8MKszLpOrg==","signatures":[{"sig":"MEUCIBE8HZOCTz5VycdWxltUe5+bMkAeO3s7htspIW5c6J7HAiEA36tSd2egW572jpr4fP+wZjxA7RwFbdWmRYmAWfBohWU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14713},"main":"lib/index.js","funding":{"url":"https://opencollective.com/comunica-association","type":"opencollective"},"gitHead":"8a35a73d61cf1066bb1181761884d84d3b932932","scripts":{"build":"yarn run build:ts","build:ts":"node \"../../node_modules/typescript/bin/tsc\""},"typings":"lib/index","_npmUser":{"name":"rubensworks","email":"rubensworks@gmail.com"},"repository":{"url":"git+https://github.com/comunica/comunica-feature-mcp.git","type":"git","directory":"engines/mcp-sparql"},"_npmVersion":"lerna/9.0.3/node@v22.14.0+arm64 (darwin)","description":"An MCP server for executing SPARQL queries over decentralized RDF knowledge graphs on the Web","directories":{},"sideEffects":false,"_nodeVersion":"22.14.0","dependencies":{"@comunica/utils-mcp":"^1.0.0","@comunica/query-sparql":"^5.1.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mcp-sparql_1.0.0_1770818639117_0.9120828352886097","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"_id":"@comunica/mcp-sparql@1.1.0","bin":{"comunica-mcp-sparql":"bin/mcp.js"},"bugs":{"url":"https://github.com/comunica/comunica-feature-mcp/issues"},"dist":{"shasum":"c0db23aa5707d2e2a1255d008548e3a9c67297bc","tarball":"https://registry.npmjs.org/@comunica/mcp-sparql/-/mcp-sparql-1.1.0.tgz","fileCount":6,"integrity":"sha512-W9RL0Xhu2E1uqnuZEmVCfsUhITsAqfGIxQOr3/GZQ+VhNHqkwtF8/MfkBh6dKxQI/rPcX/jKsuNHb4mmW3WGKw==","signatures":[{"sig":"MEYCIQC3J1yrhXPut1nvSMCNJFWzvbeDG788R1ziKXOyXaa1YwIhAI3jmazALROcyGFxirA/g9PSJThPw4WGbZd9pGDTBV9b","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHIuIpu/0RaGko93+SgNRfUJ/qjU2VzDHYkjopaCkDrlAiEApIeyHgInU5uhtzYO/p6dc3iy65FORDho9g36dQWrWnM="}],"unpackedSize":16194},"main":"lib/index.js","name":"@comunica/mcp-sparql","funding":{"url":"https://opencollective.com/comunica-association","type":"opencollective"},"gitHead":"4d3c6e5233ec89ceeb45bd2a478652e7f74d5cd2","license":"MIT","scripts":{"build":"yarn run build:ts","build:ts":"node \"../../node_modules/typescript/bin/tsc\""},"typings":"lib/index","version":"1.1.0","_npmUser":{"name":"rubensworks","email":"rubensworks@gmail.com"},"homepage":"https://comunica.dev/","keywords":["mcp","agentic","comunica","sparql","engine","query","update","sparql engine","sparql query","sparql update","sparql 1.1","sparql 1.2"],"repository":{"url":"git+https://github.com/comunica/comunica-feature-mcp.git","type":"git","directory":"engines/mcp-sparql"},"_npmVersion":"lerna/9.0.7/node@v22.23.2+arm64 (darwin)","description":"An MCP server for executing SPARQL queries over decentralized RDF knowledge graphs on the Web","directories":{},"maintainers":[{"name":"joachimvh","email":"joachimvh@gmail.com"},{"name":"rubensworks","email":"rubensworks@gmail.com"},{"name":"rubenverborgh","email":"ruben@verborgh.org"},{"name":"dexagod","email":"dedecker.ruben@gmail.com"},{"name":"jeswr","email":"jmwright.045@gmail.com"}],"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@comunica/utils-mcp":"^1.1.0","@comunica/query-sparql":"^5.1.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-sparql_1.1.0_1788267715019_0.6859437541699764"}}},"time":{"created":"2026-02-11T14:03:59.010Z","modified":"2026-09-01T13:01:55.310Z","1.0.0":"2026-02-11T14:03:59.264Z","1.1.0":"2026-09-01T13:01:55.116Z"},"bugs":{"url":"https://github.com/comunica/comunica-feature-mcp/issues"},"license":"MIT","homepage":"https://comunica.dev/","keywords":["mcp","agentic","comunica","sparql","engine","query","update","sparql engine","sparql query","sparql update","sparql 1.1","sparql 1.2"],"repository":{"url":"git+https://github.com/comunica/comunica-feature-mcp.git","type":"git","directory":"engines/mcp-sparql"},"description":"An MCP server for executing SPARQL queries over decentralized RDF knowledge graphs on the Web","maintainers":[{"name":"joachimvh","email":"joachimvh@gmail.com"},{"name":"rubensworks","email":"rubensworks@gmail.com"},{"name":"rubenverborgh","email":"ruben@verborgh.org"},{"name":"dexagod","email":"dedecker.ruben@gmail.com"},{"name":"jeswr","email":"jmwright.045@gmail.com"}],"readme":"# Comunica MCP SPARQL\n\n[![npm version](https://badge.fury.io/js/%40comunica%2Fmcp-sparql.svg)](https://www.npmjs.com/package/@comunica/mcp-sparql)\n\nComunica MCP SPARQL is an [MCP server](https://modelcontextprotocol.io/) for allowing AI agents to execute SPARQL queries over decentralized RDF knowledge graphs on the Web.\n\nIt's main distinguishing features are the following:\n\n* Improves the accuracy of your AI agent's answers by leveraging the power of SPARQL and Knowledge Graphs.\n* Execute [SPARQL 1.2](https://www.w3.org/TR/sparql12-query/) queries over one or more knowledge graphs on the Web.\n* Agents can pass one or more Knowledge Graph URLs together with the SPARQL query, making it not hard-coupled to one specific Knowledge Graph.\n* Federated querying over [heterogeneous interfaces](https://comunica.dev/docs/query/advanced/source_types/), such as RDF Linked Data files, [SPARQL endpoints](https://www.w3.org/TR/sparql12-protocol/), [Triple Pattern Fragments](https://linkeddatafragments.org/), or [Solid data pods](https://solidproject.org/).\n* Easy to set up, and connects to public or private/internal Knowledge Graphs.\n\n**[Learn more about Comunica on our website](https://comunica.dev/).**\n\n_Internally, this is a [Comunica module](https://comunica.dev/) that is configured with modules to execute SPARQL queries through MCP._\n\n## Supported by\n\nComunica is a community-driven project, sustained by the [Comunica Association](https://comunica.dev/association/).\nIf you are using Comunica, [becoming a sponsor or member](https://opencollective.com/comunica-association) is a way to make Comunica sustainable in the long-term.\n\nOur top sponsors are shown below!\n\n<a href=\"https://opencollective.com/comunica-association/sponsor/0/website\" target=\"_blank\"><img src=\"https://opencollective.com/comunica-association/sponsor/0/avatar.svg\"></a>\n<a href=\"https://opencollective.com/comunica-association/sponsor/1/website\" target=\"_blank\"><img src=\"https://opencollective.com/comunica-association/sponsor/1/avatar.svg\"></a>\n<a href=\"https://opencollective.com/comunica-association/sponsor/2/website\" target=\"_blank\"><img src=\"https://opencollective.com/comunica-association/sponsor/2/avatar.svg\"></a>\n<a href=\"https://opencollective.com/comunica-association/sponsor/3/website\" target=\"_blank\"><img src=\"https://opencollective.com/comunica-association/sponsor/3/avatar.svg\"></a>\n\n## Usage examples\n\nAfter connecting this MCP server to your AI agent (see some examples on how to do this below),\nyour agent can SPARQL query any Knowledge Graph that is accessible to you.\n\nFor example, use it to ask:\n\n> Use Comunica SPARQL to determine what movies both Brad Pitt and Leonardo DiCaprio both play in.\n\nThis will produce two movies: Once Upon a Time in Hollywood and The Audition.\nWithout SPARQL, the answer on Claude Desktop (Sonnet 4.5) is incomplete, as only a single movie is returned.\n\n### Prompt suggestions\n\nIf you want your agent to always use SPARQL for higher accuracy in answers, you can tell it the following:\n\n> When looking up data, always prefer looking them up over Knowledge Graphs via SPARQL, as this is more precise.\n> If data needs to be combined from multiple Knowledge Graphs, do so using a virtually integrated SPARQL query towards multiple URLs pointing to Knowledge Graphs.\n> You are responsible for selecting relevant sources for the SPARQL query, for which you can consider SPARQL endpoints, TPF interfaces, and Linked Data (in any RDF serialization).\n> Also take into account that many websites contain RDF data. So if you need to lookup data about something, and you know the relevant website(s), try querying those websites using SPARQL.\n> Since SPARQL queries can take a while to execute, start producing an approximate answer yourself and show it to me if the SPARQL query takes more than 1 second, but then make the answer more concrete based on the SPARQL query once it finalized, as it will be more accurate.\n> Since you will probably query over Wikidata and DBpedia often, prefer authoritative Knowledge Graphs for domain-specific data if they exist.\n\nAfter this, SPARQL will be used for questions such as:\n\n- \"What is the time zone of Salt Lake City?\"\n- \"What movies do both Brad Pitt and Leonardo DiCaprio play in?\"\n- \"What are the largest cities in Canada?\"\n- \"Give me Ruben Taelman's main interests.\"\n- \"What are some proteins associated with Alzheimer's disease, according to a protein knowledge graph?\"\n- \"What are the 10 longest streets in Belgium?\"\n\n### Limitations\n\nMost models seem to prefer Wikidata and DBpedia for most questions.\nIf you want it to query another Knowledge Graph, you need to be explicit.\nWhen performing federated queries, endpoint URLs passed to the MCP server are not always accurate.\n\n## Installation\n\nComunica requires [Node.JS](http://nodejs.org/) 14.0 or higher and is tested on OSX and Linux.\n\nThe easiest way to install the client is by installing it from NPM as follows:\n\n```bash\n$ [sudo] npm install -g @comunica/mcp-sparql\n```\n\nAlternatively, you can install from the latest GitHub sources.\nFor this, please refer to the README of the [Comunica monorepo](https://github.com/comunica/comunica).\nIf you do so, the following examples require replacing `comunica-mcp-sparql` with `node engines/mcp-sparql/bin/mcp.js`.\n\n## Connect this MCP server to your agent\n\nBelow, a non-exhaustive list of examples is given to connect this MCP server to your agent.\n\n### Claude Desktop\n\nAfter installing, you can run the MCP server in two modes:\n\n#### Stdio Mode (Recommended for Claude Desktop)\n\nWith stdio mode, the MCP server communicates directly via standard input/output, which is simpler and doesn't require a network port.\n\nAdd the following entry to your `claude_desktop_config.json` file (can be found via Settings / Developer / Edit Config):\n\n```json\n{\n  \"mcpServers\": {\n    \"comunica-sparql\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"@comunica/mcp-sparql\",\n        \"--mode\",\n        \"stdio\"\n      ]\n    }\n  }\n}\n```\n\n#### HTTP Mode\n\nAlternatively, you can run the MCP server in HTTP mode, which requires starting the server manually first:\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123\n```\n\nThen, add the following entry to your `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"comunica-sparql\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote\",\n        \"http://localhost:3123/mcp\",\n        \"--allow-http\"\n      ]\n    }\n  }\n}\n```\n\nThen, you can ask Claude something like the following:\n\n> Use Comunica SPARQL to determine what movies both Brad Pitt and Leonardo DiCaprio both play in.\n\n#### Default Sources\n\nYou can optionally configure default sources when starting the MCP server. When default sources are provided, the `sources` parameter is hidden from the tools, and all queries automatically use the configured sources.\n\nThis is useful when you want to restrict queries to specific Knowledge Graphs or avoid having the AI agent select sources on its own.\n\n**Stdio Mode with Default Sources:**\n\n```json\n{\n  \"mcpServers\": {\n    \"comunica-sparql\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"@comunica/mcp-sparql\",\n        \"--mode\",\n        \"stdio\",\n        \"https://dbpedia.org/sparql\",\n        \"https://query.wikidata.org/sparql\"\n      ]\n    }\n  }\n}\n```\n\n**HTTP Mode with Default Sources:**\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123 https://dbpedia.org/sparql https://query.wikidata.org/sparql\n```\n\n**Source Type Prefixes:**\n\nYou can optionally force a source type by prefixing the URL with a type annotation, following the same syntax as the [Comunica CLI](https://comunica.dev/docs/query/getting_started/query_cli/):\n\n```bash\n$ comunica-mcp-sparql --mode stdio sparql@https://dbpedia.org/sparql file@/path/to/data.ttl hypermedia@https://fragments.dbpedia.org/2016-04/en\n```\n\nThis is useful when the source type is already known to avoid auto-detection overhead.\n\n### Claude Code\n\n#### Stdio Mode (Recommended for Claude Code)\n\nWith stdio mode, the MCP server communicates directly via standard input/output, which is simpler and doesn't require a network port.\n\n```bash\nclaude mcp add --transport stdio sparql -- npx -y @comunica/mcp-sparql --mode stdio\n```\n\nLearn more in the [Claude Code MCP docs](https://code.claude.com/docs/en/mcp),\nsuch as for running this on Windows.\n\n#### HTTP Mode\n\nAlternatively, you can run the MCP server in HTTP mode, which requires starting the server manually first:\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123\n```\n\n```bash\nclaude mcp add --transport http sparql http://localhost:3123/mcp\n```\n\n### ChatGPT\n\nAt the time of writing, ChatGPT only supports HTTP-based MCP servers.\nSo you'll need to run this tool under HTTP mode and expose it to the public Web,\npossibly combined with a reverse proxy and/or OAuth layer.\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123\n```\n\n## Query timeouts\n\nSPARQL queries can take arbitrarily long, for example when they are executed over large or slow sources.\nTo make sure that an agent never waits indefinitely, queries are aborted after `--timeout` milliseconds\n(60 seconds by default, `--timeout 0` disables this), after which the agent receives an error\nthat invites it to refine its query.\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123 --timeout 300000\n```\n\nComunica offers no way to abort a query that is already running,\nso a timed out query would keep consuming CPU and memory in the background.\nIn http mode, queries are therefore executed inside worker processes that are supervised by a primary process,\nwhich allows such workers to be replaced by a fresh one after a timeout.\nThis also makes the server recover from queries that block the event loop entirely,\nwhich would otherwise make the server unreachable forever.\n\nThe number of workers can be configured with `--workers`, which also determines\nhow many queries can be executed concurrently:\n\n```bash\n$ comunica-mcp-sparql --mode http --port 3123 --workers 4\n```\n\nIn stdio mode, the server always runs as a single process, since worker processes can not share a single\nstandard input stream, and replacing a worker would invalidate the MCP session of the connected client.\nQueries are still aborted after `--timeout` milliseconds there, but their resources are only reclaimed\nonce the query terminates by itself.\n\n## Available Tools\n\nThis MCP server provides the following tools:\n\n### query_sparql\n\nExecute SPARQL queries over one or more remote sources (SPARQL endpoints, TPF interfaces, or RDF files), which also includes update queries.\n\n**Parameters:**\n- `query` (required): SPARQL query string\n- `sources` (required, unless default sources are configured): List of SPARQL endpoint URLs, TPF interface URLs, or Linked Data (RDF) file paths\n- `queryFormatLanguage` (optional): Query language (e.g., `sparql`, `graphql`). Allows you to specify alternative query languages supported by Comunica\n- `queryFormatVersion` (optional): Query language version (e.g., `1.0`, `1.1`, `1.2`). Specifies the version of the query language to use\n- `baseIRI` (optional): Base IRI for resolving relative IRIs in the query\n- `httpProxy` (optional): HTTP proxy URL (e.g., `http://proxy.example.com:8080`)\n- `httpAuth` (optional): HTTP basic authentication in the format `username:password`\n- `httpTimeout` (optional): HTTP request timeout in milliseconds\n- `httpRetryCount` (optional): Number of HTTP request retries on failure\n\n**Note:** When the MCP server is started with default sources, the `sources` parameter is not available, and all queries automatically use the configured default sources.\n\n### query_sparql_rdf\n\nExecute SPARQL queries over a serialized RDF dataset provided as a string (useful for querying Turtle, N-Triples, or other RDF formats directly).\n\n**Parameters:**\n- `query` (required): SPARQL query string\n- `value` (required): Serialized RDF dataset as a string\n- `mediaType` (required): Media type of the serialized RDF dataset (e.g., `text/turtle`, `application/n-triples`, `application/ld+json`)\n- `fileBaseIRI` (optional): Base IRI for resolving relative IRIs in the RDF dataset\n- `baseIRI` (optional): Base IRI for resolving relative IRIs in the query\n- `queryFormatLanguage` (optional): Query language (e.g., `sparql`, `graphql`). Allows you to specify alternative query languages supported by Comunica\n- `queryFormatVersion` (optional): Query language version (e.g., `1.0`, `1.1`, `1.2`). Specifies the version of the query language to use\n\n## Learn more\n\nThis README just shows the tip of the iceberg!\nLearn more about Comunica's functionalities in the following guides:\n\n* _[*Full documentation*](https://comunica.dev/docs/)_\n","readmeFilename":"README.md"}