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