@corbits/mcp 0.3.1 → 0.4.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.
Files changed (124) hide show
  1. package/README.md +120 -26
  2. package/dist/auth/callback.d.ts +14 -0
  3. package/dist/auth/callback.js +79 -0
  4. package/dist/auth/challenge.d.ts +9 -0
  5. package/dist/auth/challenge.js +52 -0
  6. package/dist/auth/contracts.d.ts +18 -0
  7. package/dist/auth/contracts.js +19 -0
  8. package/dist/auth/http.d.ts +2 -0
  9. package/dist/auth/http.js +2 -0
  10. package/dist/auth/index.d.ts +6 -0
  11. package/dist/auth/index.js +6 -0
  12. package/dist/auth/login.d.ts +62 -0
  13. package/dist/auth/login.js +175 -0
  14. package/dist/auth/oauth-http.d.ts +6 -0
  15. package/dist/auth/oauth-http.js +32 -0
  16. package/dist/auth/resource-server.d.ts +25 -0
  17. package/dist/auth/resource-server.js +94 -0
  18. package/dist/auth/url-policy.d.ts +10 -0
  19. package/dist/auth/url-policy.js +35 -0
  20. package/dist/client/resource-budget.d.ts +1 -0
  21. package/dist/client/resource-budget.js +1 -0
  22. package/dist/client/transport.d.ts +10 -0
  23. package/dist/client/transport.js +1 -0
  24. package/dist/client.d.ts +208 -26
  25. package/dist/client.js +1128 -90
  26. package/dist/extensions/apps.d.ts +58 -0
  27. package/dist/extensions/apps.js +55 -0
  28. package/dist/extensions/elicitation.d.ts +18 -0
  29. package/dist/extensions/elicitation.js +55 -0
  30. package/dist/extensions/index.d.ts +5 -0
  31. package/dist/extensions/index.js +5 -0
  32. package/dist/extensions/maturity.d.ts +44 -0
  33. package/dist/extensions/maturity.js +24 -0
  34. package/dist/extensions/skills/contracts.d.ts +53 -0
  35. package/dist/extensions/skills/contracts.js +1 -0
  36. package/dist/extensions/skills/index.d.ts +52 -0
  37. package/dist/extensions/skills/index.js +402 -0
  38. package/dist/extensions/tasks/contracts.d.ts +39 -0
  39. package/dist/extensions/tasks/contracts.js +1 -0
  40. package/dist/extensions/tasks/file-store.d.ts +12 -0
  41. package/dist/extensions/tasks/file-store.js +152 -0
  42. package/dist/extensions/tasks/index.d.ts +82 -0
  43. package/dist/extensions/tasks/index.js +221 -0
  44. package/dist/extensions/tasks/record.d.ts +3 -0
  45. package/dist/extensions/tasks/record.js +37 -0
  46. package/dist/hub/discover.d.ts +5 -1
  47. package/dist/hub/discover.js +36 -13
  48. package/dist/index.d.ts +3 -2
  49. package/dist/index.js +4 -2
  50. package/dist/interchange/client/capabilities.d.ts +4 -0
  51. package/dist/interchange/client/capabilities.js +53 -0
  52. package/dist/interchange/client/catalog.d.ts +14 -0
  53. package/dist/interchange/client/catalog.js +52 -0
  54. package/dist/interchange/client/contracts.d.ts +47 -0
  55. package/dist/interchange/client/contracts.js +1 -0
  56. package/dist/interchange/client/projection.d.ts +6 -0
  57. package/dist/interchange/client/projection.js +92 -0
  58. package/dist/interchange/client/skills.d.ts +16 -0
  59. package/dist/interchange/client/skills.js +87 -0
  60. package/dist/interchange/client.d.ts +8 -0
  61. package/dist/interchange/client.js +6 -0
  62. package/dist/interchange/server/contracts.d.ts +65 -0
  63. package/dist/interchange/server/contracts.js +1 -0
  64. package/dist/interchange/server.d.ts +5 -0
  65. package/dist/interchange/server.js +172 -0
  66. package/dist/naming.d.ts +2 -0
  67. package/dist/naming.js +7 -0
  68. package/dist/oauth-discovery.d.ts +107 -1
  69. package/dist/oauth-discovery.js +292 -56
  70. package/dist/protocol/content.d.ts +35 -0
  71. package/dist/protocol/content.js +64 -0
  72. package/dist/protocol/envelopes.d.ts +14 -0
  73. package/dist/protocol/envelopes.js +22 -0
  74. package/dist/protocol/errors.d.ts +26 -0
  75. package/dist/protocol/errors.js +31 -0
  76. package/dist/protocol/extensions.d.ts +34 -0
  77. package/dist/protocol/extensions.js +86 -0
  78. package/dist/protocol/headers.d.ts +12 -0
  79. package/dist/protocol/headers.js +128 -0
  80. package/dist/protocol/index.d.ts +11 -0
  81. package/dist/protocol/index.js +11 -0
  82. package/dist/protocol/json-schema.d.ts +8 -0
  83. package/dist/protocol/json-schema.js +152 -0
  84. package/dist/protocol/legacy.d.ts +12 -0
  85. package/dist/protocol/legacy.js +18 -0
  86. package/dist/protocol/methods.d.ts +116 -0
  87. package/dist/protocol/methods.js +78 -0
  88. package/dist/protocol/resource-budget.d.ts +9 -0
  89. package/dist/protocol/resource-budget.js +206 -0
  90. package/dist/protocol/schemas.d.ts +115 -0
  91. package/dist/protocol/schemas.js +553 -0
  92. package/dist/protocol/types.d.ts +295 -0
  93. package/dist/protocol/types.js +3 -0
  94. package/dist/protocol/ui.d.ts +3 -0
  95. package/dist/protocol/ui.js +18 -0
  96. package/dist/server/contracts.d.ts +67 -0
  97. package/dist/server/contracts.js +1 -0
  98. package/dist/server/errors.d.ts +6 -0
  99. package/dist/server/errors.js +21 -0
  100. package/dist/server/extensions.d.ts +7 -0
  101. package/dist/server/extensions.js +61 -0
  102. package/dist/server/fixtures.d.ts +2 -0
  103. package/dist/server/fixtures.js +34 -0
  104. package/dist/server/legacy.d.ts +9 -0
  105. package/dist/server/legacy.js +435 -0
  106. package/dist/server/tools.d.ts +17 -0
  107. package/dist/server/tools.js +93 -0
  108. package/dist/server.d.ts +14 -0
  109. package/dist/server.js +406 -0
  110. package/dist/sidecar-bundle.d.ts +7 -7
  111. package/dist/sidecar-bundle.js +36 -29
  112. package/dist/test-server.js +12 -3
  113. package/dist/tool.d.ts +8 -0
  114. package/dist/tool.js +35 -19
  115. package/dist/url.js +8 -3
  116. package/docs/conformance.md +135 -0
  117. package/docs/integration-status.md +98 -0
  118. package/docs/legacy-server.md +58 -0
  119. package/docs/migration.md +143 -0
  120. package/docs/public-api.md +106 -0
  121. package/examples/README.md +28 -0
  122. package/examples/standalone-client.ts +14 -0
  123. package/examples/standalone-server.ts +37 -0
  124. package/package.json +40 -5
@@ -0,0 +1,106 @@
1
+ # Public extension and authorization API
2
+
3
+ Status: integration followup, 2026-10-25. Factory exports are implemented and
4
+ installed behavior is tested; OAuth-core is an optional host peer.
5
+
6
+ | Entry | Public API |
7
+ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
8
+ | `@corbits/mcp/client` | Standalone client functions and wire types |
9
+ | `@corbits/mcp/server` | Server/provider factories, `createSkillPublisher`, skill contracts, `createTaskRuntime`, `validateTaskRecord`, task contracts, `createMcpResourceServerAuth`, auth policy/identity/options types |
10
+ | `@corbits/mcp/server/task-store` | `createFileTaskStore` (explicit filesystem entry only) |
11
+ | `@corbits/mcp/interchange/client` | Existing tool/server/host APIs plus `createSkillLoader`, `parseSkillFrontmatter`, `SKILL_LIMITS`, skill contracts |
12
+ | `@corbits/mcp/interchange/server` | Explicit selected host exposure contracts and providers |
13
+ | `@corbits/mcp` | Historical facade and guarded authorization APIs |
14
+
15
+ Facade changes add reexports only. No filesystem store is exported through a
16
+ neutral barrel. The file store requires a private host-owned directory and one
17
+ writer; stale-lock recovery requires proof the previous writer is dead.
18
+
19
+ ## Dependency boundary and setup
20
+
21
+ OAuth-core is an optional peer (`^0.3.0`) and pinned development dependency
22
+ (0.3.0). Neutral client/server entries do not require it. Root and guarded OAuth
23
+ login users must explicitly install OAuth-core plus the root's agent/harness
24
+ peers; this is a breaking change from automatic OAuth installation. Host/auth
25
+ packed fixtures explicitly install these dependencies. OAuth-core itself still
26
+ transitively installs DB/hub/Hono; that cost belongs to the opt-in host setup.
27
+
28
+ Resource-server URL validation now uses the neutral auth URL-policy seam. Its
29
+ errors retain the diagnostic `OAuthDiscoveryError` name/message/detail but are
30
+ not instances of OAuth-core's error class. OAuth-facing helpers translate to the
31
+ actual OAuth-core `OAuthDiscoveryError` class. Neutral consumers must not import
32
+ the optional OAuth implementation merely to perform an `instanceof` check.
33
+
34
+ ```sh
35
+ npm install @corbits/mcp @corbits/oauth-core@0.3.0 @intx/agent@0.5.0 @intx/harness@0.5.0
36
+ ```
37
+
38
+ The full hub peer set does not resolve: credential-http 0.1.0 declares harness
39
+ **and types** `^0.4.0`, incompatible with the pinned 0.5.0 baseline. A companion
40
+ credential-http release validated with and declaring support for both
41
+ `@intx/harness@0.5.0` and `@intx/types@0.5.0` is needed. No known release number
42
+ is asserted; no force/legacy-peer-deps or external patch was used.
43
+
44
+ ## Installed evidence
45
+
46
+ The final optional-peer tarball fixtures pass on Bun 1.4.2 and Node 24.22.1:
47
+ publisher bytes/metadata, task close/reopen/recovery without replay and principal
48
+ isolation, injected resource-auth verifier/challenge/metadata, skill verification
49
+ and refusal to activate without policy, historical facade identity, and guarded
50
+ OAuth PKCE/resource/cancellation. These are scoped fixture assertions, not live
51
+ OAuth interoperability, cryptographic-verifier certification or full conformance.
52
+
53
+ Package tests use ordinary npm installs (no peer omission), reject absent public
54
+ exports, assert unwanted dependencies are absent, and check both neutral module
55
+ graphs. These checks validate the dependency boundary; see [integration status](integration-status.md) for command evidence.
56
+
57
+ ## Legacy public options and Apps gate
58
+
59
+ The server entry exposes `McpLegacyOptions` / `McpLegacyRevision`; the installed
60
+ legacy smoke exercises `createMcpServer({ legacy: ... })` for all three 2025
61
+ revisions. See [legacy-server.md](legacy-server.md) for bounds and deployment
62
+ requirements. Modern mode stays session-free by default.
63
+
64
+ Interchange Apps advertisement requires explicit `apps` bridge/support and
65
+ presentation, including sandbox renderer, CSP enforcement and authenticated
66
+ bridge support. Metadata-only presentation does not advertise Apps. The host
67
+ must implement the renderer and enforce these commitments.
68
+
69
+ ## Guarded path versus external companion defects
70
+
71
+ **CL11479:** OAuth-core 0.3.0 stock BaseTokens/conversion/storage requires refresh
72
+ material even for valid access-token-only grants. Stock token POST follows
73
+ redirects and exposes raw response error bodies, and authorization extras can
74
+ overwrite protected state/PKCE. The guarded MCP login/session path supports
75
+ access-only tokens through honest host persistence, refuses redirects, sanitizes
76
+ errors and rejects protected overrides; it does not fix stock helpers.
77
+
78
+ Additional documented stock hub limits are DCR-only registration selection and
79
+ present-but-unadvertised `iss` not being checked on the stock callback path.
80
+ These integration limits are distinct from the exact CL11479 issue acceptance.
81
+ Use guarded preparation/session/callback seams rather than assuming the stock
82
+ provider/hub path has equivalent checks. OAuth-core already propagates resource
83
+ on code exchange and refresh; the local config-builder omission was fixed, not
84
+ an absent upstream feature.
85
+
86
+ **CL11480:** Besides the harness/types peer conflict above, credential-http 0.1.0
87
+ ignores Request+init overrides in its Request branch and permits insecure
88
+ configured credential destination schemes. Local hub endpoint/redirect checks
89
+ do not fix standalone external provider handles. Upstream correction and host
90
+ transport policy remain required; no external package was patched here.
91
+
92
+ The source audit is recorded in `src/auth/INTEGRATION.md`; this public summary
93
+ keeps the relevant limits available in the packed docs. Production encrypted
94
+ storage/authority, live callback listeners, consent, actual cryptographic token
95
+ verification, egress/DNS policy and distributed durability remain host obligations.
96
+
97
+ ## Verified Skills supported shapes
98
+
99
+ The verified Skills loader declines dynamic manifests. This refusal is permitted
100
+ by the pinned Skills specification; dynamic consumption is not a newly missing
101
+ mandatory capability or an expansion of this adapter's implementation scope.
102
+ The adapter requires a complete resource read containing exactly one text or
103
+ blob item whose URI matches the requested resource. Resource-read MRTR
104
+ (`input_required`) is unsupported by this verified adapter; generic client MRTR
105
+ support does not imply that the Skills adapter can fulfill it. These supported-
106
+ shape limits are separate from the approved decoded-size and integrity bounds.
@@ -0,0 +1,28 @@
1
+ # Examples
2
+
3
+ These examples use public entry points after building/installing the package.
4
+
5
+ - `standalone-client.ts`: discover and call an explicitly named remote tool.
6
+ - `standalone-server.ts`: intentionally public loopback echo server. Do not expose
7
+ sensitive operations with `auth: "public"`; install a validated auth policy and
8
+ explicit allowed origins when deploying an authenticated service.
9
+ - `../e2e/interchange.test.ts`: executable bidirectional example using installed
10
+ Interchange `defineTool`, `createToolRunner`, HTTP credential provider and
11
+ credential capability. It exposes one selected tool (not the entire bundle),
12
+ calls it through standalone MCP, consumes it back into a real tool factory,
13
+ and asserts schema/authorization/approval failures do not execute it. It does
14
+ not simulate an inference reactor or certify workflow/task lifecycle support.
15
+
16
+ ```sh
17
+ bun run build
18
+ bun examples/standalone-server.ts
19
+ # In another terminal:
20
+ bun examples/standalone-client.ts http://127.0.0.1:3000/mcp echo
21
+ ```
22
+
23
+ For an authenticated host, compose `createInterchangeProviders({ auth, exposures })`
24
+ into `createMcpServer({ serverInfo, auth, providers })`. Each exposure supplies a
25
+ host-bound tenant, operation resource/action, explicit approval callback and a
26
+ selected tool/agent/HTTP/workflow binding. Never derive identity or fixed tenant
27
+ paths from model arguments. See the [migration guide](../docs/migration.md) for
28
+ required host services and cancellation/durability limits.
@@ -0,0 +1,14 @@
1
+ import { mcpCallTool, mcpConnect, mcpListTools } from "@corbits/mcp/client";
2
+
3
+ const url = process.argv[2];
4
+ const name = process.argv[3];
5
+ if (!url || !name) throw new Error("Usage: standalone-client.ts <url> <tool>");
6
+ const session = await mcpConnect(url);
7
+ console.log(await mcpListTools(url, { session }));
8
+ const result = await mcpCallTool(url, name, { text: "hello" }, { session });
9
+ if (result.resultType === "input_required" || result.resultType === "task") {
10
+ throw new Error(
11
+ "This minimal example has no elicitation or task host services",
12
+ );
13
+ }
14
+ console.log(result.content);
@@ -0,0 +1,37 @@
1
+ import { createMcpServer, createToolProviders } from "@corbits/mcp/server";
2
+
3
+ const server = createMcpServer({
4
+ serverInfo: { name: "public-loopback-echo", version: "1" },
5
+ auth: "public",
6
+ providers: createToolProviders(
7
+ [
8
+ {
9
+ definition: {
10
+ name: "echo",
11
+ inputSchema: {
12
+ type: "object",
13
+ properties: { text: { type: "string" } },
14
+ required: ["text"],
15
+ additionalProperties: false,
16
+ },
17
+ },
18
+ resource: "example:echo",
19
+ action: "invoke",
20
+ execute: (args) => ({
21
+ content: [{ type: "text", text: String(args.text) }],
22
+ }),
23
+ },
24
+ ],
25
+ "public",
26
+ ),
27
+ });
28
+ const http = Bun.serve({
29
+ hostname: "127.0.0.1",
30
+ port: 3000,
31
+ fetch: server.fetch,
32
+ });
33
+ console.log(new URL("/mcp", http.url).href);
34
+ process.once("SIGINT", () => {
35
+ http.stop(true);
36
+ void server.close();
37
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corbits/mcp",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "MCP client tool package for Interchange: streamable HTTP, per-tool grants, OAuth.",
5
5
  "keywords": [
6
6
  "corbits",
@@ -22,7 +22,9 @@
22
22
  "files": [
23
23
  "dist",
24
24
  "README.md",
25
- "LICENSE"
25
+ "LICENSE",
26
+ "docs",
27
+ "examples"
26
28
  ],
27
29
  "type": "module",
28
30
  "sideEffects": false,
@@ -38,6 +40,26 @@
38
40
  "./hub": {
39
41
  "types": "./dist/hub/index.d.ts",
40
42
  "default": "./dist/hub/index.js"
43
+ },
44
+ "./client": {
45
+ "types": "./dist/client.d.ts",
46
+ "default": "./dist/client.js"
47
+ },
48
+ "./server": {
49
+ "types": "./dist/server.d.ts",
50
+ "default": "./dist/server.js"
51
+ },
52
+ "./interchange/client": {
53
+ "types": "./dist/interchange/client.d.ts",
54
+ "default": "./dist/interchange/client.js"
55
+ },
56
+ "./interchange/server": {
57
+ "types": "./dist/interchange/server.d.ts",
58
+ "default": "./dist/interchange/server.js"
59
+ },
60
+ "./server/task-store": {
61
+ "types": "./dist/extensions/tasks/file-store.d.ts",
62
+ "default": "./dist/extensions/tasks/file-store.js"
41
63
  }
42
64
  },
43
65
  "publishConfig": {
@@ -52,15 +74,18 @@
52
74
  "format:check": "oxfmt --check",
53
75
  "test": "bun test src --pass-with-no-tests",
54
76
  "test:e2e": "bun test e2e",
55
- "check": "bun run typecheck && bun run lint && bun run format:check && bun run test"
77
+ "check": "bun run typecheck && bun run lint && bun run format:check && bun run test",
78
+ "test:package": "bun test e2e/package.test.ts"
56
79
  },
57
80
  "dependencies": {
58
- "@corbits/oauth-core": "^0.3.0",
59
81
  "@intx/types": "^0.5.0",
60
- "arktype": "^2.2.3"
82
+ "ajv": "^8.17.1",
83
+ "arktype": "^2.2.3",
84
+ "yaml": "2.8.1"
61
85
  },
62
86
  "devDependencies": {
63
87
  "@corbits/credential-http": "0.1.0",
88
+ "@corbits/oauth-core": "0.3.0",
64
89
  "@intx/agent": "0.5.0",
65
90
  "@intx/authz": "0.5.0",
66
91
  "@intx/db": "0.5.0",
@@ -77,6 +102,7 @@
77
102
  },
78
103
  "peerDependencies": {
79
104
  "@corbits/credential-http": "^0.1.0",
105
+ "@corbits/oauth-core": "^0.3.0",
80
106
  "@intx/agent": "^0.5.0",
81
107
  "@intx/db": "^0.5.0",
82
108
  "@intx/harness": "^0.4.0 || ^0.5.0",
@@ -99,6 +125,15 @@
99
125
  },
100
126
  "hono": {
101
127
  "optional": true
128
+ },
129
+ "@intx/agent": {
130
+ "optional": true
131
+ },
132
+ "@intx/harness": {
133
+ "optional": true
134
+ },
135
+ "@corbits/oauth-core": {
136
+ "optional": true
102
137
  }
103
138
  },
104
139
  "engines": {