@webpieces/mcp-server 0.4.772 → 0.4.773

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/README.md +31 -0
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -42,6 +42,37 @@ The `@WpMcpTool.description` becomes the tool description returned by `tools/lis
42
42
  response classes generate `inputSchema` and `outputSchema`; `@WpDtoField` supplies property
43
43
  descriptions and the facts TypeScript erases, such as optionality and array element types.
44
44
 
45
+ ### Typed maps
46
+
47
+ A `Record<string, V>` reflects as plain `Object`, so its value type must be declared — the same reason
48
+ `arrayItems` exists for arrays. Use `WpDtoMapFieldOptions(description, required, mapValues)`, where
49
+ `mapValues` is `'string' | 'number' | 'integer' | 'boolean'` or a `@WpDto` class:
50
+
51
+ ```ts
52
+ @WpDto()
53
+ class PassageSentenceItem {
54
+ @WpDtoField(new WpDtoFieldOptions('Sentence text', true))
55
+ text!: string;
56
+
57
+ @WpDtoField(new WpDtoMapFieldOptions('ISO 639-1 -> sentence', false, 'string'))
58
+ translations?: Record<string, string>;
59
+ }
60
+
61
+ @WpDto()
62
+ class PassageResponse {
63
+ @WpDtoField(new WpDtoMapFieldOptions('Sentences by locale', true, PassageSentenceItem))
64
+ sentencesByLocale!: Record<string, PassageSentenceItem>;
65
+ }
66
+ ```
67
+
68
+ The field emits `{ type: 'object', additionalProperties: <value schema> }`, and validation checks every
69
+ value (`$.translations.es must be string`). An `Object`-typed field without map options — an interface or
70
+ an undeclared `Record` — fails at startup, because an interface can never carry `@WpDto`.
71
+
72
+ A map is still a closed schema: no key can carry an unspecified value. Check closure with
73
+ `new DtoSchemaBuilder().isClosedSchema(schema)`, not `schema.additionalProperties === false`, which wrongly
74
+ rejects typed maps.
75
+
45
76
  Applications construct `WpMcpServer` with their built `ApiFactory`, the API classes they want scanned,
46
77
  a paired `McpAccessTokenAuthority`, and their application `JwtHook`. The authority verifies issuer,
47
78
  signature/token state, expiry, scopes, the exact resource URI, and current account state on every MCP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/mcp-server",
3
- "version": "0.4.772",
3
+ "version": "0.4.773",
4
4
  "description": "Secure MCP tool generation from annotated Webpieces API contracts",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "1.29.0",
26
- "@webpieces/core-context": "0.4.772",
27
- "@webpieces/core-util": "0.4.772",
28
- "@webpieces/http-routing": "0.4.772",
26
+ "@webpieces/core-context": "0.4.773",
27
+ "@webpieces/core-util": "0.4.773",
28
+ "@webpieces/http-routing": "0.4.773",
29
29
  "reflect-metadata": "0.2.2",
30
30
  "tslib": "2.8.1"
31
31
  }