@ttoss/http-server-mcp 0.41.0 → 0.43.0

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/README.md CHANGED
@@ -484,13 +484,14 @@ registerTools({ server: fullServer, tools });
484
484
  registerTools({ server: deferredServer, tools, defer: true });
485
485
  ```
486
486
 
487
- A schema enters the model's context only for the tools it is about to use. `call` enforces the tool's schema as a direct call would, and its errors help the model recover: an unknown name answers suggestions (close typos first, then near-misses and tools sharing the name's words, by how much they share), and invalid arguments, a tool's own error result, or a thrown error carry the input schema, so a `call` made without `describe` corrects itself in one retry.
487
+ A schema enters the model's context only for the tools it is about to use. `call` enforces the tool's schema as a direct call would, and its errors help the model recover: an unknown name answers suggestions (close typos first, then near-misses and tools sharing the name's words, by how much they share), and invalid arguments carry the input schema, so a `call` made without `describe` corrects itself in one retry.
488
488
 
489
489
  Pass options instead of `true` to tune it:
490
490
 
491
491
  - `except` — tools kept standalone, not deferred; they stay reachable through `search` too. Defaults to those linked to an [MCP Apps](#mcp-apps-interactive-uis) view, since a host finds a view through the tool's own `tools/list` entry.
492
492
  - `visible` — runs on every `search`, `describe` and `call`; a tool it rejects is absent from all three. Standalone tools stay listed.
493
493
  - `search` — replaces the default ranking, `rankTools`, e.g. with embeddings.
494
+ - `schemaOnError` (default `'invalidArguments'`) — which failed calls carry the input schema. By default only arguments that fail it do: a tool's own error result or a thrown error is usually a refusal of the operation (a 404, a 409), and a large schema on every refusal costs more context than deferring saved. `'always'` attaches it to those too, for tools that do not validate their arguments and whose errors may be argument errors only the API detects.
494
495
  - `searchLimit` (default `10`), `searchMaxLimit` — the largest `limit` accepted (default `50`, or `searchLimit` when higher) — and `names` (default `search` / `describe` / `call`).
495
496
 
496
497
  A gate (below) sees each call with the tool's own name and arguments, so authorization stays per tool when deferred.
package/dist/index.cjs CHANGED
@@ -997,6 +997,7 @@ var deferredToolsOf = ({
997
997
  tools,
998
998
  searchLimit,
999
999
  searchMaxLimit: options.searchMaxLimit ?? Math.max(DEFAULT_SEARCH_MAX_LIMIT, searchLimit),
1000
+ schemaOnError: options.schemaOnError ?? "invalidArguments",
1000
1001
  searchTools: options.search ?? rankTools,
1001
1002
  visibleTools: () => {
1002
1003
  return tools.filter(isVisible);
@@ -1140,7 +1141,8 @@ var describeToolOf = ({
1140
1141
  /** Runs one tool the way a direct call would, with errors that help a retry. */
1141
1142
  var runTool = async ({
1142
1143
  tool,
1143
- args
1144
+ args,
1145
+ schemaOnError
1144
1146
  }) => {
1145
1147
  const schemas = resolveToolSchemas(tool);
1146
1148
  const validated = await schemas.input["~standard"].validate(args);
@@ -1152,24 +1154,24 @@ var runTool = async ({
1152
1154
  },
1153
1155
  isError: true
1154
1156
  });
1155
- const schemaHint = {
1157
+ const schemaHint = schemaOnError === "always" ? [{
1156
1158
  type: "text",
1157
1159
  text: JSON.stringify({
1158
1160
  inputSchema: schemas.inputJson
1159
1161
  })
1160
- };
1162
+ }] : [];
1161
1163
  try {
1162
1164
  const result = await tool.handler(validated.value);
1163
1165
  return result.isError ? {
1164
1166
  ...result,
1165
- content: [...result.content, schemaHint]
1167
+ content: [...result.content, ...schemaHint]
1166
1168
  } : result;
1167
1169
  } catch (error) {
1168
1170
  return {
1169
1171
  content: [{
1170
1172
  type: "text",
1171
1173
  text: errorMessageOf(error)
1172
- }, schemaHint],
1174
+ }, ...schemaHint],
1173
1175
  isError: true
1174
1176
  };
1175
1177
  }
@@ -1177,7 +1179,8 @@ var runTool = async ({
1177
1179
  var callToolOf = ({
1178
1180
  names,
1179
1181
  find,
1180
- visibleTools
1182
+ visibleTools,
1183
+ schemaOnError
1181
1184
  }) => {
1182
1185
  return {
1183
1186
  name: names.call,
@@ -1212,7 +1215,8 @@ var callToolOf = ({
1212
1215
  });
1213
1216
  return runTool({
1214
1217
  tool,
1215
- args: args.arguments ?? {}
1218
+ args: args.arguments ?? {},
1219
+ schemaOnError
1216
1220
  });
1217
1221
  }
1218
1222
  };
package/dist/index.d.cts CHANGED
@@ -861,6 +861,20 @@ interface DeferToolsOptions {
861
861
  * @default 50, or `searchLimit` when that is higher
862
862
  */
863
863
  searchMaxLimit?: number;
864
+ /**
865
+ * Which failed `call`s carry the tool's input schema.
866
+ *
867
+ * - `'invalidArguments'` — only arguments that fail the tool's schema, so a
868
+ * `call` made without `describe` corrects itself in one retry. A tool's
869
+ * own error result or a thrown error is usually a refusal of the
870
+ * operation (a 404, a 409), and a large schema on every refusal costs
871
+ * more context than deferring saved.
872
+ * - `'always'` — those carry it too. For tools that do not validate their
873
+ * arguments, whose errors may be argument errors only the API detects.
874
+ *
875
+ * @default 'invalidArguments'
876
+ */
877
+ schemaOnError?: 'always' | 'invalidArguments';
864
878
  /**
865
879
  * Runs on every `search`, `describe` and `call`. A tool it rejects is
866
880
  * absent from all three; `call` answers it as an unknown name. Tools
package/dist/index.d.mts CHANGED
@@ -862,6 +862,20 @@ interface DeferToolsOptions {
862
862
  * @default 50, or `searchLimit` when that is higher
863
863
  */
864
864
  searchMaxLimit?: number;
865
+ /**
866
+ * Which failed `call`s carry the tool's input schema.
867
+ *
868
+ * - `'invalidArguments'` — only arguments that fail the tool's schema, so a
869
+ * `call` made without `describe` corrects itself in one retry. A tool's
870
+ * own error result or a thrown error is usually a refusal of the
871
+ * operation (a 404, a 409), and a large schema on every refusal costs
872
+ * more context than deferring saved.
873
+ * - `'always'` — those carry it too. For tools that do not validate their
874
+ * arguments, whose errors may be argument errors only the API detects.
875
+ *
876
+ * @default 'invalidArguments'
877
+ */
878
+ schemaOnError?: 'always' | 'invalidArguments';
865
879
  /**
866
880
  * Runs on every `search`, `describe` and `call`. A tool it rejects is
867
881
  * absent from all three; `call` answers it as an unknown name. Tools
package/dist/index.mjs CHANGED
@@ -994,6 +994,7 @@ var deferredToolsOf = ({
994
994
  tools,
995
995
  searchLimit,
996
996
  searchMaxLimit: options.searchMaxLimit ?? Math.max(DEFAULT_SEARCH_MAX_LIMIT, searchLimit),
997
+ schemaOnError: options.schemaOnError ?? "invalidArguments",
997
998
  searchTools: options.search ?? rankTools,
998
999
  visibleTools: () => {
999
1000
  return tools.filter(isVisible);
@@ -1137,7 +1138,8 @@ var describeToolOf = ({
1137
1138
  /** Runs one tool the way a direct call would, with errors that help a retry. */
1138
1139
  var runTool = async ({
1139
1140
  tool,
1140
- args
1141
+ args,
1142
+ schemaOnError
1141
1143
  }) => {
1142
1144
  const schemas = resolveToolSchemas(tool);
1143
1145
  const validated = await schemas.input["~standard"].validate(args);
@@ -1149,24 +1151,24 @@ var runTool = async ({
1149
1151
  },
1150
1152
  isError: true
1151
1153
  });
1152
- const schemaHint = {
1154
+ const schemaHint = schemaOnError === "always" ? [{
1153
1155
  type: "text",
1154
1156
  text: JSON.stringify({
1155
1157
  inputSchema: schemas.inputJson
1156
1158
  })
1157
- };
1159
+ }] : [];
1158
1160
  try {
1159
1161
  const result = await tool.handler(validated.value);
1160
1162
  return result.isError ? {
1161
1163
  ...result,
1162
- content: [...result.content, schemaHint]
1164
+ content: [...result.content, ...schemaHint]
1163
1165
  } : result;
1164
1166
  } catch (error) {
1165
1167
  return {
1166
1168
  content: [{
1167
1169
  type: "text",
1168
1170
  text: errorMessageOf(error)
1169
- }, schemaHint],
1171
+ }, ...schemaHint],
1170
1172
  isError: true
1171
1173
  };
1172
1174
  }
@@ -1174,7 +1176,8 @@ var runTool = async ({
1174
1176
  var callToolOf = ({
1175
1177
  names,
1176
1178
  find,
1177
- visibleTools
1179
+ visibleTools,
1180
+ schemaOnError
1178
1181
  }) => {
1179
1182
  return {
1180
1183
  name: names.call,
@@ -1209,7 +1212,8 @@ var callToolOf = ({
1209
1212
  });
1210
1213
  return runTool({
1211
1214
  tool,
1212
- args: args.arguments ?? {}
1215
+ args: args.arguments ?? {},
1216
+ schemaOnError
1213
1217
  });
1214
1218
  }
1215
1219
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/http-server-mcp",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Model Context Protocol (MCP) server integration for @ttoss/http-server",
5
5
  "keywords": [
6
6
  "ai",
@@ -37,10 +37,10 @@
37
37
  "@modelcontextprotocol/node": "^2.1.1",
38
38
  "@modelcontextprotocol/server": "^2.3.1",
39
39
  "zod": "^4.6.7",
40
- "@ttoss/http-server": "^0.14.2",
41
- "@ttoss/http-server-auth": "^0.10.2",
42
- "@ttoss/auth-core": "^0.20.1",
43
- "@ttoss/i18n-core": "^0.9.2"
40
+ "@ttoss/auth-core": "^0.21.0",
41
+ "@ttoss/http-server": "^0.15.0",
42
+ "@ttoss/http-server-auth": "^0.11.0",
43
+ "@ttoss/i18n-core": "^0.10.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@modelcontextprotocol/client": "^2.3.1",
@@ -48,7 +48,7 @@
48
48
  "jest": "^30.5.2",
49
49
  "supertest": "^7.3.1",
50
50
  "tsdown": "^0.23.1",
51
- "@ttoss/config": "^3.0.0"
51
+ "@ttoss/config": "^4.0.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public",