@tinycloud/mcp 0.8.0-beta.5 → 0.8.0-beta.7
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 +4 -1
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/http-cli.cjs +32 -21
- package/dist/http-cli.cjs.map +1 -1
- package/dist/http-cli.js +32 -21
- package/dist/http-cli.js.map +1 -1
- package/dist/http.cjs +32 -21
- package/dist/http.cjs.map +1 -1
- package/dist/http.js +32 -21
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +32 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -21
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +3 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -485,7 +485,7 @@ function outcomeCode(result) {
|
|
|
485
485
|
// package.json
|
|
486
486
|
var package_default = {
|
|
487
487
|
name: "@tinycloud/mcp",
|
|
488
|
-
version: "0.8.0-beta.
|
|
488
|
+
version: "0.8.0-beta.7",
|
|
489
489
|
description: "TinyCloud delegated operations MCP server",
|
|
490
490
|
keywords: [
|
|
491
491
|
"tinycloud",
|
|
@@ -556,9 +556,9 @@ var package_default = {
|
|
|
556
556
|
dependencies: {
|
|
557
557
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
558
558
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
559
|
-
"@tinycloud/node-sdk": "3.6.0-beta.
|
|
559
|
+
"@tinycloud/node-sdk": "3.6.0-beta.6",
|
|
560
560
|
"@tinycloud/node-sdk-wasm": "1.7.8",
|
|
561
|
-
"@tinycloud/operations": "0.7.4-beta.
|
|
561
|
+
"@tinycloud/operations": "0.7.4-beta.6",
|
|
562
562
|
jose: "6.2.4"
|
|
563
563
|
},
|
|
564
564
|
devDependencies: {
|
|
@@ -878,9 +878,9 @@ var RemoteTenantStore = class {
|
|
|
878
878
|
}
|
|
879
879
|
async connectStatus(subject, ownerDids = []) {
|
|
880
880
|
const tenant = await this.#ensureTenant(subject);
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
881
|
+
const state = await this.#sessionState(tenant, ownerDids, true);
|
|
882
|
+
if (state === "valid") return { connected: true, sessionDid: tenant.sessionDid };
|
|
883
|
+
if (state === "unknown") return { connected: false, sessionDid: tenant.sessionDid };
|
|
884
884
|
const pending = await this.#createPending(subject, ownerDids, "bootstrap", BOOTSTRAP_PERMISSIONS);
|
|
885
885
|
return {
|
|
886
886
|
connected: false,
|
|
@@ -1220,7 +1220,10 @@ var RemoteTenantStore = class {
|
|
|
1220
1220
|
return initializing;
|
|
1221
1221
|
}
|
|
1222
1222
|
async #hasValidSession(tenant, ownerDids, fresh = false) {
|
|
1223
|
-
|
|
1223
|
+
return await this.#sessionState(tenant, ownerDids, fresh) !== "invalid";
|
|
1224
|
+
}
|
|
1225
|
+
async #sessionState(tenant, ownerDids, fresh = false) {
|
|
1226
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
1224
1227
|
const key = JSON.stringify([tenant.stateRoot, ownerDids.map(normalizeDid), fresh]);
|
|
1225
1228
|
const current = this.#sessionChecks.get(key);
|
|
1226
1229
|
if (current) return current;
|
|
@@ -1237,9 +1240,9 @@ var RemoteTenantStore = class {
|
|
|
1237
1240
|
} catch (error) {
|
|
1238
1241
|
if (!(error instanceof SyntaxError)) throw error;
|
|
1239
1242
|
await this.#clearAuthority(tenant);
|
|
1240
|
-
return
|
|
1243
|
+
return "invalid";
|
|
1241
1244
|
}
|
|
1242
|
-
if (raw === null) return
|
|
1245
|
+
if (raw === null) return "invalid";
|
|
1243
1246
|
const node = new TinyCloudNode({ host: this.#config.nodeHost });
|
|
1244
1247
|
try {
|
|
1245
1248
|
await node.restoreSession(raw);
|
|
@@ -1248,11 +1251,11 @@ var RemoteTenantStore = class {
|
|
|
1248
1251
|
const signedExpiry = typeof header === "string" ? signedCompactUcanExpiry(header) : void 0;
|
|
1249
1252
|
const siweExpiry = typeof raw.siwe === "string" ? /^Expiration Time: ([^\r\n]+)\r?$/m.exec(raw.siwe)?.[1] : void 0;
|
|
1250
1253
|
const expiry = signedExpiry ?? (siweExpiry === void 0 ? void 0 : new Date(siweExpiry));
|
|
1251
|
-
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return
|
|
1254
|
+
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return "invalid";
|
|
1252
1255
|
await this.#clearAuthority(tenant);
|
|
1253
|
-
return
|
|
1256
|
+
return "invalid";
|
|
1254
1257
|
}
|
|
1255
|
-
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return
|
|
1258
|
+
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return "invalid";
|
|
1256
1259
|
const additional = await readJson(this.#additionalPath(tenant.stateRoot));
|
|
1257
1260
|
const cids = [raw.delegationCid];
|
|
1258
1261
|
if (additional !== null) {
|
|
@@ -1267,7 +1270,7 @@ var RemoteTenantStore = class {
|
|
|
1267
1270
|
}
|
|
1268
1271
|
const fingerprint = cids.join("\n");
|
|
1269
1272
|
const cached = this.#activeSessions.get(tenant.stateRoot);
|
|
1270
|
-
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return
|
|
1273
|
+
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return "valid";
|
|
1271
1274
|
let timer;
|
|
1272
1275
|
const timeout = new Promise((resolve) => {
|
|
1273
1276
|
timer = setTimeout(() => resolve(void 0), 2e3);
|
|
@@ -1280,13 +1283,14 @@ var RemoteTenantStore = class {
|
|
|
1280
1283
|
const refusal = probe !== void 0 && !probe.ok ? nodeRevocationOf(probe.error) : void 0;
|
|
1281
1284
|
if (refusal !== void 0 && (refusal.revokedCid === raw.delegationCid || refusal.reason === "delegation_ancestor_revoked" && refusal.ancestorCid === raw.delegationCid)) {
|
|
1282
1285
|
await this.#clearAuthority(tenant);
|
|
1283
|
-
return
|
|
1286
|
+
return "invalid";
|
|
1284
1287
|
}
|
|
1285
|
-
if (this.#renewalRequired.has(tenant.stateRoot)) return
|
|
1288
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
1286
1289
|
if (probe?.ok) {
|
|
1287
1290
|
this.#activeSessions.set(tenant.stateRoot, { cids: fingerprint, until: Date.now() + 3e4 });
|
|
1291
|
+
return "valid";
|
|
1288
1292
|
}
|
|
1289
|
-
return
|
|
1293
|
+
return "unknown";
|
|
1290
1294
|
}
|
|
1291
1295
|
async #clearAuthority(tenant) {
|
|
1292
1296
|
const current = this.#clearing.get(tenant.stateRoot);
|
|
@@ -1798,19 +1802,26 @@ function registerConnectTool(server, validator, store, identity, surface) {
|
|
|
1798
1802
|
async () => {
|
|
1799
1803
|
const startedAt = performance.now();
|
|
1800
1804
|
let code = "INTERNAL_ERROR";
|
|
1805
|
+
let text;
|
|
1801
1806
|
try {
|
|
1802
1807
|
const status = await store.connectStatus(identity.subject, identity.ownerDids);
|
|
1803
|
-
|
|
1808
|
+
if (status.connected) {
|
|
1809
|
+
code = "ok";
|
|
1810
|
+
text = "TinyCloud is connected.";
|
|
1811
|
+
} else if (status.approvalUrl === void 0) {
|
|
1812
|
+
code = "unavailable";
|
|
1813
|
+
text = "TinyCloud is unavailable. Call this tool again shortly.";
|
|
1814
|
+
} else {
|
|
1815
|
+
code = "authority_required";
|
|
1816
|
+
text = `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`;
|
|
1817
|
+
}
|
|
1804
1818
|
const visibleStatus = surface === "hosted" ? status : {
|
|
1805
1819
|
connected: status.connected,
|
|
1806
1820
|
...status.approvalUrl === void 0 ? {} : { approvalUrl: status.approvalUrl },
|
|
1807
1821
|
...status.expiresAt === void 0 ? {} : { expiresAt: status.expiresAt }
|
|
1808
1822
|
};
|
|
1809
1823
|
return {
|
|
1810
|
-
content: [{
|
|
1811
|
-
type: "text",
|
|
1812
|
-
text: status.connected ? "TinyCloud is connected." : `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`
|
|
1813
|
-
}],
|
|
1824
|
+
content: [{ type: "text", text }],
|
|
1814
1825
|
structuredContent: visibleStatus
|
|
1815
1826
|
};
|
|
1816
1827
|
} finally {
|