@comunica/mcp-sparql-link-traversal 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +22 -0
- package/README.md +229 -0
- package/bin/mcp.d.ts +2 -0
- package/bin/mcp.js +8 -0
- package/bin/mcp.js.map +1 -0
- package/package.json +61 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2026-now Ruben Taelman
|
|
4
|
+
Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Comunica MCP SPARQL Link Traversal
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/mcp-sparql-link-traversal)
|
|
4
|
+
|
|
5
|
+
Comunica MCP SPARQL Link Traversal is an [MCP server](https://modelcontextprotocol.io/) for allowing AI agents to execute SPARQL queries with link traversal capabilities over decentralized RDF knowledge graphs on the Web.
|
|
6
|
+
|
|
7
|
+
Link traversal enables querying over interconnected Linked Data by following links between resources during query execution, allowing for dynamic discovery and querying of data across the Web.
|
|
8
|
+
|
|
9
|
+
It's main distinguishing features are the following:
|
|
10
|
+
|
|
11
|
+
* Improves the accuracy of your AI agent's answers by leveraging the power of SPARQL and Knowledge Graphs.
|
|
12
|
+
* Execute [SPARQL 1.2](https://www.w3.org/TR/sparql12-query/) queries with automatic link traversal.
|
|
13
|
+
* Dynamically discover and query linked data across the Web.
|
|
14
|
+
* Follow RDF links during query execution to find relevant data.
|
|
15
|
+
* Query over distributed knowledge graphs without prior knowledge of all sources.
|
|
16
|
+
|
|
17
|
+
**[Learn more about Comunica on our website](https://comunica.dev/).**
|
|
18
|
+
|
|
19
|
+
_Internally, this is a [Comunica module](https://comunica.dev/) that is configured with modules to execute SPARQL queries with link traversal through MCP._
|
|
20
|
+
|
|
21
|
+
## Supported by
|
|
22
|
+
|
|
23
|
+
Comunica is a community-driven project, sustained by the [Comunica Association](https://comunica.dev/association/).
|
|
24
|
+
If 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.
|
|
25
|
+
|
|
26
|
+
Our top sponsors are shown below!
|
|
27
|
+
|
|
28
|
+
<a href="https://opencollective.com/comunica-association/sponsor/0/website" target="_blank"><img src="https://opencollective.com/comunica-association/sponsor/0/avatar.svg"></a>
|
|
29
|
+
<a href="https://opencollective.com/comunica-association/sponsor/1/website" target="_blank"><img src="https://opencollective.com/comunica-association/sponsor/1/avatar.svg"></a>
|
|
30
|
+
<a href="https://opencollective.com/comunica-association/sponsor/2/website" target="_blank"><img src="https://opencollective.com/comunica-association/sponsor/2/avatar.svg"></a>
|
|
31
|
+
<a href="https://opencollective.com/comunica-association/sponsor/3/website" target="_blank"><img src="https://opencollective.com/comunica-association/sponsor/3/avatar.svg"></a>
|
|
32
|
+
|
|
33
|
+
## Usage examples
|
|
34
|
+
|
|
35
|
+
After connecting this MCP server to your AI agent (see some examples on how to do this below),
|
|
36
|
+
your agent can SPARQL query any Knowledge Graph that is accessible to you with automatic link traversal.
|
|
37
|
+
|
|
38
|
+
For example, use it to ask:
|
|
39
|
+
|
|
40
|
+
> Use Comunica SPARQL Link Traversal to find information about a person starting from their homepage URL.
|
|
41
|
+
|
|
42
|
+
The query engine will automatically follow links to discover related data across multiple sources.
|
|
43
|
+
|
|
44
|
+
### Prompt suggestions
|
|
45
|
+
|
|
46
|
+
If you want your agent to always use SPARQL for higher accuracy in answers, you can tell it the following:
|
|
47
|
+
|
|
48
|
+
> When looking up data, always prefer looking them up over Knowledge Graphs via SPARQL with link traversal, as this enables dynamic discovery of data.
|
|
49
|
+
> Link traversal allows queries to follow links between resources to find relevant data without knowing all sources upfront.
|
|
50
|
+
> Since SPARQL queries with link traversal 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.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Comunica requires [Node.JS](http://nodejs.org/) 14.0 or higher and is tested on OSX and Linux.
|
|
55
|
+
|
|
56
|
+
The easiest way to install the client is by installing it from NPM as follows:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
$ [sudo] npm install -g @comunica/mcp-sparql-link-traversal
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Alternatively, you can install from the latest GitHub sources.
|
|
63
|
+
For this, please refer to the README of the [Comunica monorepo](https://github.com/comunica/comunica).
|
|
64
|
+
If you do so, the following examples require replacing `comunica-mcp-sparql-link-traversal` with `node engines/mcp-sparql-link-traversal/bin/mcp.js`.
|
|
65
|
+
|
|
66
|
+
## Connect this MCP server to your agent
|
|
67
|
+
|
|
68
|
+
Below, a non-exhaustive list of examples is given to connect this MCP server to your agent.
|
|
69
|
+
|
|
70
|
+
### Claude Desktop
|
|
71
|
+
|
|
72
|
+
After installing, you can run the MCP server in two modes:
|
|
73
|
+
|
|
74
|
+
#### Stdio Mode (Recommended for Claude Desktop)
|
|
75
|
+
|
|
76
|
+
With stdio mode, the MCP server communicates directly via standard input/output, which is simpler and doesn't require a network port.
|
|
77
|
+
|
|
78
|
+
Add the following entry to your `claude_desktop_config.json` file (can be found via Settings / Developer / Edit Config):
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"comunica-sparql-link-traversal": {
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": [
|
|
86
|
+
"-y",
|
|
87
|
+
"@comunica/mcp-sparql-link-traversal",
|
|
88
|
+
"--mode",
|
|
89
|
+
"stdio"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### HTTP Mode
|
|
97
|
+
|
|
98
|
+
Alternatively, you can run the MCP server in HTTP mode, which requires starting the server manually first:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
$ comunica-mcp-sparql-link-traversal --mode http --port 3123
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Then, add the following entry to your `claude_desktop_config.json`:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"mcpServers": {
|
|
109
|
+
"comunica-sparql-link-traversal": {
|
|
110
|
+
"command": "npx",
|
|
111
|
+
"args": [
|
|
112
|
+
"-y",
|
|
113
|
+
"mcp-remote",
|
|
114
|
+
"http://localhost:3123/mcp",
|
|
115
|
+
"--allow-http"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then, you can ask Claude something like the following:
|
|
123
|
+
|
|
124
|
+
> Use Comunica SPARQL Link Traversal to find information about Tim Berners-Lee starting from his homepage.
|
|
125
|
+
|
|
126
|
+
#### Default Sources
|
|
127
|
+
|
|
128
|
+
You can optionally configure default starting points 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 as starting points for link traversal.
|
|
129
|
+
|
|
130
|
+
**Stdio Mode with Default Sources:**
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"comunica-sparql-link-traversal": {
|
|
136
|
+
"command": "npx",
|
|
137
|
+
"args": [
|
|
138
|
+
"-y",
|
|
139
|
+
"@comunica/mcp-sparql-link-traversal",
|
|
140
|
+
"--mode",
|
|
141
|
+
"stdio",
|
|
142
|
+
"https://example.org/person/alice"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**HTTP Mode with Default Sources:**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
$ comunica-mcp-sparql-link-traversal --mode http --port 3123 https://example.org/person/alice
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Claude Code
|
|
156
|
+
|
|
157
|
+
#### Stdio Mode (Recommended for Claude Code)
|
|
158
|
+
|
|
159
|
+
With stdio mode, the MCP server communicates directly via standard input/output, which is simpler and doesn't require a network port.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
claude mcp add --transport stdio sparql-link-traversal -- npx -y @comunica/mcp-sparql-link-traversal --mode stdio
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Learn more in the [Claude Code MCP docs](https://code.claude.com/docs/en/mcp),
|
|
166
|
+
such as for running this on Windows.
|
|
167
|
+
|
|
168
|
+
#### HTTP Mode
|
|
169
|
+
|
|
170
|
+
Alternatively, you can run the MCP server in HTTP mode, which requires starting the server manually first:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
$ comunica-mcp-sparql-link-traversal --mode http --port 3123
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
claude mcp add --transport http sparql-link-traversal http://localhost:3123/mcp
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### ChatGPT
|
|
181
|
+
|
|
182
|
+
At the time of writing, ChatGPT only supports HTTP-based MCP servers.
|
|
183
|
+
So you'll need to run this tool under HTTP mode and expose it to the public Web,
|
|
184
|
+
possibly combined with a reverse proxy and/or OAuth layer.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
$ comunica-mcp-sparql-link-traversal --mode http --port 3123
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Available Tools
|
|
191
|
+
|
|
192
|
+
This MCP server provides the following tools:
|
|
193
|
+
|
|
194
|
+
### query_sparql
|
|
195
|
+
|
|
196
|
+
Execute SPARQL queries with link traversal over one or more starting sources, which also includes update queries.
|
|
197
|
+
|
|
198
|
+
**Parameters:**
|
|
199
|
+
- `query` (required): SPARQL query string
|
|
200
|
+
- `sources` (required, unless default sources are configured): List of starting point URLs for link traversal
|
|
201
|
+
- `queryFormatLanguage` (optional): Query language (e.g., `sparql`, `graphql`). Allows you to specify alternative query languages supported by Comunica
|
|
202
|
+
- `queryFormatVersion` (optional): Query language version (e.g., `1.0`, `1.1`, `1.2`). Specifies the version of the query language to use
|
|
203
|
+
- `baseIRI` (optional): Base IRI for resolving relative IRIs in the query
|
|
204
|
+
- `httpProxy` (optional): HTTP proxy URL (e.g., `http://proxy.example.com:8080`)
|
|
205
|
+
- `httpAuth` (optional): HTTP basic authentication in the format `username:password`
|
|
206
|
+
- `httpTimeout` (optional): HTTP request timeout in milliseconds
|
|
207
|
+
- `httpRetryCount` (optional): Number of HTTP request retries on failure
|
|
208
|
+
|
|
209
|
+
**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.
|
|
210
|
+
|
|
211
|
+
### query_sparql_rdf
|
|
212
|
+
|
|
213
|
+
Execute SPARQL queries over a serialized RDF dataset provided as a string (useful for querying Turtle, N-Triples, or other RDF formats directly).
|
|
214
|
+
|
|
215
|
+
**Parameters:**
|
|
216
|
+
- `query` (required): SPARQL query string
|
|
217
|
+
- `value` (required): Serialized RDF dataset as a string
|
|
218
|
+
- `mediaType` (required): Media type of the serialized RDF dataset (e.g., `text/turtle`, `application/n-triples`, `application/ld+json`)
|
|
219
|
+
- `fileBaseIRI` (optional): Base IRI for resolving relative IRIs in the RDF dataset
|
|
220
|
+
- `baseIRI` (optional): Base IRI for resolving relative IRIs in the query
|
|
221
|
+
- `queryFormatLanguage` (optional): Query language (e.g., `sparql`, `graphql`). Allows you to specify alternative query languages supported by Comunica
|
|
222
|
+
- `queryFormatVersion` (optional): Query language version (e.g., `1.0`, `1.1`, `1.2`). Specifies the version of the query language to use
|
|
223
|
+
|
|
224
|
+
## Learn more
|
|
225
|
+
|
|
226
|
+
This README just shows the tip of the iceberg!
|
|
227
|
+
Learn more about Comunica's functionalities in the following guides:
|
|
228
|
+
|
|
229
|
+
* _[*Full documentation*](https://comunica.dev/docs/)_
|
package/bin/mcp.d.ts
ADDED
package/bin/mcp.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const query_sparql_link_traversal_1 = require("@comunica/query-sparql-link-traversal");
|
|
5
|
+
const utils_mcp_1 = require("@comunica/utils-mcp");
|
|
6
|
+
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions
|
|
7
|
+
(0, utils_mcp_1.runCli)(new query_sparql_link_traversal_1.QueryEngine(), require('../package.json').version);
|
|
8
|
+
//# sourceMappingURL=mcp.js.map
|
package/bin/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["mcp.ts"],"names":[],"mappings":";;;AACA,uFAAoE;AACpE,mDAA6C;AAE7C,sFAAsF;AACtF,IAAA,kBAAM,EAAC,IAAI,yCAAW,EAAE,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { QueryEngine } from '@comunica/query-sparql-link-traversal';\nimport { runCli } from '@comunica/utils-mcp';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions\nrunCli(new QueryEngine(), require('../package.json').version);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/mcp-sparql-link-traversal",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "An MCP server for executing SPARQL queries with link traversal capabilities",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"funding": {
|
|
7
|
+
"type": "opencollective",
|
|
8
|
+
"url": "https://opencollective.com/comunica-association"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://comunica.dev/",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/comunica/comunica-feature-mcp.git",
|
|
14
|
+
"directory": "engines/mcp-sparql-link-traversal"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/comunica/comunica-feature-mcp/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"agentic",
|
|
22
|
+
"comunica",
|
|
23
|
+
"sparql",
|
|
24
|
+
"link-traversal",
|
|
25
|
+
"linked-data",
|
|
26
|
+
"engine",
|
|
27
|
+
"query",
|
|
28
|
+
"update",
|
|
29
|
+
"sparql engine",
|
|
30
|
+
"sparql query",
|
|
31
|
+
"sparql update",
|
|
32
|
+
"sparql 1.1",
|
|
33
|
+
"sparql 1.2"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"main": "lib/index.js",
|
|
37
|
+
"typings": "lib/index",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"bin": {
|
|
42
|
+
"comunica-mcp-sparql-link-traversal": "bin/mcp.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"bin/**/*.d.ts",
|
|
46
|
+
"bin/**/*.js",
|
|
47
|
+
"bin/**/*.js.map",
|
|
48
|
+
"lib/**/*.d.ts",
|
|
49
|
+
"lib/**/*.js",
|
|
50
|
+
"lib/**/*.js.map"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "yarn run build:ts",
|
|
54
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\""
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@comunica/query-sparql-link-traversal": "^0.8.0",
|
|
58
|
+
"@comunica/utils-mcp": "^1.0.0"
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "8a35a73d61cf1066bb1181761884d84d3b932932"
|
|
61
|
+
}
|