@ttoss/http-server-mcp 0.39.1 → 0.40.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
@@ -781,6 +781,8 @@ Registers `Tool`s on an MCP server. See [Tools](#tools).
781
781
 
782
782
  By default, a JSON Schema `inputSchema` is **advertised but not enforced**: it round-trips verbatim over `tools/list` so clients know what to send, while arguments reach your handler unchecked. Set `validateArguments: true` to reject mismatched calls before the handler runs.
783
783
 
784
+ A schema with `additionalProperties: false` refuses every argument it does not declare, and names each one (`prefix: is not an argument of this tool`), so a misspelled argument is an error the caller can fix rather than one dropped unseen.
785
+
784
786
  Enable it once you're confident `inputSchema` describes every value the tool genuinely accepts. Schemas derived from an OpenAPI document are a common source of _incomplete_ ones — a field a client may send as `null` to clear it, or one that accepts several shapes, is easily emitted as a bare `{ type: 'string' }`. Validating against a schema like that rejects calls the underlying API would have accepted. To describe those cases accurately, use `{ type: ['string', 'null'] }` for a nullable field and forward `oneOf`/`anyOf` verbatim rather than collapsing to one type.
785
787
 
786
788
  ### `defineTool(params)`
package/dist/index.cjs CHANGED
@@ -520,6 +520,50 @@ var isStandardSchema = schema => {
520
520
  return "~standard" in schema;
521
521
  };
522
522
  /**
523
+ * Enforces a closed schema while naming each undeclared argument. The SDK's
524
+ * own `additionalProperties: false` issue carries no path, so the argument to
525
+ * drop goes unnamed; the rest of the schema is checked with it left open.
526
+ */
527
+ var namingUndeclared = ({
528
+ schema,
529
+ standard
530
+ }) => {
531
+ const {
532
+ additionalProperties: _closed,
533
+ ...openSchema
534
+ } = schema;
535
+ const open = (0, _modelcontextprotocol_server.fromJsonSchema)(openSchema);
536
+ const declared = new Set(Object.keys(schema.properties ?? {}));
537
+ const withUndeclared = ({
538
+ value,
539
+ result
540
+ }) => {
541
+ const undeclared = Object.keys(Object(value)).filter(key => {
542
+ return !declared.has(key);
543
+ });
544
+ if (undeclared.length === 0) return result;
545
+ return {
546
+ issues: [...undeclared.map(key => {
547
+ return {
548
+ message: "is not an argument of this tool",
549
+ path: [key]
550
+ };
551
+ }), ...(result.issues ?? [])]
552
+ };
553
+ };
554
+ return {
555
+ "~standard": {
556
+ ...standard["~standard"],
557
+ validate: async value => {
558
+ return withUndeclared({
559
+ value,
560
+ result: await open["~standard"].validate(value)
561
+ });
562
+ }
563
+ }
564
+ };
565
+ };
566
+ /**
523
567
  * Converts a JSON Schema into the Standard Schema `registerTool` accepts.
524
568
  *
525
569
  * A Standard Schema keeps advertisement and enforcement in separate fields:
@@ -532,6 +576,10 @@ var fromJsonObjectSchema = ({
532
576
  validate
533
577
  }) => {
534
578
  const standard = (0, _modelcontextprotocol_server.fromJsonSchema)(schema);
579
+ if (validate && schema.additionalProperties === false) return namingUndeclared({
580
+ schema,
581
+ standard
582
+ });
535
583
  if (validate) return standard;
536
584
  return {
537
585
  "~standard": {
package/dist/index.mjs CHANGED
@@ -517,6 +517,50 @@ var isStandardSchema = schema => {
517
517
  return "~standard" in schema;
518
518
  };
519
519
  /**
520
+ * Enforces a closed schema while naming each undeclared argument. The SDK's
521
+ * own `additionalProperties: false` issue carries no path, so the argument to
522
+ * drop goes unnamed; the rest of the schema is checked with it left open.
523
+ */
524
+ var namingUndeclared = ({
525
+ schema,
526
+ standard
527
+ }) => {
528
+ const {
529
+ additionalProperties: _closed,
530
+ ...openSchema
531
+ } = schema;
532
+ const open = fromJsonSchema(openSchema);
533
+ const declared = new Set(Object.keys(schema.properties ?? {}));
534
+ const withUndeclared = ({
535
+ value,
536
+ result
537
+ }) => {
538
+ const undeclared = Object.keys(Object(value)).filter(key => {
539
+ return !declared.has(key);
540
+ });
541
+ if (undeclared.length === 0) return result;
542
+ return {
543
+ issues: [...undeclared.map(key => {
544
+ return {
545
+ message: "is not an argument of this tool",
546
+ path: [key]
547
+ };
548
+ }), ...(result.issues ?? [])]
549
+ };
550
+ };
551
+ return {
552
+ "~standard": {
553
+ ...standard["~standard"],
554
+ validate: async value => {
555
+ return withUndeclared({
556
+ value,
557
+ result: await open["~standard"].validate(value)
558
+ });
559
+ }
560
+ }
561
+ };
562
+ };
563
+ /**
520
564
  * Converts a JSON Schema into the Standard Schema `registerTool` accepts.
521
565
  *
522
566
  * A Standard Schema keeps advertisement and enforcement in separate fields:
@@ -529,6 +573,10 @@ var fromJsonObjectSchema = ({
529
573
  validate
530
574
  }) => {
531
575
  const standard = fromJsonSchema(schema);
576
+ if (validate && schema.additionalProperties === false) return namingUndeclared({
577
+ schema,
578
+ standard
579
+ });
532
580
  if (validate) return standard;
533
581
  return {
534
582
  "~standard": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/http-server-mcp",
3
- "version": "0.39.1",
3
+ "version": "0.40.0",
4
4
  "description": "Model Context Protocol (MCP) server integration for @ttoss/http-server",
5
5
  "keywords": [
6
6
  "ai",
@@ -37,9 +37,9 @@
37
37
  "@modelcontextprotocol/node": "^2.1.1",
38
38
  "@modelcontextprotocol/server": "^2.3.1",
39
39
  "zod": "^4.6.7",
40
- "@ttoss/http-server-auth": "^0.10.2",
41
40
  "@ttoss/auth-core": "^0.20.1",
42
41
  "@ttoss/http-server": "^0.14.2",
42
+ "@ttoss/http-server-auth": "^0.10.2",
43
43
  "@ttoss/i18n-core": "^0.9.2"
44
44
  },
45
45
  "devDependencies": {