@comunica/mcp-sparql-solid 1.0.0 → 1.1.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/README.md CHANGED
@@ -157,6 +157,22 @@ possibly combined with a reverse proxy and/or OAuth layer.
157
157
  $ comunica-mcp-sparql-solid --mode http --port 3123
158
158
  ```
159
159
 
160
+ ## Query timeouts
161
+
162
+ SPARQL queries can take arbitrarily long, for example when they are executed over large or slow sources.
163
+ To make sure that an agent never waits indefinitely, queries are aborted after `--timeout` milliseconds
164
+ (60 seconds by default, `--timeout 0` disables this), after which the agent receives an error
165
+ that invites it to refine its query.
166
+
167
+ ```bash
168
+ $ comunica-mcp-sparql-solid --mode http --port 3123 --timeout 300000
169
+ ```
170
+
171
+ Note that Comunica offers no way to abort a query that is already running,
172
+ so a timed out query keeps consuming CPU and memory until it terminates by itself.
173
+ Contrary to the other Comunica MCP servers, this server does not execute queries inside replaceable worker
174
+ processes, as every new worker would require the user to interactively log in again.
175
+
160
176
  ## Available Tools
161
177
 
162
178
  This MCP server provides the following tools:
@@ -27,11 +27,18 @@ function runCliSolid(queryEngine, version) {
27
27
  type: 'string',
28
28
  description: 'Solid identity provider to authenticate with (set to \'void\' to disable auth)',
29
29
  default: 'https://solidcommunity.net/',
30
+ })
31
+ .option('timeout', {
32
+ alias: 't',
33
+ type: 'number',
34
+ default: 60_000,
35
+ description: 'Maximum query execution time in milliseconds (0 to disable)',
30
36
  })
31
37
  .example([
32
38
  ['$0 --mode http --port 3000', 'Start MCP server in HTTP mode on port 3000 with default IDP'],
33
39
  ['$0 --mode http --idp https://solidcommunity.net/', 'Start with a specific identity provider'],
34
40
  ['$0 --mode http --idp void', 'Start without authentication'],
41
+ ['$0 --mode http --timeout 300000', 'Start with a query timeout of 5 minutes'],
35
42
  ['$0 --mode http https://example.org/data/', 'Start with a default Solid pod URL'],
36
43
  ])
37
44
  .parse();
@@ -59,7 +66,10 @@ function runCliSolid(queryEngine, version) {
59
66
  const customContext = session ?
60
67
  { '@comunica/actor-http-inrupt-solid-client-authn:session': session } :
61
68
  undefined;
62
- const server = new utils_mcp_1.SparqlMcpServer('http', argv.port, queryEngine, version, process.stderr, defaultSources, customContext, ` If you want to query the WebID or pod of the user, you can pass the URL ${session?.info.webId}.`);
69
+ // Contrary to the non-Solid MCP servers, this server is not run inside worker processes,
70
+ // as restarting a worker would require the user to interactively log in again.
71
+ // Queries are therefore only guarded by the (soft) query timeout below.
72
+ const server = new utils_mcp_1.SparqlMcpServer('http', argv.port, queryEngine, version, process.stderr, defaultSources, customContext, ` If you want to query the WebID or pod of the user, you can pass the URL ${session?.info.webId}.`, { queryTimeout: argv.timeout });
63
73
  // Handle graceful shutdown
64
74
  const cleanup = async () => {
65
75
  if (session) {
@@ -1 +1 @@
1
- {"version":3,"file":"BinHelpersSolid.js","sourceRoot":"","sources":["BinHelpersSolid.ts"],"names":[],"mappings":";;AAUA,kCAqGC;AA7GD,mDAAsD;AAEtD,iCAA0B;AAC1B,2CAAwC;AAExC,oEAAoE;AACpE,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAEpE,SAAgB,WAAW,CAAC,WAA4B,EAAE,OAAe;IACvE,CAAC,KAAK,IAAG,EAAE;QACT,MAAM,IAAI,GAAG,MAAM,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5C,KAAK,CAAC,kCAAkC,CAAC;aACzC,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAE,MAAM,CAAE;YACnB,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,wEAAwE;SACtF,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,+BAA+B;SAC7C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H,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YACzD,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACjE,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable unicorn/no-process-exit */\nimport type { QueryEngineBase } from '@comunica/actor-init-query';\nimport { SparqlMcpServer } from '@comunica/utils-mcp';\nimport type { Session } from '@rubensworks/solid-client-authn-isomorphic';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires\nconst { interactiveLogin } = require('solid-node-interactive-auth');\n\nexport function runCliSolid(queryEngine: QueryEngineBase, version: string): void {\n (async() => {\n const argv = await yargs(hideBin(process.argv))\n .usage('Usage: $0 [options] [sources...]')\n .option('mode', {\n alias: 'm',\n type: 'string',\n choices: [ 'http' ],\n demandOption: true,\n description: 'Transport mode for the MCP server (only http mode supported for Solid)',\n })\n .option('port', {\n alias: 'p',\n type: 'number',\n default: 3123,\n description: 'Port to run the MCP server on',\n })\n .option('idp', {\n type: 'string',\n description: 'Solid identity provider to authenticate with (set to \\'void\\' to disable auth)',\n default: 'https://solidcommunity.net/',\n })\n .example([\n [ '$0 --mode http --port 3000', 'Start MCP server in HTTP mode on port 3000 with default IDP' ],\n [ '$0 --mode http --idp https://solidcommunity.net/', 'Start with a specific identity provider' ],\n [ '$0 --mode http --idp void', 'Start without authentication' ],\n [ '$0 --mode http https://example.org/data/', 'Start with a default Solid pod URL' ],\n ])\n .parse();\n\n // Extract positional arguments as default sources\n const defaultSources: string[] | undefined = argv._.length > 0 ? argv._.map(String) : undefined;\n\n // Handle Solid authentication\n let session: Session | undefined;\n if (argv.idp !== 'void') {\n try {\n process.stderr.write(`Authenticating with identity provider: ${argv.idp}\\n`);\n session = await interactiveLogin({\n oidcIssuer: argv.idp,\n });\n process.stderr.write('Authentication successful!\\n');\n } catch (error: any) {\n process.stderr.write(`Authentication error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n }\n }\n\n // Prepare custom context with Solid session if authenticated\n const customContext = session ?\n { '@comunica/actor-http-inrupt-solid-client-authn:session': session } :\n undefined;\n\n const server = new SparqlMcpServer(\n 'http',\n argv.port,\n queryEngine,\n version,\n process.stderr,\n defaultSources,\n customContext,\n ` If you want to query the WebID or pod of the user, you can pass the URL ${session?.info.webId}.`,\n );\n\n // Handle graceful shutdown\n const cleanup = async(): Promise<void> => {\n if (session) {\n try {\n await session.logout();\n process.stderr.write('Logged out from Solid pod\\n');\n } catch (error: any) {\n process.stderr.write(`Logout error: ${error.message}\\n`);\n }\n }\n };\n\n process.on('SIGINT', () => {\n cleanup().then(() => process.exit(0)).catch(() => process.exit(1));\n });\n\n process.on('SIGTERM', () => {\n cleanup().then(() => process.exit(0)).catch(() => process.exit(1));\n });\n\n await server.start().catch((error) => {\n process.stderr.write(`Server error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n return cleanup().finally(() => process.exit(1));\n });\n })().catch((error) => {\n process.stderr.write(`Initialization error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n });\n}\n"]}
1
+ {"version":3,"file":"BinHelpersSolid.js","sourceRoot":"","sources":["BinHelpersSolid.ts"],"names":[],"mappings":";;AAUA,kCAgHC;AAxHD,mDAAsD;AAEtD,iCAA0B;AAC1B,2CAAwC;AAExC,oEAAoE;AACpE,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAEpE,SAAgB,WAAW,CAAC,WAA4B,EAAE,OAAe;IACvE,CAAC,KAAK,IAAG,EAAE;QACT,MAAM,IAAI,GAAG,MAAM,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5C,KAAK,CAAC,kCAAkC,CAAC;aACzC,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAE,MAAM,CAAE;YACnB,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,wEAAwE;SACtF,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,+BAA+B;SAC7C,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gFAAgF;YAC7F,OAAO,EAAE,6BAA6B;SACvC,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,6DAA6D;SAC3E,CAAC;aACD,OAAO,CAAC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M,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YACzD,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACjE,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable unicorn/no-process-exit */\nimport type { QueryEngineBase } from '@comunica/actor-init-query';\nimport { SparqlMcpServer } from '@comunica/utils-mcp';\nimport type { Session } from '@rubensworks/solid-client-authn-isomorphic';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\n// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires\nconst { interactiveLogin } = require('solid-node-interactive-auth');\n\nexport function runCliSolid(queryEngine: QueryEngineBase, version: string): void {\n (async() => {\n const argv = await yargs(hideBin(process.argv))\n .usage('Usage: $0 [options] [sources...]')\n .option('mode', {\n alias: 'm',\n type: 'string',\n choices: [ 'http' ],\n demandOption: true,\n description: 'Transport mode for the MCP server (only http mode supported for Solid)',\n })\n .option('port', {\n alias: 'p',\n type: 'number',\n default: 3123,\n description: 'Port to run the MCP server on',\n })\n .option('idp', {\n type: 'string',\n description: 'Solid identity provider to authenticate with (set to \\'void\\' to disable auth)',\n default: 'https://solidcommunity.net/',\n })\n .option('timeout', {\n alias: 't',\n type: 'number',\n default: 60_000,\n description: 'Maximum query execution time in milliseconds (0 to disable)',\n })\n .example([\n [ '$0 --mode http --port 3000', 'Start MCP server in HTTP mode on port 3000 with default IDP' ],\n [ '$0 --mode http --idp https://solidcommunity.net/', 'Start with a specific identity provider' ],\n [ '$0 --mode http --idp void', 'Start without authentication' ],\n [ '$0 --mode http --timeout 300000', 'Start with a query timeout of 5 minutes' ],\n [ '$0 --mode http https://example.org/data/', 'Start with a default Solid pod URL' ],\n ])\n .parse();\n\n // Extract positional arguments as default sources\n const defaultSources: string[] | undefined = argv._.length > 0 ? argv._.map(String) : undefined;\n\n // Handle Solid authentication\n let session: Session | undefined;\n if (argv.idp !== 'void') {\n try {\n process.stderr.write(`Authenticating with identity provider: ${argv.idp}\\n`);\n session = await interactiveLogin({\n oidcIssuer: argv.idp,\n });\n process.stderr.write('Authentication successful!\\n');\n } catch (error: any) {\n process.stderr.write(`Authentication error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n }\n }\n\n // Prepare custom context with Solid session if authenticated\n const customContext = session ?\n { '@comunica/actor-http-inrupt-solid-client-authn:session': session } :\n undefined;\n\n // Contrary to the non-Solid MCP servers, this server is not run inside worker processes,\n // as restarting a worker would require the user to interactively log in again.\n // Queries are therefore only guarded by the (soft) query timeout below.\n const server = new SparqlMcpServer(\n 'http',\n argv.port,\n queryEngine,\n version,\n process.stderr,\n defaultSources,\n customContext,\n ` If you want to query the WebID or pod of the user, you can pass the URL ${session?.info.webId}.`,\n { queryTimeout: argv.timeout },\n );\n\n // Handle graceful shutdown\n const cleanup = async(): Promise<void> => {\n if (session) {\n try {\n await session.logout();\n process.stderr.write('Logged out from Solid pod\\n');\n } catch (error: any) {\n process.stderr.write(`Logout error: ${error.message}\\n`);\n }\n }\n };\n\n process.on('SIGINT', () => {\n cleanup().then(() => process.exit(0)).catch(() => process.exit(1));\n });\n\n process.on('SIGTERM', () => {\n cleanup().then(() => process.exit(0)).catch(() => process.exit(1));\n });\n\n await server.start().catch((error) => {\n process.stderr.write(`Server error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n return cleanup().finally(() => process.exit(1));\n });\n })().catch((error) => {\n process.stderr.write(`Initialization error: ${error.message}\\n`);\n if (error.stack) {\n process.stderr.write(`${error.stack}\\n`);\n }\n process.exit(1);\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/mcp-sparql-solid",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "An MCP server for executing SPARQL queries over Solid data pods with authentication support",
5
5
  "license": "MIT",
6
6
  "funding": {
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@comunica/query-sparql-solid": "^5.0.1",
58
- "@comunica/utils-mcp": "^1.0.0",
58
+ "@comunica/utils-mcp": "^1.1.0",
59
59
  "@rubensworks/solid-client-authn-isomorphic": "^2.0.0",
60
60
  "@types/yargs": "^17.0.0",
61
61
  "solid-node-interactive-auth": "^1.0.2",
62
62
  "yargs": "^17.7.2"
63
63
  },
64
- "gitHead": "8a35a73d61cf1066bb1181761884d84d3b932932"
64
+ "gitHead": "4d3c6e5233ec89ceeb45bd2a478652e7f74d5cd2"
65
65
  }