@comunica/mcp-sparql-hdt 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 +60 -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 HDT
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/mcp-sparql-hdt)
|
|
4
|
+
|
|
5
|
+
Comunica MCP SPARQL HDT is an [MCP server](https://modelcontextprotocol.io/) for allowing AI agents to execute SPARQL queries over [HDT files](https://www.rdfhdt.org/).
|
|
6
|
+
|
|
7
|
+
HDT (Header-Dictionary-Triples) is a binary RDF serialization format that enables efficient querying of large RDF datasets with low memory consumption.
|
|
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 over HDT files.
|
|
13
|
+
* Memory-efficient querying of large RDF datasets.
|
|
14
|
+
* Fast query execution over compressed HDT files.
|
|
15
|
+
* Supports local HDT files and remote HDT endpoints.
|
|
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 over HDT files 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 HDT file that is accessible to you.
|
|
37
|
+
|
|
38
|
+
For example, use it to ask:
|
|
39
|
+
|
|
40
|
+
> Use Comunica SPARQL HDT to query the DBpedia HDT file and find all movies directed by Christopher Nolan.
|
|
41
|
+
|
|
42
|
+
### Prompt suggestions
|
|
43
|
+
|
|
44
|
+
If you want your agent to always use SPARQL for higher accuracy in answers, you can tell it the following:
|
|
45
|
+
|
|
46
|
+
> When looking up data, always prefer looking them up over Knowledge Graphs via SPARQL, as this is more precise.
|
|
47
|
+
> For large RDF datasets, HDT files provide efficient querying capabilities.
|
|
48
|
+
> 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.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Comunica requires [Node.JS](http://nodejs.org/) 14.0 or higher and is tested on OSX and Linux.
|
|
53
|
+
|
|
54
|
+
The easiest way to install the client is by installing it from NPM as follows:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
$ [sudo] npm install -g @comunica/mcp-sparql-hdt
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Alternatively, you can install from the latest GitHub sources.
|
|
61
|
+
For this, please refer to the README of the [Comunica monorepo](https://github.com/comunica/comunica).
|
|
62
|
+
If you do so, the following examples require replacing `comunica-mcp-sparql-hdt` with `node engines/mcp-sparql-hdt/bin/mcp.js`.
|
|
63
|
+
|
|
64
|
+
## Connect this MCP server to your agent
|
|
65
|
+
|
|
66
|
+
Below, a non-exhaustive list of examples is given to connect this MCP server to your agent.
|
|
67
|
+
|
|
68
|
+
### Claude Desktop
|
|
69
|
+
|
|
70
|
+
After installing, you can run the MCP server in two modes:
|
|
71
|
+
|
|
72
|
+
#### Stdio Mode (Recommended for Claude Desktop)
|
|
73
|
+
|
|
74
|
+
With stdio mode, the MCP server communicates directly via standard input/output, which is simpler and doesn't require a network port.
|
|
75
|
+
|
|
76
|
+
Add the following entry to your `claude_desktop_config.json` file (can be found via Settings / Developer / Edit Config):
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"comunica-sparql-hdt": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": [
|
|
84
|
+
"-y",
|
|
85
|
+
"@comunica/mcp-sparql-hdt",
|
|
86
|
+
"--mode",
|
|
87
|
+
"stdio"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### HTTP Mode
|
|
95
|
+
|
|
96
|
+
Alternatively, you can run the MCP server in HTTP mode, which requires starting the server manually first:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
$ comunica-mcp-sparql-hdt --mode http --port 3123
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Then, add the following entry to your `claude_desktop_config.json`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"comunica-sparql-hdt": {
|
|
108
|
+
"command": "npx",
|
|
109
|
+
"args": [
|
|
110
|
+
"-y",
|
|
111
|
+
"mcp-remote",
|
|
112
|
+
"http://localhost:3123/mcp",
|
|
113
|
+
"--allow-http"
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Then, you can ask Claude something like the following:
|
|
121
|
+
|
|
122
|
+
> Use Comunica SPARQL HDT to query the DBpedia HDT file at /path/to/dbpedia.hdt and find all movies directed by Christopher Nolan.
|
|
123
|
+
|
|
124
|
+
#### Default Sources
|
|
125
|
+
|
|
126
|
+
You can optionally configure default HDT 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.
|
|
127
|
+
|
|
128
|
+
This is useful when you want to restrict queries to specific HDT files.
|
|
129
|
+
|
|
130
|
+
**Stdio Mode with Default Sources:**
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"comunica-sparql-hdt": {
|
|
136
|
+
"command": "npx",
|
|
137
|
+
"args": [
|
|
138
|
+
"-y",
|
|
139
|
+
"@comunica/mcp-sparql-hdt",
|
|
140
|
+
"--mode",
|
|
141
|
+
"stdio",
|
|
142
|
+
"/path/to/dbpedia.hdt"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**HTTP Mode with Default Sources:**
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
$ comunica-mcp-sparql-hdt --mode http --port 3123 /path/to/dbpedia.hdt
|
|
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-hdt -- npx -y @comunica/mcp-sparql-hdt --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-hdt --mode http --port 3123
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
claude mcp add --transport http sparql-hdt 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-hdt --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 over one or more HDT files or remote HDT endpoints, which also includes update queries.
|
|
197
|
+
|
|
198
|
+
**Parameters:**
|
|
199
|
+
- `query` (required): SPARQL query string
|
|
200
|
+
- `sources` (required, unless default sources are configured): List of HDT file paths or HDT endpoint URLs
|
|
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_hdt_1 = require("@comunica/query-sparql-hdt");
|
|
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_hdt_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,iEAAyD;AACzD,mDAA6C;AAE7C,sFAAsF;AACtF,IAAA,kBAAM,EAAC,IAAI,8BAAW,EAAE,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { QueryEngine } from '@comunica/query-sparql-hdt';\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,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/mcp-sparql-hdt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "An MCP server for executing SPARQL queries over HDT files",
|
|
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-hdt"
|
|
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
|
+
"hdt",
|
|
25
|
+
"engine",
|
|
26
|
+
"query",
|
|
27
|
+
"update",
|
|
28
|
+
"sparql engine",
|
|
29
|
+
"sparql query",
|
|
30
|
+
"sparql update",
|
|
31
|
+
"sparql 1.1",
|
|
32
|
+
"sparql 1.2"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"main": "lib/index.js",
|
|
36
|
+
"typings": "lib/index",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"comunica-mcp-sparql-hdt": "bin/mcp.js"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"bin/**/*.d.ts",
|
|
45
|
+
"bin/**/*.js",
|
|
46
|
+
"bin/**/*.js.map",
|
|
47
|
+
"lib/**/*.d.ts",
|
|
48
|
+
"lib/**/*.js",
|
|
49
|
+
"lib/**/*.js.map"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "yarn run build:ts",
|
|
53
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\""
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@comunica/query-sparql-hdt": "^5.0.0",
|
|
57
|
+
"@comunica/utils-mcp": "^1.0.0"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "8a35a73d61cf1066bb1181761884d84d3b932932"
|
|
60
|
+
}
|