@emseepea/create-api-backed-server 0.0.7 → 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.
|
@@ -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
|
|
22
|
-
const
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
48
|
-
outputSchema
|
|
49
|
-
backendInputSchema
|
|
50
|
-
backendOutputSchema
|
|
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.
|
|
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.
|
|
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",
|