@nodatachat/mcp 0.4.0 → 0.4.1

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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +57 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -53,7 +53,9 @@ claude mcp add nodata -- npx @nodatachat/mcp --api-key YOUR_API_KEY --base-url h
53
53
  | Grant token (agent) | `--grant-token` | `NODATA_GRANT_TOKEN` | — |
54
54
  | Base URL | `--base-url` | `NODATA_BASE_URL` | `https://www.nodatacapsule.com` |
55
55
 
56
- At least one of `--api-key` or `--grant-token` is required. API keys use the format `sk_live_…`; grant tokens are `ndca-…` (mint via `POST /api/v1/governance/grant`).
56
+ API keys use the format `sk_live_…` (get one free at [/developers/get-started](https://www.nodatacapsule.com/developers/get-started)); grant tokens are `ndca-…` (mint via `POST /api/v1/governance/grant` or the `nodata_grant` tool).
57
+
58
+ **No credential? Setup mode.** Started without a credential, the server still connects and exposes a single `nodata_get_started` tool that walks you (or your AI) through getting a key and reconnecting — it never fails the MCP handshake. Data tools stay disabled until a credential is provided. `--help` and `--version` are also available.
57
59
 
58
60
  ## Available Tools
59
61
 
package/dist/index.js CHANGED
@@ -31,6 +31,15 @@
31
31
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
32
32
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
33
33
  import { z } from "zod";
34
+ const VERSION = "0.4.1";
35
+ const USAGE = `nodata-mcp v${VERSION} — NoData MCP server\n\n` +
36
+ " ADMIN mode: nodata-mcp --api-key sk_live_...\n" +
37
+ " AGENT mode: nodata-mcp --grant-token ndca-...\n" +
38
+ " Options: --base-url <url> (default https://www.nodatacapsule.com)\n" +
39
+ " --help · --version\n\n" +
40
+ "Env vars: NODATA_API_KEY · NODATA_GRANT_TOKEN · NODATA_BASE_URL\n" +
41
+ "Get a free API key: https://www.nodatacapsule.com/developers/get-started\n" +
42
+ "Mint a grant token: POST /api/v1/governance/grant (or the nodata_grant tool).";
34
43
  function parseArgs(argv) {
35
44
  let apiKey = "";
36
45
  let grantToken = "";
@@ -45,6 +54,18 @@ function parseArgs(argv) {
45
54
  else if (argv[i] === "--base-url" && argv[i + 1]) {
46
55
  baseUrl = argv[++i];
47
56
  }
57
+ else if (argv[i] === "--help" || argv[i] === "-h") {
58
+ console.log(USAGE);
59
+ process.exit(0);
60
+ }
61
+ else if (argv[i] === "--version" || argv[i] === "-v") {
62
+ console.log(VERSION);
63
+ process.exit(0);
64
+ }
65
+ else if (argv[i].startsWith("--")) {
66
+ // A typo like --apikey silently degrading to setup mode is worse than noise.
67
+ console.error(`nodata-mcp: unknown option '${argv[i]}' (see --help)`);
68
+ }
48
69
  }
49
70
  if (!apiKey)
50
71
  apiKey = process.env.NODATA_API_KEY ?? "";
@@ -52,14 +73,6 @@ function parseArgs(argv) {
52
73
  grantToken = process.env.NODATA_GRANT_TOKEN ?? "";
53
74
  if (process.env.NODATA_BASE_URL)
54
75
  baseUrl = process.env.NODATA_BASE_URL;
55
- if (!apiKey && !grantToken) {
56
- console.error("Error: a credential is required.\n\n" +
57
- " ADMIN mode: nodata-mcp --api-key sk_live_...\n" +
58
- " AGENT mode: nodata-mcp --grant-token ndca-...\n\n" +
59
- "Get an API key at https://www.nodatacapsule.com/developers/get-started\n" +
60
- "Mint a grant token via POST /api/v1/governance/grant.");
61
- process.exit(1);
62
- }
63
76
  baseUrl = baseUrl.replace(/\/+$/, "");
64
77
  return { apiKey, grantToken, baseUrl };
65
78
  }
@@ -341,19 +354,52 @@ function registerAgentTool(server, baseUrl, grantToken) {
341
354
  });
342
355
  }
343
356
  // ---------------------------------------------------------------------------
357
+ // Setup mode — no credential yet
358
+ // ---------------------------------------------------------------------------
359
+ // The public one-liner (`claude mcp add nodata -- npx @nodatachat/mcp`) arrives
360
+ // here with no credential. Exiting 1 makes the MCP client report an opaque
361
+ // "connection failed" and the stderr explanation is never seen. Instead we
362
+ // connect successfully and expose a single tool whose answer walks the user
363
+ // (via their own AI) to a working credential.
364
+ const SETUP_TEXT = "This NoData server is connected but has NO credential yet, so no data tools are available.\n\n" +
365
+ "To finish setup:\n\n" +
366
+ "1. Get a free API key (takes seconds, no card):\n" +
367
+ " https://www.nodatacapsule.com/developers/get-started\n\n" +
368
+ "2. Reconnect with the key —\n" +
369
+ " Claude Code: claude mcp remove nodata\n" +
370
+ " claude mcp add nodata -- npx @nodatachat/mcp --api-key sk_live_YOUR_KEY\n" +
371
+ " Or keep the command credential-free and set the env var instead:\n" +
372
+ " claude mcp add nodata --env NODATA_API_KEY=sk_live_YOUR_KEY -- npx @nodatachat/mcp\n\n" +
373
+ "3. (Agent mode) If you were handed a grant token (ndca-...), use --grant-token ndca-YOUR_GRANT\n" +
374
+ " (or NODATA_GRANT_TOKEN) instead of an API key — the server then exposes only the\n" +
375
+ " decide/retrieve/read/use tools scoped to that grant.\n\n" +
376
+ "Admin mode (--api-key) manages governance: register tables, issue/revoke grants, encrypt,\n" +
377
+ "decrypt, deliver, evidence. Agent mode (--grant-token) is what you hand an AI agent.";
378
+ function registerSetupTool(server) {
379
+ server.registerTool("nodata_get_started", {
380
+ description: "NoData is connected WITHOUT a credential — data tools are disabled. Call this (no arguments) to get the exact steps to finish setup: where to get a free API key and how to reconnect in admin or agent mode. If the user asks why NoData tools are missing or how to set up NoData, call this and relay the steps.",
381
+ inputSchema: {},
382
+ }, async () => ({ content: [{ type: "text", text: SETUP_TEXT }] }));
383
+ }
384
+ // ---------------------------------------------------------------------------
344
385
  // Server setup
345
386
  // ---------------------------------------------------------------------------
346
387
  async function main() {
347
388
  const { apiKey, grantToken, baseUrl } = parseArgs(process.argv.slice(2));
348
- const mode = grantToken ? "agent" : "admin";
389
+ const mode = grantToken ? "agent" : apiKey ? "admin" : "setup";
349
390
  const server = new McpServer({
350
- name: mode === "agent" ? "NoData (agent-scoped)" : "NoData",
351
- version: "0.4.0",
391
+ name: mode === "agent" ? "NoData (agent-scoped)" : mode === "setup" ? "NoData (setup)" : "NoData",
392
+ version: VERSION,
352
393
  });
353
394
  if (apiKey)
354
395
  registerAdminTools(server, baseUrl, apiKey);
355
396
  if (grantToken)
356
397
  registerAgentTool(server, baseUrl, grantToken);
398
+ if (mode === "setup") {
399
+ registerSetupTool(server);
400
+ console.error("nodata-mcp: no credential given — running in setup mode (only nodata_get_started is available).\n" +
401
+ "Pass --api-key sk_live_... or --grant-token ndca-... to enable data tools. See --help.");
402
+ }
357
403
  const transport = new StdioServerTransport();
358
404
  await server.connect(transport);
359
405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodatachat/mcp",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "NoData MCP Server — govern data for AI agents: decide (may I?) + retrieve (authorized context) + read + secret-blind invoke, plus admin governance/encrypt/decrypt/deliver",
5
5
  "bin": {
6
6
  "nodata-mcp": "./dist/index.js"