@emseepea/server 0.3.0 → 0.3.2

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 +45 -34
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,19 +19,24 @@ package supports and what it does not support.
19
19
  import { createEmseepea, defineMappedTool, defineTool, serveEmseepea } from "@emseepea/server";
20
20
  import { z } from "zod";
21
21
 
22
- const peaVariety = z.object({
23
- name: z.string(),
24
- peaType: z.enum(["shelling", "snap"]),
25
- growthHabit: z.enum(["bush", "climbing"]),
26
- daysToMaturity: z.number().int().positive(),
22
+ const outputSchema = z.object({
23
+ name: z.string().describe("Name of the pea variety."),
24
+ peaType: z.enum(["shelling", "snap"])
25
+ .describe("Whether the variety is grown for shelled peas or edible pods."),
26
+ growthHabit: z.enum(["bush", "climbing"])
27
+ .describe("Whether the plant grows as a bush or climbing vine."),
28
+ daysToMaturity: z.number().int().positive()
29
+ .describe("Approximate days from sowing until the first harvest."),
27
30
  });
28
31
 
29
32
  const getPeaVariety = defineTool({
30
33
  name: "get-pea-variety",
31
34
  access: "public",
32
35
  description: "Get the type, growth habit, and maturity time for one pea variety.",
33
- inputSchema: z.object({ name: z.string() }),
34
- outputSchema: peaVariety,
36
+ inputSchema: z.object({
37
+ name: z.string().describe("Pea variety to look up."),
38
+ }),
39
+ outputSchema,
35
40
  handler: ({ name }) => {
36
41
  const data = {
37
42
  name,
@@ -47,6 +52,9 @@ const app = createEmseepea({ name: "pea-guide", version: "1.0.0", tools: [getPea
47
52
  await serveEmseepea(app);
48
53
  ```
49
54
 
55
+ Describe each public input and output property in terms useful to a model. Em
56
+ See Pea includes Zod `.describe()` text in the MCP tool schema sent to clients.
57
+
50
58
  ## Discover Capability Modules at Startup
51
59
 
52
60
  Explicit registration still works. If you prefer one file per capability, put
@@ -84,8 +92,12 @@ export default (() => defineTool({
84
92
  name: "get-pea-variety",
85
93
  access: "public",
86
94
  description: "Get one pea variety.",
87
- inputSchema: z.object({ name: z.string() }),
88
- outputSchema: z.object({ name: z.string() }),
95
+ inputSchema: z.object({
96
+ name: z.string().describe("Pea variety to look up."),
97
+ }),
98
+ outputSchema: z.object({
99
+ name: z.string().describe("Name of the pea variety."),
100
+ }),
89
101
  handler: ({ name }) => ({ text: name, data: { name } }),
90
102
  })) satisfies CapabilityModuleFactory;
91
103
  ```
@@ -241,7 +253,7 @@ const getPeaVariety = defineTool({
241
253
  icons: [{ src: "https://garden.example/icons/pea.png", mimeType: "image/png" }],
242
254
  annotations: { readOnlyHint: true, openWorldHint: false },
243
255
  inputSchema: z.object({ name: z.string() }),
244
- outputSchema: peaVariety,
256
+ outputSchema,
245
257
  handler,
246
258
  });
247
259
  ```
@@ -374,39 +386,36 @@ Prefer an open, bounded schema when the backend can add valid values
374
386
  independently.
375
387
 
376
388
  ```ts
377
- const backendCommand = z.object({ search: z.string().max(200) });
378
- const catalogueTaxon = z.object({
379
- id: z.number().int().positive(),
380
- name: z.string().max(200),
381
- rank: z.string().max(40),
382
- observations_count: z.number().int().nonnegative(),
389
+ const inputSchema = z.object({
390
+ name: z.string().max(200).describe("Pea taxon to look up."),
383
391
  });
384
- const backendResult = z.object({
385
- record: z.object({
386
- id: z.number().int().positive(),
387
- name: z.string().max(200),
388
- rank: z.string().max(40),
389
- observations_count: z.number().int().nonnegative(),
390
- }),
392
+ const backendInputSchema = z.object({ search: z.string().max(200) });
393
+ const backendTaxon = z.object({
394
+ id: z.number().int().positive().describe("Provider identifier for the taxon."),
395
+ name: z.string().max(200).describe("Scientific name of the taxon."),
396
+ rank: z.string().max(40).describe("Taxonomic rank reported by the provider."),
397
+ observations_count: z.number().int().nonnegative()
398
+ .describe("Recorded observations, not an estimate of the wild population."),
399
+ });
400
+ const outputSchema = backendTaxon.extend({
401
+ source: z.literal("catalogue-service").describe("Data provider for this result."),
402
+ });
403
+ const backendOutputSchema = z.object({
404
+ record: backendTaxon,
391
405
  });
392
406
 
393
407
  const getPeaTaxon = defineMappedTool({
394
408
  name: "get-pea-taxon",
395
409
  access: "public",
396
410
  description: "Get a pea taxon from the catalogue service.",
397
- inputSchema: z.object({ name: z.string().max(200) }),
398
- outputSchema: catalogueTaxon,
399
- backendInputSchema: backendCommand,
400
- backendOutputSchema: backendResult,
411
+ inputSchema,
412
+ outputSchema,
413
+ backendInputSchema,
414
+ backendOutputSchema,
401
415
  mapInput: ({ name }) => ({ search: name }),
402
416
  adapter: async (command, { signal }) => backend.findTaxon(command, { signal }),
403
417
  mapOutput: ({ record }) => {
404
- const data = {
405
- id: record.id,
406
- name: record.name,
407
- rank: record.rank,
408
- observations_count: record.observations_count,
409
- };
418
+ const data = { ...record, source: "catalogue-service" as const };
410
419
  return { text: `${data.name} has rank ${data.rank} and ${data.observations_count} recorded observations.`, data };
411
420
  },
412
421
  });
@@ -610,7 +619,9 @@ const methodGuide = defineResourceTemplate({
610
619
 
611
620
  const growing = definePrompt({
612
621
  name: "growing-guide",
613
- argsSchema: z.object({ topic: z.string().min(1) }),
622
+ argsSchema: z.object({
623
+ topic: z.string().min(1).describe("Pea-growing topic to explain."),
624
+ }),
614
625
  complete: {
615
626
  topic: (value) => ["sowing-depth", "plant-spacing"].filter((topic) => topic.startsWith(value)),
616
627
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emseepea/server",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Fastify-first framework for Model Context Protocol 2026-07-28 servers over Streamable HTTP",
5
5
  "license": "MIT",
6
6
  "repository": {