@jini-ai/mcp 0.3.4 → 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 (99) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/README.md +97 -22
  3. package/dist/agent-install/install.d.ts +20 -4
  4. package/dist/agent-install/install.js +11 -11
  5. package/dist/bin/serve.d.ts +25 -13
  6. package/dist/bin/serve.js +42 -21
  7. package/dist/client/client.d.ts +28 -8
  8. package/dist/client/client.js +25 -21
  9. package/dist/core/config.d.ts +57 -18
  10. package/dist/core/config.js +76 -48
  11. package/dist/core/index.d.ts +1 -2
  12. package/dist/core/index.js +1 -2
  13. package/dist/core/install-info.d.ts +4 -1
  14. package/dist/core/install-info.js +5 -5
  15. package/dist/core/tokens.d.ts +39 -13
  16. package/dist/core/tokens.js +54 -24
  17. package/dist/federation/adapter.http.d.ts +67 -0
  18. package/dist/federation/adapter.http.js +414 -0
  19. package/dist/federation/approvals/call-confirmation.d.ts +23 -0
  20. package/dist/federation/approvals/call-confirmation.js +124 -0
  21. package/dist/federation/approvals/index.d.ts +4 -0
  22. package/dist/federation/approvals/index.js +4 -0
  23. package/dist/federation/approvals/ports.d.ts +107 -0
  24. package/dist/federation/approvals/ports.js +2 -0
  25. package/dist/federation/approvals/revocation.d.ts +61 -0
  26. package/dist/federation/approvals/revocation.js +52 -0
  27. package/dist/federation/bootstrap.d.ts +100 -0
  28. package/dist/federation/bootstrap.js +182 -0
  29. package/dist/federation/config.d.ts +68 -0
  30. package/dist/federation/config.js +40 -0
  31. package/dist/federation/index.d.ts +14 -0
  32. package/dist/federation/index.js +14 -0
  33. package/dist/federation/mcp-protocol.d.ts +115 -0
  34. package/dist/federation/mcp-protocol.js +151 -0
  35. package/dist/federation/messages.d.ts +54 -0
  36. package/dist/federation/messages.js +35 -0
  37. package/dist/federation/ports.d.ts +287 -0
  38. package/dist/federation/ports.js +5 -0
  39. package/dist/federation/presets.d.ts +66 -0
  40. package/dist/federation/presets.js +30 -0
  41. package/dist/federation/refusal-notice.d.ts +198 -0
  42. package/dist/federation/refusal-notice.js +193 -0
  43. package/dist/federation/registrations.d.ts +171 -0
  44. package/dist/federation/registrations.js +181 -0
  45. package/dist/federation/reload.d.ts +112 -0
  46. package/dist/federation/reload.js +110 -0
  47. package/dist/federation/stdio/adapter.stdio.d.ts +157 -0
  48. package/dist/federation/stdio/adapter.stdio.js +526 -0
  49. package/dist/federation/stdio/default-connect.d.ts +29 -0
  50. package/dist/federation/stdio/default-connect.js +92 -0
  51. package/dist/federation/stdio/index.d.ts +4 -0
  52. package/dist/federation/stdio/index.js +4 -0
  53. package/dist/federation/stdio/stdio-launch-resolver.d.ts +139 -0
  54. package/dist/federation/stdio/stdio-launch-resolver.js +227 -0
  55. package/dist/federation/testing/adapter.memory.d.ts +177 -0
  56. package/dist/federation/testing/adapter.memory.js +189 -0
  57. package/dist/federation/testing/index.d.ts +3 -0
  58. package/dist/federation/testing/index.js +3 -0
  59. package/dist/federation/testing/tool-approvals.memory.d.ts +27 -0
  60. package/dist/federation/testing/tool-approvals.memory.js +38 -0
  61. package/dist/federation/tool-approvals.d.ts +97 -0
  62. package/dist/federation/tool-approvals.js +42 -0
  63. package/dist/federation/trust.d.ts +471 -0
  64. package/dist/federation/trust.js +707 -0
  65. package/dist/index.d.ts +175 -2
  66. package/dist/index.js +172 -2
  67. package/dist/server/daemon-client.d.ts +16 -4
  68. package/dist/server/daemon-client.js +41 -19
  69. package/dist/server/ports.d.ts +9 -0
  70. package/dist/server/ports.js +2 -0
  71. package/dist/server/resource-protocol.d.ts +14 -4
  72. package/dist/server/resource-protocol.js +6 -6
  73. package/dist/server/resources/active-resource.js +3 -3
  74. package/dist/server/sdk-transport.d.ts +11 -0
  75. package/dist/server/sdk-transport.js +31 -0
  76. package/dist/server/tool-protocol.d.ts +31 -9
  77. package/dist/server/tool-protocol.js +20 -18
  78. package/dist/server/tool-server.d.ts +60 -43
  79. package/dist/server/tool-server.js +51 -27
  80. package/dist/server/tools/component-catalog-tools.js +7 -7
  81. package/dist/server/tools/delegated-tool.d.ts +7 -4
  82. package/dist/server/tools/delegated-tool.js +18 -16
  83. package/dist/server/tools/run-tools.js +15 -15
  84. package/dist/server/tools/tool-catalog-tools.js +7 -7
  85. package/dist/tools/ask-choice/index.d.ts +123 -0
  86. package/dist/tools/ask-choice/index.js +98 -0
  87. package/dist/tools/ask-choice/pending.d.ts +11 -0
  88. package/dist/tools/ask-choice/pending.js +34 -0
  89. package/dist/tools/ask-choice/question.d.ts +16 -0
  90. package/dist/tools/ask-choice/question.js +60 -0
  91. package/dist/tools/ask-choice/schema.d.ts +91 -0
  92. package/dist/tools/ask-choice/schema.js +27 -0
  93. package/dist/tools/ask-choice/types.d.ts +106 -0
  94. package/dist/tools/ask-choice/types.js +2 -0
  95. package/package.json +43 -5
  96. package/dist/core/oauth.d.ts +0 -274
  97. package/dist/core/oauth.js +0 -667
  98. package/dist/core/secure-write.d.ts +0 -17
  99. package/dist/core/secure-write.js +0 -72
@@ -1,72 +0,0 @@
1
- /**
2
- * @module @jini-ai/mcp/core/secure-write
3
- * Shared atomic, owner-only-permission (0600) secret-file writer used by
4
- * every secret-bearing on-disk store in this package: the server config
5
- * store (env vars / `Authorization` headers), the OAuth dynamic-client-
6
- * registration cache (`clientSecret`), and the OAuth token store (bearer /
7
- * refresh tokens, confidential-client secrets). CR-006 / SEC-RB-002.
8
- *
9
- * The previous pattern in each of those stores wrote the temp file with
10
- * default permissions and either never restricted it (config, OAuth client
11
- * cache) or `chmod(0600)`'d it *after* the atomic rename and silently
12
- * continued when the chmod failed (tokens) — both leave a window where the
13
- * file exists world/group-readable, and the latter makes the "protection"
14
- * advisory rather than enforced. This writer instead:
15
- *
16
- * 1. Creates the temp file *exclusively* (`wx`) with mode 0600 supplied to
17
- * the same `open()`/`writeFile()` call that creates it — POSIX applies
18
- * the requested mode atomically at creation time, so there is no
19
- * window where the file exists with a broader mode. This repo already
20
- * relies on `writeFile`'s `mode` option alone for a secret file with no
21
- * separate chmod step (see `packages/agent-runtime/src/prompt-file.ts`);
22
- * this module follows that same precedent rather than inventing a new one.
23
- * 2. On POSIX platforms, verifies the on-disk mode actually landed as
24
- * owner-only before renaming into place, and fails closed — removing
25
- * the temp file and throwing — if it did not (e.g. an unusual umask or
26
- * a filesystem that doesn't honor `mode`).
27
- * 3. Skips that verification on `win32`: Windows has no POSIX permission-
28
- * bit model (`mode` there only toggles the read-only attribute), so
29
- * there is nothing meaningful to enforce or fail closed on — matching
30
- * this repo's only other cross-platform file-mode precedent, which
31
- * also does not branch on Windows.
32
- *
33
- * Part of the MCP `core` kernel; not part of the package's public barrel —
34
- * imported directly by sibling `core/*.ts` files.
35
- */
36
- import { mkdir, rename, rm, stat, writeFile } from 'node:fs/promises';
37
- import { randomBytes } from 'node:crypto';
38
- import path from 'node:path';
39
- const SECRET_FILE_MODE = 0o600;
40
- /**
41
- * Atomically write `contents` to `finalPath` via a same-directory temp file
42
- * created exclusively with mode 0600. On POSIX platforms, verifies no
43
- * group/other permission bit made it onto disk before renaming into place;
44
- * throws (after removing the temp file) if verification fails or the write
45
- * itself fails, so a caller never observes a partially-written or
46
- * insufficiently-restricted secret file.
47
- * @param finalPath Absolute path the secret file should end up at.
48
- * @param contents UTF-8 text to write.
49
- * @param options `platform` override for tests; defaults to `process.platform`.
50
- */
51
- export async function writeSecretFileAtomic(finalPath, contents, options = {}) {
52
- const platform = options.platform ?? process.platform;
53
- await mkdir(path.dirname(finalPath), { recursive: true });
54
- const tmp = `${finalPath}.${randomBytes(4).toString('hex')}.tmp`;
55
- try {
56
- await writeFile(tmp, contents, { encoding: 'utf8', mode: SECRET_FILE_MODE, flag: 'wx' });
57
- if (platform !== 'win32') {
58
- const info = await stat(tmp);
59
- const bits = info.mode & 0o777;
60
- if ((bits & 0o077) !== 0) {
61
- throw new Error(`refusing to persist secret-bearing file with non-owner-only permissions ` +
62
- `(mode 0${bits.toString(8)}): ${finalPath}`);
63
- }
64
- }
65
- await rename(tmp, finalPath);
66
- }
67
- catch (err) {
68
- await rm(tmp, { force: true }).catch(() => undefined);
69
- throw err;
70
- }
71
- }
72
- //# sourceMappingURL=secure-write.js.map