@emseepea/create-api-backed-server 0.0.6 → 0.0.8

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.
@@ -12,6 +12,8 @@ test("searches once and remembers the common name for a follow-up", async (t) =>
12
12
  server: new URL("../test-support/llm-server.mjs", import.meta.url),
13
13
  });
14
14
 
15
+ // The judged search covers the backend result's domain meaning. The exact
16
+ // no-call follow-up adds memory coverage without paying for a second judge.
15
17
  const search = await chat.send(
16
18
  'Search the public taxon catalogue for "pea". ' +
17
19
  "Which species has more recorded observations, how many does it have, " +
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "private": true,
27
27
  "dependencies": {
28
- "@emseepea/server": "0.3.0",
28
+ "@emseepea/server": "0.3.1",
29
29
  "zod": "4.4.3"
30
30
  }
31
31
  }
@@ -4,13 +4,6 @@ import { z } from "zod";
4
4
 
5
5
  export interface BackendExampleContext { readonly client: JsonHttpClient }
6
6
 
7
- const taxon = z.object({
8
- id: z.number().int().positive(),
9
- name: z.string().min(1).max(200),
10
- preferred_common_name: z.string().min(1).max(200).nullable().optional(),
11
- rank: z.string().min(1).max(40),
12
- observations_count: z.number().int().nonnegative(),
13
- });
14
7
  const backendTaxon = z.object({
15
8
  id: z.number().int().positive(),
16
9
  name: z.string().min(1).max(200),
@@ -18,15 +11,17 @@ const backendTaxon = z.object({
18
11
  rank: z.string().min(1).max(40),
19
12
  observations_count: z.number().int().nonnegative(),
20
13
  });
21
- const searchInput = z.object({ query: z.string().trim().min(2).max(80) });
22
- const searchReport = z.object({
23
- query: z.string().max(80),
14
+ const inputSchema = z.object({ query: z.string().trim().min(2).max(80) });
15
+ const backendPayload = z.object({
24
16
  total_results: z.number().int().nonnegative(),
25
- results: z.array(taxon).max(5),
17
+ results: z.array(backendTaxon).max(5),
18
+ });
19
+ const outputSchema = backendPayload.extend({
20
+ query: z.string().max(80),
26
21
  source: z.literal("iNaturalist"),
27
22
  source_url: z.literal("https://www.inaturalist.org"),
28
23
  });
29
- const backendCommand = z.object({
24
+ const backendInputSchema = z.object({
30
25
  pathname: z.literal("/v1/taxa"),
31
26
  searchParams: z.object({
32
27
  q: z.string().min(2).max(80),
@@ -34,20 +29,16 @@ const backendCommand = z.object({
34
29
  per_page: z.literal("5"),
35
30
  }),
36
31
  });
37
- const backendPayload = z.object({
38
- total_results: z.number().int().nonnegative(),
39
- results: z.array(backendTaxon).max(5),
40
- });
41
- const backendResult = z.object({ request: backendCommand, payload: backendPayload });
32
+ const backendOutputSchema = z.object({ request: backendInputSchema, payload: backendPayload });
42
33
 
43
34
  export default (({ client }) => defineMappedTool({
44
35
  name: "search-pea-taxa",
45
36
  access: "public",
46
37
  description: "Search iNaturalist's public taxon catalogue for pea species.",
47
- inputSchema: searchInput,
48
- outputSchema: searchReport,
49
- backendInputSchema: backendCommand,
50
- backendOutputSchema: backendResult,
38
+ inputSchema,
39
+ outputSchema,
40
+ backendInputSchema,
41
+ backendOutputSchema,
51
42
  mapInput: ({ query }) => ({
52
43
  pathname: "/v1/taxa" as const,
53
44
  searchParams: { q: query, rank: "species" as const, per_page: "5" as const },
@@ -57,15 +48,8 @@ export default (({ client }) => defineMappedTool({
57
48
  },
58
49
  mapOutput: ({ request, payload }) => {
59
50
  const data = {
51
+ ...payload,
60
52
  query: request.searchParams.q,
61
- total_results: payload.total_results,
62
- results: payload.results.map((record) => ({
63
- id: record.id,
64
- name: record.name,
65
- preferred_common_name: record.preferred_common_name,
66
- rank: record.rank,
67
- observations_count: record.observations_count,
68
- })),
69
53
  source: "iNaturalist" as const,
70
54
  source_url: "https://www.inaturalist.org" as const,
71
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emseepea/create-api-backed-server",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Create an Em See Pea server backed by a public web API.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  "prepack": "npm run build:initializer"
19
19
  },
20
20
  "devDependencies": {
21
- "@emseepea/server": "0.3.0",
21
+ "@emseepea/server": "0.3.1",
22
22
  "zod": "4.4.3",
23
23
  "@emseepea/testing": "0.3.0",
24
24
  "@modelcontextprotocol/client": "2.0.0",