@topolo/mcp 0.11.3 → 0.11.5

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.
Files changed (3) hide show
  1. package/dist/http.js +667 -220
  2. package/dist/index.js +33 -11
  3. package/package.json +3 -3
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
- // ../../node_modules/.pnpm/@topolo+sdk@0.11.3/node_modules/@topolo/sdk/dist/index.js
6
+ // 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);
@@ -66,6 +66,7 @@ var PUBLIC_ERROR_CODES = /* @__PURE__ */ new Set([
66
66
  "permission_denied",
67
67
  "rate_limited",
68
68
  "request_failed",
69
+ "request_timeout",
69
70
  "service_catalog_unavailable",
70
71
  "service_path_origin_mismatch",
71
72
  "service_required",
@@ -914,7 +915,7 @@ var TopoloClient = class _TopoloClient {
914
915
  this.serviceUrls = options.environment ? topoloServiceOrigins(options.serviceUrls, options.environment) : options.serviceUrls;
915
916
  this.appIds = options.appIds;
916
917
  this.requireConfirmForWrites = options.requireConfirmForWrites !== false;
917
- this.timeoutMs = options.timeoutMs ?? 3e4;
918
+ this.timeoutMs = options.timeoutMs ?? 12e4;
918
919
  this.fetchImpl = options.fetch ?? fetch;
919
920
  this.credentialProvider = options.credentialProvider;
920
921
  this.refreshCredential = options.refreshCredential;
@@ -985,7 +986,11 @@ var TopoloClient = class _TopoloClient {
985
986
  this.emit({ phase: "request", method, service: resolvedService.serviceKey, path: opts.path, url: urlStr, requestId });
986
987
  const fetchOnce = async () => {
987
988
  const controller = new AbortController();
988
- const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
989
+ let timedOut = false;
990
+ const timeoutId = setTimeout(() => {
991
+ timedOut = true;
992
+ controller.abort();
993
+ }, this.timeoutMs);
989
994
  const signal = opts.signal ? mergeSignals(opts.signal, controller.signal) : controller.signal;
990
995
  try {
991
996
  return await this.fetchImpl(urlStr, {
@@ -994,6 +999,14 @@ var TopoloClient = class _TopoloClient {
994
999
  body: opts.rawBody ?? (opts.body !== void 0 ? JSON.stringify(opts.body) : null),
995
1000
  signal
996
1001
  });
1002
+ } catch (error) {
1003
+ if (timedOut) {
1004
+ throw new TopoloSdkError(
1005
+ "request_timeout",
1006
+ `Topolo request timed out after ${this.timeoutMs}ms. Verify current state before retrying a mutation.`
1007
+ );
1008
+ }
1009
+ throw error;
997
1010
  } finally {
998
1011
  clearTimeout(timeoutId);
999
1012
  }
@@ -1019,7 +1032,7 @@ var TopoloClient = class _TopoloClient {
1019
1032
  url: urlStr,
1020
1033
  requestId,
1021
1034
  durationMs: Date.now() - startedAt,
1022
- error: "network_error"
1035
+ error: err instanceof TopoloSdkError ? err.code : "network_error"
1023
1036
  });
1024
1037
  throw err;
1025
1038
  }
@@ -2004,11 +2017,12 @@ function compactExample(input) {
2004
2017
  function compactActionValidation(actionId, validation) {
2005
2018
  return { actionId, valid: validation.valid, errors: validation.errors };
2006
2019
  }
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;
2020
+ var ACTION_RESULT_MAX_DEPTH = 3;
2021
+ var ACTION_RESULT_MAX_KEYS = 12;
2022
+ var ACTION_RESULT_MAX_ORDINARY_KEYS = 5;
2023
+ var ACTION_RESULT_MAX_ITEMS = 3;
2024
+ var ACTION_RESULT_MAX_SCALARS = 60;
2025
+ var ACTION_RESULT_MAX_STRING = 256;
2012
2026
  function resultKeyPriority(key) {
2013
2027
  if (/^(id|requestId|status|state|url|slug|name|title|version)$/i.test(key)) return 0;
2014
2028
  if (/(Id|Ids|Url|Uri|Status|State|Count|Total|Version|CreatedAt|UpdatedAt)$/i.test(key)) return 1;
@@ -2034,7 +2048,14 @@ function compactResultValue(value, depth, budget) {
2034
2048
  if (typeof value === "object") {
2035
2049
  const record = value;
2036
2050
  const allKeys = Object.keys(record);
2037
- const keys = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right)).slice(0, ACTION_RESULT_MAX_KEYS);
2051
+ const ranked = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right));
2052
+ const prioritized = ranked.filter((key) => resultKeyPriority(key) < 2);
2053
+ const ordinary = ranked.filter((key) => resultKeyPriority(key) === 2);
2054
+ const ordinaryLimit = depth === 0 ? ACTION_RESULT_MAX_ORDINARY_KEYS : prioritized.length ? 1 : ACTION_RESULT_MAX_ORDINARY_KEYS;
2055
+ const keys = [
2056
+ ...prioritized,
2057
+ ...ordinary.slice(0, ordinaryLimit)
2058
+ ].slice(0, ACTION_RESULT_MAX_KEYS);
2038
2059
  const compact = Object.fromEntries(keys.map((key) => [key, compactResultValue(record[key], depth + 1, budget)]));
2039
2060
  if (allKeys.length > keys.length) compact["_omittedKeys"] = allKeys.length - keys.length;
2040
2061
  return compact;
@@ -2266,7 +2287,7 @@ function createTopolo(options) {
2266
2287
  };
2267
2288
  }
2268
2289
 
2269
- // ../../node_modules/.pnpm/@topolo+sdk@0.11.3/node_modules/@topolo/sdk/dist/node/credential-store.js
2290
+ // node_modules/@topolo/sdk/dist/node/credential-store.js
2270
2291
  import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
2271
2292
  import { existsSync } from "fs";
2272
2293
  import { homedir, platform } from "os";
@@ -2315,6 +2336,7 @@ var PUBLIC_ERROR_CODES2 = /* @__PURE__ */ new Set([
2315
2336
  "permission_denied",
2316
2337
  "rate_limited",
2317
2338
  "request_failed",
2339
+ "request_timeout",
2318
2340
  "service_catalog_unavailable",
2319
2341
  "service_path_origin_mismatch",
2320
2342
  "service_required",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.11.3",
4
- "topoloPublishedVersion": "0.11.3",
3
+ "version": "0.11.5",
4
+ "topoloPublishedVersion": "0.11.5",
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.3"
38
+ "@topolo/sdk": "0.11.5"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^20.12.0",