@topolo/mcp 0.11.2 → 0.11.3

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/index.ts
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
5
 
6
- // ../../../package-topolo-sdk-0.11.2/packages/topolo-sdk/dist/index.js
6
+ // ../../node_modules/.pnpm/@topolo+sdk@0.11.3/node_modules/@topolo/sdk/dist/index.js
7
7
  function applyAuthHeaders(headers, credential) {
8
8
  if (credential.kind === "api_key") {
9
9
  headers.set("X-Api-Key", credential.apiKey);
@@ -1978,6 +1978,7 @@ function mergeSignals(a, b) {
1978
1978
  function compactActionCatalogEntry(action) {
1979
1979
  const required = Array.isArray(action.inputSchema["required"]) ? action.inputSchema["required"].filter((value) => typeof value === "string") : [];
1980
1980
  const examples = action.agentContract?.examples ?? [];
1981
+ const example = compactExample(examples[0]?.input);
1981
1982
  return {
1982
1983
  actionId: action.actionId,
1983
1984
  title: action.title,
@@ -1989,13 +1990,75 @@ function compactActionCatalogEntry(action) {
1989
1990
  requiredPermission: action.requiredPermission,
1990
1991
  requiredInput: required,
1991
1992
  resourceType: action.agentContract?.resource?.kind ?? null,
1992
- exampleInput: examples[0]?.input ?? null,
1993
+ exampleInput: example.value,
1994
+ exampleInputAvailable: example.available,
1993
1995
  docsUrl: action.agentContract?.docsUrl ?? null
1994
1996
  };
1995
1997
  }
1998
+ function compactExample(input) {
1999
+ if (!input) return { value: null, available: false };
2000
+ const serialized = JSON.stringify(input);
2001
+ if (serialized.length > 512) return { value: null, available: true };
2002
+ return { value: input, available: true };
2003
+ }
1996
2004
  function compactActionValidation(actionId, validation) {
1997
2005
  return { actionId, valid: validation.valid, errors: validation.errors };
1998
2006
  }
2007
+ var ACTION_RESULT_MAX_DEPTH = 4;
2008
+ var ACTION_RESULT_MAX_KEYS = 16;
2009
+ var ACTION_RESULT_MAX_ITEMS = 5;
2010
+ var ACTION_RESULT_MAX_SCALARS = 120;
2011
+ var ACTION_RESULT_MAX_STRING = 512;
2012
+ function resultKeyPriority(key) {
2013
+ if (/^(id|requestId|status|state|url|slug|name|title|version)$/i.test(key)) return 0;
2014
+ if (/(Id|Ids|Url|Uri|Status|State|Count|Total|Version|CreatedAt|UpdatedAt)$/i.test(key)) return 1;
2015
+ return 2;
2016
+ }
2017
+ function compactResultValue(value, depth, budget) {
2018
+ if (value === null || typeof value === "boolean" || typeof value === "number") {
2019
+ budget.scalars += 1;
2020
+ return value;
2021
+ }
2022
+ if (typeof value === "string") {
2023
+ budget.scalars += 1;
2024
+ if (value.length <= ACTION_RESULT_MAX_STRING) return value;
2025
+ return `${value.slice(0, ACTION_RESULT_MAX_STRING)}\u2026 (${value.length} chars)`;
2026
+ }
2027
+ if (depth >= ACTION_RESULT_MAX_DEPTH || budget.scalars >= ACTION_RESULT_MAX_SCALARS) {
2028
+ return Array.isArray(value) ? { count: value.length, omitted: true } : { omitted: true };
2029
+ }
2030
+ if (Array.isArray(value)) {
2031
+ const items = value.slice(0, ACTION_RESULT_MAX_ITEMS).map((item) => compactResultValue(item, depth + 1, budget));
2032
+ return value.length > ACTION_RESULT_MAX_ITEMS ? { count: value.length, items, omittedItems: value.length - ACTION_RESULT_MAX_ITEMS } : items;
2033
+ }
2034
+ if (typeof value === "object") {
2035
+ const record = value;
2036
+ const allKeys = Object.keys(record);
2037
+ const keys = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right)).slice(0, ACTION_RESULT_MAX_KEYS);
2038
+ const compact = Object.fromEntries(keys.map((key) => [key, compactResultValue(record[key], depth + 1, budget)]));
2039
+ if (allKeys.length > keys.length) compact["_omittedKeys"] = allKeys.length - keys.length;
2040
+ return compact;
2041
+ }
2042
+ budget.scalars += 1;
2043
+ return String(value);
2044
+ }
2045
+ function compactActionResult(actionId, result) {
2046
+ let normalized = result;
2047
+ if (typeof result === "string") {
2048
+ try {
2049
+ normalized = JSON.parse(result);
2050
+ } catch {
2051
+ normalized = result;
2052
+ }
2053
+ }
2054
+ return { actionId, result: compactResultValue(normalized, 0, { scalars: 0 }) };
2055
+ }
2056
+ function preferExactActionMatches(actions, query) {
2057
+ const expected = query?.trim().toLowerCase();
2058
+ if (!expected) return actions;
2059
+ const exact = actions.filter((action) => [action.actionId, action.name, action.toolName].some((candidate) => candidate?.trim().toLowerCase() === expected));
2060
+ return exact.length ? exact : actions;
2061
+ }
1999
2062
  function compactActionPlan(plan) {
2000
2063
  return {
2001
2064
  actionId: plan.action.actionId,
@@ -2203,7 +2266,7 @@ function createTopolo(options) {
2203
2266
  };
2204
2267
  }
2205
2268
 
2206
- // ../../../package-topolo-sdk-0.11.2/packages/topolo-sdk/dist/node/credential-store.js
2269
+ // ../../node_modules/.pnpm/@topolo+sdk@0.11.3/node_modules/@topolo/sdk/dist/node/credential-store.js
2207
2270
  import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
2208
2271
  import { existsSync } from "fs";
2209
2272
  import { homedir, platform } from "os";
@@ -2984,7 +3047,8 @@ var TOOLS = [
2984
3047
  },
2985
3048
  query: { type: "string" },
2986
3049
  cursor: { type: "string" },
2987
- limit: { type: "integer", minimum: 1, maximum: 100, default: 25 }
3050
+ limit: { type: "integer", minimum: 1, maximum: 100, default: 25 },
3051
+ detail: { type: "boolean", description: "Return full schemas and agent contracts. Defaults to compact action guidance." }
2988
3052
  },
2989
3053
  required: ["service"],
2990
3054
  additionalProperties: false
@@ -2992,13 +3056,15 @@ var TOOLS = [
2992
3056
  handler: async (topolo, args) => {
2993
3057
  const service = typeof args["service"] === "string" ? args["service"].trim() : "";
2994
3058
  if (!service) throw new TopoloMcpPublicError("service is required for bounded action discovery.");
3059
+ const query = typeof args["query"] === "string" ? args["query"] : void 0;
2995
3060
  const result = await topolo.client.searchActions({
2996
3061
  service,
2997
- query: typeof args["query"] === "string" ? args["query"] : void 0,
3062
+ query,
2998
3063
  cursor: typeof args["cursor"] === "string" ? args["cursor"] : void 0,
2999
3064
  limit: typeof args["limit"] === "number" ? args["limit"] : void 0
3000
3065
  });
3001
- return args["detail"] === true ? result : { actions: result.actions.map(compactActionCatalogEntry), page: result.page };
3066
+ const actions = preferExactActionMatches(result.actions, query);
3067
+ return args["detail"] === true ? { ...result, actions } : { actions: actions.map(compactActionCatalogEntry), page: result.page };
3002
3068
  }
3003
3069
  },
3004
3070
  {
@@ -3086,7 +3152,8 @@ var TOOLS = [
3086
3152
  input: { type: "object", additionalProperties: true },
3087
3153
  resourceType: { type: "string", description: "Optional resource-scoping alias published in the app resource catalog (e.g. workspace, brand, merchant)." },
3088
3154
  resourceId: { type: "string", description: "Resource id. Required when resourceType is provided." },
3089
- confirm: { type: "boolean" }
3155
+ confirm: { type: "boolean" },
3156
+ detail: { type: "boolean", description: "Return the complete action response. Defaults to a bounded agent projection." }
3090
3157
  },
3091
3158
  required: ["actionId"],
3092
3159
  additionalProperties: false
@@ -3096,7 +3163,7 @@ var TOOLS = [
3096
3163
  if (!actionId) throw new TopoloMcpPublicError("actionId is required.");
3097
3164
  const input = coerceObjectParam(args["input"], "input");
3098
3165
  const resource = optionalResourceContext(args);
3099
- return topolo.client.callAction(
3166
+ const result = await topolo.client.callAction(
3100
3167
  actionId,
3101
3168
  input,
3102
3169
  {
@@ -3104,6 +3171,7 @@ var TOOLS = [
3104
3171
  ...resource ? { resource } : {}
3105
3172
  }
3106
3173
  );
3174
+ return args["detail"] === true ? result : compactActionResult(actionId, result);
3107
3175
  }
3108
3176
  },
3109
3177
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.11.2",
4
- "topoloPublishedVersion": "0.11.2",
3
+ "version": "0.11.3",
4
+ "topoloPublishedVersion": "0.11.3",
5
5
  "description": "Model Context Protocol server for the Topolo platform. Exposes scope-gated tools that third-party agents (Claude, Codex, etc.) can call natively.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "Topolo",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "^1.0.0",
38
- "@topolo/sdk": "0.11.2"
38
+ "@topolo/sdk": "0.11.3"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^20.12.0",