@trainheroic-unofficial/coach-mcp 1.7.0 → 1.7.1

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 (2) hide show
  1. package/dist/server.mjs +19 -11
  2. package/package.json +3 -3
package/dist/server.mjs CHANGED
@@ -365,6 +365,23 @@ const DEFAULT_RESULT_BUDGET = 6e4;
365
365
  const MARKER_RESERVE = 300;
366
366
  const DEFAULT_ARRAY_HINT = "Result was truncated to fit the size budget. Narrow it with a filter/search argument or paginate to see the rest.";
367
367
  const DEFAULT_OBJECT_HINT = "Result was truncated to fit the size budget. Request a more specific id or sub-resource.";
368
+ /**
369
+ * Clip an array to its first `keep` items and attach the `__truncated` marker describing what was
370
+ * dropped. The marker is model-facing (tools instruct the model to key off `__truncated`), so its
371
+ * shape has exactly one definition here: the size-budget path (`boundedSerialize`) and any tool
372
+ * that deliberately caps a list (e.g. `athlete_exercises`) emit the same thing.
373
+ */
374
+ function clipArray(items, keep, hint) {
375
+ return {
376
+ items: items.slice(0, keep),
377
+ __truncated: {
378
+ returned: keep,
379
+ total: items.length,
380
+ omitted: items.length - keep,
381
+ hint: hint ?? DEFAULT_ARRAY_HINT
382
+ }
383
+ };
384
+ }
368
385
  /** Active budget. Overridable via TH_MCP_RESULT_BUDGET on Node; the default on workerd. */
369
386
  function resultBudget() {
370
387
  const raw = (globalThis.process?.env)?.TH_MCP_RESULT_BUDGET;
@@ -421,16 +438,7 @@ function boundedSerialize(data, budget, hint) {
421
438
  }
422
439
  if (Array.isArray(data)) {
423
440
  const k = largestPrefixCount(data.map((el) => JSON.stringify(el) ?? "null"), budget - MARKER_RESERVE);
424
- const wrapped = {
425
- items: data.slice(0, k),
426
- __truncated: {
427
- returned: k,
428
- total: data.length,
429
- omitted: data.length - k,
430
- hint: hint ?? DEFAULT_ARRAY_HINT
431
- }
432
- };
433
- const out = JSON.stringify(wrapped);
441
+ const out = JSON.stringify(clipArray(data, k, hint));
434
442
  if (out.length <= budget) return out;
435
443
  } else if (isPlainObject(data)) {
436
444
  const key = largestArrayValuedKey(data);
@@ -3729,7 +3737,7 @@ var JsonFileLibraryCache = class {
3729
3737
  };
3730
3738
  //#endregion
3731
3739
  //#region package.json
3732
- var version = "1.7.0";
3740
+ var version = "1.7.1";
3733
3741
  //#endregion
3734
3742
  //#region src/server.ts
3735
3743
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/coach-mcp",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/sdk": "^1.29.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/js": "1.7.0",
25
- "@trainheroic-unofficial/core": "1.7.0"
24
+ "@trainheroic-unofficial/core": "1.7.1",
25
+ "@trainheroic-unofficial/js": "1.7.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.0.1",