@tinycloud/mcp 0.10.0-beta.5 → 0.10.0-beta.50
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 +49 -31
- package/dist/cli.cjs +57 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +57 -30
- package/dist/cli.js.map +1 -1
- package/dist/http-cli.cjs +97 -59
- package/dist/http-cli.cjs.map +1 -1
- package/dist/http-cli.js +97 -58
- package/dist/http-cli.js.map +1 -1
- package/dist/http.cjs +97 -59
- package/dist/http.cjs.map +1 -1
- package/dist/http.js +97 -58
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +102 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +98 -60
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +57 -30
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +57 -30
- package/dist/server.js.map +1 -1
- package/dist/tools.cjs +53 -28
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +53 -28
- package/dist/tools.js.map +1 -1
- package/generated/mcp-facts.json +16 -18
- package/package.json +5 -4
- package/skills/tinycloud-delegated-secrets/SKILL.md +4 -3
package/dist/http-cli.cjs
CHANGED
|
@@ -290,6 +290,7 @@ function logToolCall(tool, code, startedAt, replayedGrants) {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
// src/remote-store.ts
|
|
293
|
+
var import_sdk_core = require("@tinycloud/sdk-core");
|
|
293
294
|
var import_node_crypto3 = require("crypto");
|
|
294
295
|
var import_promises = require("fs/promises");
|
|
295
296
|
var import_node_path = require("path");
|
|
@@ -369,7 +370,7 @@ var NATIVE_GRANT_IMPORT_REJECTION_CODES = /* @__PURE__ */ new Set([
|
|
|
369
370
|
"DELEGATION_HOST_MISMATCH",
|
|
370
371
|
"DELEGATION_REJECTED"
|
|
371
372
|
]);
|
|
372
|
-
var
|
|
373
|
+
var PRODUCTION_NODE_HOSTS = /* @__PURE__ */ new Set(["https://node.tinycloud.xyz", "https://tee.node.tinycloud.xyz"]);
|
|
373
374
|
var BOOTSTRAP_PERMISSIONS = [
|
|
374
375
|
{
|
|
375
376
|
service: "tinycloud.kv",
|
|
@@ -792,14 +793,16 @@ var RemoteTenantStore = class {
|
|
|
792
793
|
did: tenant.sessionDid,
|
|
793
794
|
callback: callback.toString(),
|
|
794
795
|
host: this.#config.nodeHost,
|
|
795
|
-
|
|
796
|
+
requesterOrigin: this.#config.publicUrl.origin,
|
|
797
|
+
jwk: Buffer.from(JSON.stringify((0, import_node_sdk2.publicJwk)(tenant.jwk))).toString("base64url"),
|
|
796
798
|
permissions: Buffer.from(JSON.stringify({
|
|
797
799
|
permissions: pending.permissions,
|
|
798
800
|
reason: [
|
|
799
801
|
pending.kind === "bootstrap" ? "Connect this TinyCloud account to the hosted MCP delegate." : (0, import_tc_apps.tcAppsApprovalReason)(pending.permissions) ?? "Approve the exact capabilities requested by the TinyCloud MCP operation.",
|
|
800
802
|
// Owner DIDs come from the verified OpenKey access token of the MCP
|
|
801
|
-
// client that created this link, never from the link itself.
|
|
802
|
-
|
|
803
|
+
// client that created this link, never from the link itself. The
|
|
804
|
+
// callback refuses a signer outside them, so the approver isn't asked to check.
|
|
805
|
+
...pending.ownerDids.length === 0 ? [] : [`Requested by TinyCloud account ${pending.ownerDids.join(", ")}.`]
|
|
803
806
|
].join(" ")
|
|
804
807
|
})).toString("base64url"),
|
|
805
808
|
expiry: this.#config.delegationExpiry
|
|
@@ -1098,10 +1101,10 @@ var RemoteTenantStore = class {
|
|
|
1098
1101
|
authMethod: "openkey",
|
|
1099
1102
|
openkeyHost: this.#config.openkeyHost
|
|
1100
1103
|
});
|
|
1101
|
-
} else if (typeof profile.host === "string" && profile.host.replace(/\/+$/, "")
|
|
1104
|
+
} else if (typeof profile.host === "string" && PRODUCTION_NODE_HOSTS.has(profile.host.replace(/\/+$/, "")) && PRODUCTION_NODE_HOSTS.has(this.#config.nodeHost.replace(/\/+$/, "")) && profile.host.replace(/\/+$/, "") !== this.#config.nodeHost.replace(/\/+$/, "")) {
|
|
1102
1105
|
await secureWrite(profilePath, { ...profile, host: this.#config.nodeHost });
|
|
1103
1106
|
process.stderr.write(
|
|
1104
|
-
`[tinycloud-mcp-http] tenant node host migrated: from=${
|
|
1107
|
+
`[tinycloud-mcp-http] tenant node host migrated: from=${profile.host.replace(/\/+$/, "")} to=${new URL(this.#config.nodeHost).origin}
|
|
1105
1108
|
`
|
|
1106
1109
|
);
|
|
1107
1110
|
}
|
|
@@ -1407,11 +1410,6 @@ function sessionFromCallback(data, privateJwk) {
|
|
|
1407
1410
|
signature: data.signature
|
|
1408
1411
|
};
|
|
1409
1412
|
}
|
|
1410
|
-
function publicJwk(jwk) {
|
|
1411
|
-
const copy = { ...jwk };
|
|
1412
|
-
for (const field of ["d", "p", "q", "dp", "dq", "qi", "oth", "k"]) delete copy[field];
|
|
1413
|
-
return copy;
|
|
1414
|
-
}
|
|
1415
1413
|
function samePrincipal(left, right) {
|
|
1416
1414
|
if (typeof left !== "string") return false;
|
|
1417
1415
|
try {
|
|
@@ -1424,6 +1422,7 @@ function normalizeDid(value) {
|
|
|
1424
1422
|
return value.split("#", 1)[0];
|
|
1425
1423
|
}
|
|
1426
1424
|
function sameNodeHost(left, right) {
|
|
1425
|
+
if (PRODUCTION_NODE_HOSTS.has(left) && (0, import_sdk_core.sameTinyCloudNode)(left, right)) return true;
|
|
1427
1426
|
try {
|
|
1428
1427
|
const normalize = (value) => {
|
|
1429
1428
|
const url = new URL(value);
|
|
@@ -1525,6 +1524,7 @@ var import_node_path2 = require("path");
|
|
|
1525
1524
|
var import_server2 = require("@modelcontextprotocol/server");
|
|
1526
1525
|
var import_ajv = require("@modelcontextprotocol/server/validators/ajv");
|
|
1527
1526
|
var import_operations2 = require("@tinycloud/operations");
|
|
1527
|
+
var import_tc_apps2 = require("@tinycloud/operations/tc-apps");
|
|
1528
1528
|
|
|
1529
1529
|
// src/results.ts
|
|
1530
1530
|
function toMcpToolResult(result, bindings = [], options = {}) {
|
|
@@ -1866,7 +1866,7 @@ var TOOL_BINDINGS = [
|
|
|
1866
1866
|
operationVersion: 1,
|
|
1867
1867
|
readOnlyHint: false,
|
|
1868
1868
|
idempotentHint: true,
|
|
1869
|
-
destructiveHint:
|
|
1869
|
+
destructiveHint: false,
|
|
1870
1870
|
openWorldHint: false,
|
|
1871
1871
|
surfaces: ["hosted", "public"]
|
|
1872
1872
|
},
|
|
@@ -1896,19 +1896,9 @@ var TOOL_BINDINGS = [
|
|
|
1896
1896
|
operationVersion: 1,
|
|
1897
1897
|
readOnlyHint: false,
|
|
1898
1898
|
idempotentHint: true,
|
|
1899
|
-
destructiveHint: true,
|
|
1900
|
-
openWorldHint: false,
|
|
1901
|
-
surfaces: ["hosted", "public"]
|
|
1902
|
-
},
|
|
1903
|
-
{
|
|
1904
|
-
name: "tinycloud_apps_move",
|
|
1905
|
-
operationId: "tinycloud.apps.move",
|
|
1906
|
-
operationVersion: 1,
|
|
1907
|
-
readOnlyHint: false,
|
|
1908
|
-
idempotentHint: true,
|
|
1909
1899
|
destructiveHint: false,
|
|
1910
1900
|
openWorldHint: false,
|
|
1911
|
-
surfaces: ["hosted"]
|
|
1901
|
+
surfaces: ["hosted", "public"]
|
|
1912
1902
|
}
|
|
1913
1903
|
];
|
|
1914
1904
|
var definitions = new Map(generatedCatalog.operations.map((operation) => [
|
|
@@ -1919,18 +1909,50 @@ var definitions = new Map(generatedCatalog.operations.map((operation) => [
|
|
|
1919
1909
|
result: toMcpJsonSchema(operation.result)
|
|
1920
1910
|
}
|
|
1921
1911
|
]));
|
|
1912
|
+
var CATALOG_APP_TOOLS = [
|
|
1913
|
+
"tinycloud_knowledge_list",
|
|
1914
|
+
"tinycloud_knowledge_read",
|
|
1915
|
+
"tinycloud_sql_query",
|
|
1916
|
+
"tinycloud_sql_execute"
|
|
1917
|
+
];
|
|
1918
|
+
var APP_WITHOUT_CATALOG_APPS = "Pass one existing personal app id to request its task access together.";
|
|
1919
|
+
function withPropertyDescription(schema, property, description) {
|
|
1920
|
+
const properties = schema.properties;
|
|
1921
|
+
const current = properties?.[property];
|
|
1922
|
+
if (current === void 0) throw new Error(`Generated operations catalog has no ${property} input to describe.`);
|
|
1923
|
+
return { ...schema, properties: { ...properties, [property]: { ...current, description } } };
|
|
1924
|
+
}
|
|
1925
|
+
function catalogAppRefusal(binding, profile, input) {
|
|
1926
|
+
const app = typeof input === "object" && input !== null ? input.app : void 0;
|
|
1927
|
+
if (typeof app !== "string" || !Object.hasOwn(import_tc_apps2.TC_APPS_CATALOG_APPS, app)) return void 0;
|
|
1928
|
+
const { title, link } = import_tc_apps2.TC_APPS_CATALOG_APPS[app];
|
|
1929
|
+
return {
|
|
1930
|
+
status: "error",
|
|
1931
|
+
operation: { operationId: binding.operationId, operationVersion: binding.operationVersion },
|
|
1932
|
+
context: { profile, host: "unresolved", posture: "unauthenticated" },
|
|
1933
|
+
error: {
|
|
1934
|
+
code: "INPUT_INVALID",
|
|
1935
|
+
message: `${title} is not available through this connector. Its page is ${link}. If the user asked for ${title}, tell them so and give them that link. For any other personal records, call tinycloud_apps_context without app.`,
|
|
1936
|
+
retryable: false,
|
|
1937
|
+
details: { reason: "catalog_app_unavailable", app, link }
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1922
1941
|
function createJsonSchemaValidator() {
|
|
1923
1942
|
return new import_ajv.AjvJsonSchemaValidator();
|
|
1924
1943
|
}
|
|
1925
1944
|
function registerTinyCloudTools(server, selection, validator) {
|
|
1926
1945
|
const bindings = TOOL_BINDINGS.filter((binding) => bindingSurfaces(binding).includes(selection.surface) && (selection.allowedTools === void 0 || selection.allowedTools.includes(binding.name)));
|
|
1946
|
+
const servesCatalogApps = CATALOG_APP_TOOLS.every((name) => bindings.some((binding) => binding.name === name));
|
|
1927
1947
|
for (const binding of bindings) {
|
|
1928
1948
|
const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);
|
|
1929
1949
|
if (operation === void 0) {
|
|
1930
1950
|
throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);
|
|
1931
1951
|
}
|
|
1952
|
+
const offersCatalogApps = servesCatalogApps || binding.operationId !== "tinycloud.apps.context";
|
|
1953
|
+
const inputJsonSchema = offersCatalogApps ? operation.input : withPropertyDescription(operation.input, "app", APP_WITHOUT_CATALOG_APPS);
|
|
1932
1954
|
const inputSchema = (0, import_server2.fromJsonSchema)(
|
|
1933
|
-
|
|
1955
|
+
inputJsonSchema,
|
|
1934
1956
|
validator
|
|
1935
1957
|
);
|
|
1936
1958
|
const outputSchema = (0, import_server2.fromJsonSchema)(
|
|
@@ -1957,19 +1979,22 @@ function registerTinyCloudTools(server, selection, validator) {
|
|
|
1957
1979
|
const metrics = { replayedGrants: 0 };
|
|
1958
1980
|
let code = "INTERNAL_ERROR";
|
|
1959
1981
|
try {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1982
|
+
let projected = offersCatalogApps ? void 0 : catalogAppRefusal(binding, selection.profile, input);
|
|
1983
|
+
if (projected === void 0) {
|
|
1984
|
+
await selection.beforeOperation?.();
|
|
1985
|
+
const result = await (0, import_operations2.invokeOperation)(
|
|
1986
|
+
binding.operationId,
|
|
1987
|
+
binding.operationVersion,
|
|
1988
|
+
invocationTargetForMcp(selection),
|
|
1989
|
+
input,
|
|
1990
|
+
metrics
|
|
1991
|
+
);
|
|
1992
|
+
projected = selection.transformOperationResult === void 0 ? result : await selection.transformOperationResult(result, {
|
|
1993
|
+
operationId: binding.operationId,
|
|
1994
|
+
operationVersion: binding.operationVersion,
|
|
1995
|
+
input
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1973
1998
|
const response = toMcpToolResult(projected, bindings, {
|
|
1974
1999
|
surface: selection.surface === "local" ? "local" : "hosted",
|
|
1975
2000
|
readOnly: binding.readOnlyHint,
|
|
@@ -2001,7 +2026,7 @@ function outcomeCode(result) {
|
|
|
2001
2026
|
// package.json
|
|
2002
2027
|
var package_default = {
|
|
2003
2028
|
name: "@tinycloud/mcp",
|
|
2004
|
-
version: "0.10.0-beta.
|
|
2029
|
+
version: "0.10.0-beta.50",
|
|
2005
2030
|
description: "TinyCloud delegated operations MCP server",
|
|
2006
2031
|
keywords: [
|
|
2007
2032
|
"tinycloud",
|
|
@@ -2072,9 +2097,10 @@ var package_default = {
|
|
|
2072
2097
|
dependencies: {
|
|
2073
2098
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
2074
2099
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
2075
|
-
"@tinycloud/node-sdk": "3.12.0-beta.
|
|
2076
|
-
"@tinycloud/
|
|
2077
|
-
"@tinycloud/
|
|
2100
|
+
"@tinycloud/node-sdk": "3.12.0-beta.38",
|
|
2101
|
+
"@tinycloud/sdk-core": "3.12.0-beta.37",
|
|
2102
|
+
"@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
|
|
2103
|
+
"@tinycloud/operations": "0.9.0-beta.45",
|
|
2078
2104
|
jose: "6.2.4"
|
|
2079
2105
|
},
|
|
2080
2106
|
devDependencies: {
|
|
@@ -2099,32 +2125,42 @@ var MCP_SERVER_NAME = "tinycloud-mcp";
|
|
|
2099
2125
|
// src/http.ts
|
|
2100
2126
|
var REQUIRED_SCOPE = "tinycloud:mcp";
|
|
2101
2127
|
var MCP_CORS_ALLOWED_HEADERS = "Authorization, Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID, Mcp-Method, Mcp-Name";
|
|
2128
|
+
var MCP_CORS_EXPOSED_HEADERS = "WWW-Authenticate, Mcp-Session-Id, Mcp-Protocol-Version";
|
|
2102
2129
|
var LOCAL_CLI_PACKAGE = ["@tinycloud", "cli"].join("/");
|
|
2103
2130
|
var LOCAL_MCP_PACKAGE = ["@tinycloud", "mcp"].join("/");
|
|
2131
|
+
var RESTRICTED_ADDRESS_PREFIXES = ["chatgpt", "claude", "grok", "muse"];
|
|
2104
2132
|
function createHostedMcpApp(config) {
|
|
2105
2133
|
if (config.nativeServiceCredential !== void 0 && Buffer.byteLength(config.nativeServiceCredential, "utf8") < 32) {
|
|
2106
2134
|
throw new Error("TC_MCP_NATIVE_SERVICE_CREDENTIAL must contain at least 32 bytes.");
|
|
2107
2135
|
}
|
|
2108
2136
|
const resourceUrl = canonicalResourceUrl(config.publicUrl);
|
|
2109
|
-
const pluginUrl = new URL("./chatgpt/mcp", resourceUrl);
|
|
2110
2137
|
const statusFor = (resource) => config.introspection === void 0 ? void 0 : createTokenStatusChecker({ ...config.introspection, resourceUrl: resource.toString() });
|
|
2111
2138
|
const hosted = createHostedSurface(config, resourceUrl, "hosted", statusFor(resourceUrl));
|
|
2112
|
-
const
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2139
|
+
const surfaces = [hosted];
|
|
2140
|
+
const restrictedByPath = /* @__PURE__ */ new Map();
|
|
2141
|
+
for (const prefix of RESTRICTED_ADDRESS_PREFIXES) {
|
|
2142
|
+
const restrictedUrl = new URL(`./${prefix}/mcp`, resourceUrl);
|
|
2143
|
+
const connectUrl = new URL("./connect", restrictedUrl);
|
|
2144
|
+
const restricted = createHostedSurface({
|
|
2145
|
+
...config,
|
|
2146
|
+
nativeServiceCredential: void 0,
|
|
2147
|
+
stateDir: (0, import_node_path3.join)(config.stateDir, prefix),
|
|
2148
|
+
approvalPath: connectUrl.pathname
|
|
2149
|
+
}, restrictedUrl, "public", statusFor(restrictedUrl));
|
|
2150
|
+
surfaces.push(restricted);
|
|
2151
|
+
for (const owned of [
|
|
2152
|
+
restrictedUrl,
|
|
2153
|
+
connectUrl,
|
|
2154
|
+
new URL("./connect/callback", restrictedUrl),
|
|
2155
|
+
new URL((0, import_server4.getOAuthProtectedResourceMetadataUrl)(restrictedUrl))
|
|
2156
|
+
]) {
|
|
2157
|
+
restrictedByPath.set(owned.pathname, restricted);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2124
2160
|
return {
|
|
2125
|
-
fetch: (request) => (
|
|
2161
|
+
fetch: (request) => (restrictedByPath.get(new URL(request.url).pathname) ?? hosted).fetch(request),
|
|
2126
2162
|
close: async () => {
|
|
2127
|
-
await Promise.all(
|
|
2163
|
+
await Promise.all(surfaces.map((surface) => surface.close()));
|
|
2128
2164
|
}
|
|
2129
2165
|
};
|
|
2130
2166
|
}
|
|
@@ -2396,10 +2432,12 @@ Local alternative: install \`${LOCAL_CLI_PACKAGE}\` and \`${LOCAL_MCP_PACKAGE}\`
|
|
|
2396
2432
|
try {
|
|
2397
2433
|
const destination = await store.approvalRedirect(requiredState(url));
|
|
2398
2434
|
return Response.redirect(destination, 302);
|
|
2399
|
-
} catch {
|
|
2435
|
+
} catch (error) {
|
|
2436
|
+
const reason = error instanceof ApprovalRequestError ? error.detail : "unknown";
|
|
2437
|
+
writeDiagnostic(`connect rejected: reason=${reason} path=${connectPath}`);
|
|
2400
2438
|
if (request.headers.get("accept")?.includes("text/html")) {
|
|
2401
2439
|
return new Response(
|
|
2402
|
-
'<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>TinyCloud approval unavailable</title><main><h1>This approval link is unavailable</h1><p>It may have expired or already been used.
|
|
2440
|
+
'<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>TinyCloud approval unavailable</title><main><h1>This approval link is unavailable</h1><p>It may have expired or already been used. Go back to the assistant that sent it and ask it to connect TinyCloud again.</p><p>If you declined access, no further approval is required. Never paste passwords, codes or approval links into support messages.</p></main></html>',
|
|
2403
2441
|
{
|
|
2404
2442
|
status: 400,
|
|
2405
2443
|
headers: {
|
|
@@ -2610,7 +2648,7 @@ function mcpCors(response, request) {
|
|
|
2610
2648
|
if (request.headers.has("origin")) {
|
|
2611
2649
|
headers.set("access-control-allow-origin", "*");
|
|
2612
2650
|
headers.set("access-control-allow-methods", "GET, POST, DELETE, OPTIONS");
|
|
2613
|
-
headers.set("access-control-expose-headers",
|
|
2651
|
+
headers.set("access-control-expose-headers", MCP_CORS_EXPOSED_HEADERS);
|
|
2614
2652
|
if (request.method === "OPTIONS") headers.set("access-control-allow-headers", MCP_CORS_ALLOWED_HEADERS);
|
|
2615
2653
|
}
|
|
2616
2654
|
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|