@absolutejs/mcp 0.17.3 → 0.17.4

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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.17.4 — 2026-09-11
10
+
11
+ ### Added
12
+
13
+ - **Ship an authenticated two-account staging canary for read isolation, credential rejection and session reconnect with private credentials and aggregate-only results**
14
+
9
15
  ## 0.17.3 — 2026-09-11
10
16
 
11
17
  ### Fixed
@@ -0,0 +1,192 @@
1
+ /** Authenticated staging checks. Tokens/results remain in memory and are never logged. */
2
+ import type { McpToolResult } from "@absolutejs/mcp";
3
+ export type AuthenticatedCanaryOptions = {
4
+ url: string;
5
+ accounts: readonly [string, string];
6
+ tool: { name: string; arguments?: Record<string, unknown> };
7
+ /** Select stable account-owned data, excluding timestamps and shared metadata. */
8
+ fingerprint: (result: McpToolResult) => string;
9
+ request?: typeof fetch;
10
+ };
11
+ export const runAuthenticatedCanary = async (
12
+ options: AuthenticatedCanaryOptions,
13
+ ) => {
14
+ const url = new URL(options.url);
15
+ if (
16
+ url.protocol !== "https:" &&
17
+ !(
18
+ url.protocol === "http:" &&
19
+ ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname)
20
+ )
21
+ )
22
+ throw Error("HTTPS required outside loopback");
23
+ if (
24
+ !options.accounts[0] ||
25
+ !options.accounts[1] ||
26
+ options.accounts[0] === options.accounts[1]
27
+ )
28
+ throw Error("Two distinct credentials required");
29
+ const request = options.request ?? fetch;
30
+ const checks: { name: string; passed: boolean }[] = [];
31
+ const sessions: { token: string; id: string; protocol: string }[] = [];
32
+ const send = async (
33
+ token: string | null,
34
+ session: (typeof sessions)[number] | undefined,
35
+ method: string,
36
+ params: unknown = {},
37
+ ) =>
38
+ request(options.url, {
39
+ method: "POST",
40
+ redirect: "error",
41
+ signal: AbortSignal.timeout(15000),
42
+ headers: {
43
+ "content-type": "application/json",
44
+ accept: "application/json, text/event-stream",
45
+ ...(token ? { authorization: `Bearer ${token}` } : {}),
46
+ ...(session
47
+ ? {
48
+ "mcp-session-id": session.id,
49
+ "mcp-protocol-version": session.protocol,
50
+ }
51
+ : {}),
52
+ },
53
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
54
+ });
55
+ const body = async (response: Response) => {
56
+ if (
57
+ !response.ok ||
58
+ !response.headers.get("content-type")?.includes("application/json")
59
+ )
60
+ throw Error("Canary requires successful JSON responses");
61
+ const value = await response.json();
62
+ if (value.error || !value.result || value.result.isError)
63
+ throw Error("Canary RPC failed");
64
+ return value.result;
65
+ };
66
+ const initialize = async (token: string) => {
67
+ const response = await send(token, undefined, "initialize", {
68
+ protocolVersion: "2025-11-25",
69
+ clientInfo: { name: "absolute-authenticated-canary", version: "1" },
70
+ capabilities: {
71
+ elicitation: {},
72
+ extensions: {
73
+ "io.modelcontextprotocol/ui": {
74
+ mimeTypes: ["text/html;profile=mcp-app"],
75
+ },
76
+ },
77
+ },
78
+ });
79
+ const result = await body(response);
80
+ const id = response.headers.get("mcp-session-id");
81
+ if (!id || typeof result.protocolVersion !== "string")
82
+ throw Error("Stateful MCP session required");
83
+ const session = { token, id, protocol: result.protocolVersion };
84
+ sessions.push(session);
85
+ await request(options.url, {
86
+ method: "POST",
87
+ redirect: "error",
88
+ signal: AbortSignal.timeout(15000),
89
+ headers: {
90
+ authorization: `Bearer ${token}`,
91
+ "content-type": "application/json",
92
+ "mcp-session-id": id,
93
+ "mcp-protocol-version": session.protocol,
94
+ },
95
+ body: JSON.stringify({
96
+ jsonrpc: "2.0",
97
+ method: "notifications/initialized",
98
+ }),
99
+ });
100
+ return session;
101
+ };
102
+ const drop = (session: (typeof sessions)[number], authorized = true) =>
103
+ request(options.url, {
104
+ method: "DELETE",
105
+ redirect: "error",
106
+ signal: AbortSignal.timeout(15000),
107
+ headers: {
108
+ "mcp-session-id": session.id,
109
+ "mcp-protocol-version": session.protocol,
110
+ ...(authorized ? { authorization: `Bearer ${session.token}` } : {}),
111
+ },
112
+ });
113
+ const read = async (token: string, session: (typeof sessions)[number]) =>
114
+ options.fingerprint(
115
+ await body(await send(token, session, "tools/call", options.tool)),
116
+ );
117
+ try {
118
+ const a = await initialize(options.accounts[0]);
119
+ const b = await initialize(options.accounts[1]);
120
+ for (const session of [a, b]) {
121
+ const discovery = await body(
122
+ await send(session.token, session, "tools/list"),
123
+ );
124
+ if (
125
+ !discovery.tools?.some(
126
+ (tool: { name: string; annotations?: { readOnlyHint?: boolean } }) =>
127
+ tool.name === options.tool.name &&
128
+ tool.annotations?.readOnlyHint === true,
129
+ )
130
+ )
131
+ throw Error("Explicitly read-only tool required for both accounts");
132
+ }
133
+ const first = await read(a.token, a);
134
+ const second = await read(b.token, b);
135
+ if (!first || !second || first === second)
136
+ throw Error(
137
+ "Distinct stable account-owned results required; isolation is inconclusive",
138
+ );
139
+ checks.push({ name: "distinct-account-results", passed: true });
140
+ for (const [session, expected] of [
141
+ [a, first],
142
+ [b, second],
143
+ ] as const)
144
+ checks.push({
145
+ name: "stable-account-result",
146
+ passed: (await read(session.token, session)) === expected,
147
+ });
148
+ for (const [token, session, expected] of [
149
+ [b.token, a, second],
150
+ [a.token, b, first],
151
+ ] as const) {
152
+ const response = await send(token, session, "tools/call", options.tool);
153
+ // Binding a session to its owner is also safe; otherwise current credentials must select the data.
154
+ checks.push({
155
+ name: "cross-session-account-isolation",
156
+ passed:
157
+ [401, 403, 404].includes(response.status) ||
158
+ options.fingerprint(await body(response)) === expected,
159
+ });
160
+ }
161
+ for (const token of [null, "invalid-canary-credential"])
162
+ checks.push({
163
+ name: "invalid-credential-rejected",
164
+ passed: (await send(token, a, "tools/list")).status === 401,
165
+ });
166
+ checks.push({
167
+ name: "unauthenticated-delete-rejected",
168
+ passed: (await drop(a, false)).status === 401,
169
+ });
170
+ checks.push({
171
+ name: "session-survives-rejected-delete",
172
+ passed: (await send(a.token, a, "tools/list")).status === 200,
173
+ });
174
+ const deletion = await drop(b);
175
+ checks.push({
176
+ name: "own-session-deletion",
177
+ passed: deletion.status === 204,
178
+ });
179
+ checks.push({
180
+ name: "terminated-session-404",
181
+ passed: (await send(b.token, b, "tools/list")).status === 404,
182
+ });
183
+ const fresh = await initialize(b.token);
184
+ checks.push({
185
+ name: "fresh-session-read",
186
+ passed: fresh.id !== b.id && (await read(b.token, fresh)) === second,
187
+ });
188
+ return { passed: checks.every((check) => check.passed), checks };
189
+ } finally {
190
+ for (const session of sessions) await drop(session).catch(() => undefined);
191
+ }
192
+ };
package/changelog.json CHANGED
@@ -2,6 +2,16 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/mcp",
4
4
  "releases": [
5
+ {
6
+ "version": "0.17.4",
7
+ "date": "2026-09-11",
8
+ "changes": [
9
+ {
10
+ "kind": "added",
11
+ "summary": "Ship an authenticated two-account staging canary for read isolation, credential rejection and session reconnect with private credentials and aggregate-only results"
12
+ }
13
+ ]
14
+ },
5
15
  {
6
16
  "version": "0.17.3",
7
17
  "date": "2026-09-11",
@@ -76,3 +76,20 @@ Native Windows VS Code 1.135.0 advertised Apps MIME support but omitted MCP-Prot
76
76
  Three report views rendered in the signed-in isolated Copilot workspace. Balance and usage refresh, daily expansion and receipt pagination passed. There were six report calls: three initial calls and three explicit button actions. Reloading restored the original report results with no extra report calls. All app documents measured 242px without horizontal document overflow. The first balance webview was blank until a window reload; its cause is not isolated, so this is a qualified rendering result, not proof of reliable first-load behavior. Reviewed aggregate evidence: `canary/results/2026-09-11-vscode.json`.
77
77
 
78
78
  Package regressions verify authorization before session deletion, per-request account selection, expired-session HTTP 404, and fresh explicit client initialization. HTTP failures now produce McpClientError with status (and a JSON-RPC code when available), including empty/non-JSON responses. After a session 404, call client.initialize() to negotiate a fresh session before further operations. The failed tool is never automatically replayed; callers must decide whether retrying is appropriate. Synthetic credentials prove handler behavior, not OAuth correctness or real-tenant isolation. Authenticated staging remains a separate release gate.
79
+
80
+ ## Authenticated two-account staging canary
81
+
82
+ Import `runAuthenticatedCanary` from `@absolutejs/mcp/canary/authenticated` in a local Bun script. Supply an HTTPS endpoint, two distinct access tokens obtained through the application's normal OAuth flow, an explicitly read-only tool, and a fingerprint function selecting stable account-owned data. Credentials, fingerprints and results remain in memory; the returned report contains only check names and booleans. Keep the calling script and tokens outside the repository.
83
+
84
+ ```ts
85
+ const report = await runAuthenticatedCanary({
86
+ url: stagingMcpUrl,
87
+ accounts: [firstAccessToken, secondAccessToken],
88
+ tool: { name: accountReadTool, arguments: {} },
89
+ fingerprint: (result) => JSON.stringify(result.content),
90
+ });
91
+ ```
92
+
93
+ Choose two accounts with known distinct data. The canary refuses identical results as inconclusive and verifies repeated reads remain stable. It checks both directions of session-ID substitution: rejecting the foreign session or returning the currently authenticated account's result is acceptable. It also checks missing/invalid credentials, unauthorized DELETE, authorized deletion, terminated-session 404, and fresh initialization/read. It creates and cleans up only its own MCP sessions, never purchases or modifies account data. Read-only annotations are a prerequisite, not a substitute for the operator selecting a known non-billable read tool. The current harness requires JSON RPC responses; SSE-only servers are not certified by it.
94
+
95
+ This verifies the selected read path, not every tenant resource, token revocation, automatic host reconnect, or billing permissions. Session termination is explicit DELETE; timed TTL expiry needs a separate store test. Use dedicated test clients and remove their grants after verification. Do not publish tokens, transcripts, fingerprints, or raw account data.
package/package.json CHANGED
@@ -46,7 +46,8 @@
46
46
  "types": "./dist/src/apps.d.ts",
47
47
  "import": "./dist/apps.js",
48
48
  "default": "./dist/apps.js"
49
- }
49
+ },
50
+ "./canary/authenticated": "./canary/authenticated.ts"
50
51
  },
51
52
  "publishConfig": {
52
53
  "access": "public"
@@ -83,8 +84,8 @@
83
84
  "prepublishOnly": "bun run check:package",
84
85
  "build:apps": "bun scripts/build-apps.ts",
85
86
  "canary": "bun canary/server.ts",
86
- "check:canary": "tsc --noEmit --strict --skipLibCheck --moduleResolution bundler --module esnext --target esnext --types bun canary/server.ts"
87
+ "check:canary": "tsc --noEmit --strict --skipLibCheck --moduleResolution bundler --module esnext --target esnext --types bun canary/server.ts canary/authenticated.ts"
87
88
  },
88
89
  "types": "./dist/src/index.d.ts",
89
- "version": "0.17.3"
90
+ "version": "0.17.4"
90
91
  }