@tinycloud/mcp 0.10.0-beta.49 → 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/dist/http.cjs CHANGED
@@ -1507,6 +1507,7 @@ var import_node_path2 = require("path");
1507
1507
  var import_server2 = require("@modelcontextprotocol/server");
1508
1508
  var import_ajv = require("@modelcontextprotocol/server/validators/ajv");
1509
1509
  var import_operations2 = require("@tinycloud/operations");
1510
+ var import_tc_apps2 = require("@tinycloud/operations/tc-apps");
1510
1511
 
1511
1512
  // src/results.ts
1512
1513
  function toMcpToolResult(result, bindings = [], options = {}) {
@@ -1891,18 +1892,50 @@ var definitions = new Map(generatedCatalog.operations.map((operation) => [
1891
1892
  result: toMcpJsonSchema(operation.result)
1892
1893
  }
1893
1894
  ]));
1895
+ var CATALOG_APP_TOOLS = [
1896
+ "tinycloud_knowledge_list",
1897
+ "tinycloud_knowledge_read",
1898
+ "tinycloud_sql_query",
1899
+ "tinycloud_sql_execute"
1900
+ ];
1901
+ var APP_WITHOUT_CATALOG_APPS = "Pass one existing personal app id to request its task access together.";
1902
+ function withPropertyDescription(schema, property, description) {
1903
+ const properties = schema.properties;
1904
+ const current = properties?.[property];
1905
+ if (current === void 0) throw new Error(`Generated operations catalog has no ${property} input to describe.`);
1906
+ return { ...schema, properties: { ...properties, [property]: { ...current, description } } };
1907
+ }
1908
+ function catalogAppRefusal(binding, profile, input) {
1909
+ const app = typeof input === "object" && input !== null ? input.app : void 0;
1910
+ if (typeof app !== "string" || !Object.hasOwn(import_tc_apps2.TC_APPS_CATALOG_APPS, app)) return void 0;
1911
+ const { title, link } = import_tc_apps2.TC_APPS_CATALOG_APPS[app];
1912
+ return {
1913
+ status: "error",
1914
+ operation: { operationId: binding.operationId, operationVersion: binding.operationVersion },
1915
+ context: { profile, host: "unresolved", posture: "unauthenticated" },
1916
+ error: {
1917
+ code: "INPUT_INVALID",
1918
+ 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.`,
1919
+ retryable: false,
1920
+ details: { reason: "catalog_app_unavailable", app, link }
1921
+ }
1922
+ };
1923
+ }
1894
1924
  function createJsonSchemaValidator() {
1895
1925
  return new import_ajv.AjvJsonSchemaValidator();
1896
1926
  }
1897
1927
  function registerTinyCloudTools(server, selection, validator) {
1898
1928
  const bindings = TOOL_BINDINGS.filter((binding) => bindingSurfaces(binding).includes(selection.surface) && (selection.allowedTools === void 0 || selection.allowedTools.includes(binding.name)));
1929
+ const servesCatalogApps = CATALOG_APP_TOOLS.every((name) => bindings.some((binding) => binding.name === name));
1899
1930
  for (const binding of bindings) {
1900
1931
  const operation = definitions.get(`${binding.operationId}@${binding.operationVersion}`);
1901
1932
  if (operation === void 0) {
1902
1933
  throw new Error(`Generated operations catalog is missing ${binding.operationId}@${binding.operationVersion}.`);
1903
1934
  }
1935
+ const offersCatalogApps = servesCatalogApps || binding.operationId !== "tinycloud.apps.context";
1936
+ const inputJsonSchema = offersCatalogApps ? operation.input : withPropertyDescription(operation.input, "app", APP_WITHOUT_CATALOG_APPS);
1904
1937
  const inputSchema = (0, import_server2.fromJsonSchema)(
1905
- operation.input,
1938
+ inputJsonSchema,
1906
1939
  validator
1907
1940
  );
1908
1941
  const outputSchema = (0, import_server2.fromJsonSchema)(
@@ -1929,19 +1962,22 @@ function registerTinyCloudTools(server, selection, validator) {
1929
1962
  const metrics = { replayedGrants: 0 };
1930
1963
  let code = "INTERNAL_ERROR";
1931
1964
  try {
1932
- await selection.beforeOperation?.();
1933
- const result = await (0, import_operations2.invokeOperation)(
1934
- binding.operationId,
1935
- binding.operationVersion,
1936
- invocationTargetForMcp(selection),
1937
- input,
1938
- metrics
1939
- );
1940
- const projected = selection.transformOperationResult === void 0 ? result : await selection.transformOperationResult(result, {
1941
- operationId: binding.operationId,
1942
- operationVersion: binding.operationVersion,
1943
- input
1944
- });
1965
+ let projected = offersCatalogApps ? void 0 : catalogAppRefusal(binding, selection.profile, input);
1966
+ if (projected === void 0) {
1967
+ await selection.beforeOperation?.();
1968
+ const result = await (0, import_operations2.invokeOperation)(
1969
+ binding.operationId,
1970
+ binding.operationVersion,
1971
+ invocationTargetForMcp(selection),
1972
+ input,
1973
+ metrics
1974
+ );
1975
+ projected = selection.transformOperationResult === void 0 ? result : await selection.transformOperationResult(result, {
1976
+ operationId: binding.operationId,
1977
+ operationVersion: binding.operationVersion,
1978
+ input
1979
+ });
1980
+ }
1945
1981
  const response = toMcpToolResult(projected, bindings, {
1946
1982
  surface: selection.surface === "local" ? "local" : "hosted",
1947
1983
  readOnly: binding.readOnlyHint,
@@ -1973,7 +2009,7 @@ function outcomeCode(result) {
1973
2009
  // package.json
1974
2010
  var package_default = {
1975
2011
  name: "@tinycloud/mcp",
1976
- version: "0.10.0-beta.49",
2012
+ version: "0.10.0-beta.50",
1977
2013
  description: "TinyCloud delegated operations MCP server",
1978
2014
  keywords: [
1979
2015
  "tinycloud",
@@ -2047,7 +2083,7 @@ var package_default = {
2047
2083
  "@tinycloud/node-sdk": "3.12.0-beta.38",
2048
2084
  "@tinycloud/sdk-core": "3.12.0-beta.37",
2049
2085
  "@tinycloud/node-sdk-wasm": "1.7.9-beta.0",
2050
- "@tinycloud/operations": "0.9.0-beta.44",
2086
+ "@tinycloud/operations": "0.9.0-beta.45",
2051
2087
  jose: "6.2.4"
2052
2088
  },
2053
2089
  devDependencies: {