@emseepea/server 0.2.0 → 0.2.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/README.md +31 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -332,16 +332,33 @@ Use `defineTool` instead when the backend already accepts the public input and
332
332
  returns the public output. `defineMappedTool` is for a real contract boundary,
333
333
  not an identity mapping.
334
334
 
335
+ Preserve useful backend concepts and values by default. Select public-safe
336
+ fields explicitly and validate the public and backend boundaries separately,
337
+ but do not maintain a second list of values just to rename it. Map values only
338
+ for transport compatibility, security, redaction, aggregation, or genuine model
339
+ comprehension.
340
+
341
+ Prefer an open, bounded schema when the backend can add valid values
342
+ independently.
343
+
335
344
  ```ts
336
- const backendCommand = z.object({ search: z.string() });
345
+ const backendCommand = z.object({ search: z.string().max(200) });
346
+ const catalogueBean = z.object({
347
+ name: z.string().max(200),
348
+ country: z.string().max(100),
349
+ variety: z.string().max(100),
350
+ process: z.string().max(100),
351
+ roast: z.string().max(40),
352
+ tastingNotes: z.array(z.string().max(100)).max(20),
353
+ });
337
354
  const backendResult = z.object({
338
355
  record: z.object({
339
- name: z.string(),
340
- country: z.string(),
341
- variety: z.string(),
342
- processCode: z.enum(["W", "N"]),
343
- roastLevel: z.enum(["light", "medium", "dark"]),
344
- flavourNotes: z.array(z.string()),
356
+ name: z.string().max(200),
357
+ country: z.string().max(100),
358
+ variety: z.string().max(100),
359
+ process: z.string().max(100),
360
+ roast: z.string().max(40),
361
+ tastingNotes: z.array(z.string().max(100)).max(20),
345
362
  }),
346
363
  });
347
364
 
@@ -349,8 +366,8 @@ const getBeanDetails = defineMappedTool({
349
366
  name: "get-bean-details",
350
367
  access: "public",
351
368
  description: "Get clear coffee details from the catalogue service.",
352
- inputSchema: z.object({ name: z.string() }),
353
- outputSchema: beanDetails,
369
+ inputSchema: z.object({ name: z.string().max(200) }),
370
+ outputSchema: catalogueBean,
354
371
  backendInputSchema: backendCommand,
355
372
  backendOutputSchema: backendResult,
356
373
  mapInput: ({ name }) => ({ search: name }),
@@ -358,13 +375,13 @@ const getBeanDetails = defineMappedTool({
358
375
  mapOutput: ({ record }) => {
359
376
  const data = {
360
377
  name: record.name,
361
- origin: record.country,
378
+ country: record.country,
362
379
  variety: record.variety,
363
- process: record.processCode === "W" ? "washed" as const : "natural" as const,
364
- roast: record.roastLevel,
365
- tastingNotes: record.flavourNotes,
380
+ process: record.process,
381
+ roast: record.roast,
382
+ tastingNotes: record.tastingNotes,
366
383
  };
367
- return { text: `${data.name} is a ${data.roast}-roast ${data.process} coffee from ${data.origin}.`, data };
384
+ return { text: `${data.name} is a ${data.roast}-roast ${data.process} coffee from ${data.country}.`, data };
368
385
  },
369
386
  });
370
387
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emseepea/server",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Fastify-first framework for Model Context Protocol 2026-07-28 servers over Streamable HTTP",
5
5
  "license": "MIT",
6
6
  "repository": {