@emseepea/create-tool-server 0.0.0
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.
- package/README.md +22 -0
- package/dist/LICENSE +21 -0
- package/dist/create.mjs +44 -0
- package/dist/template/README.md +51 -0
- package/dist/template/eval/meaning.test.mjs +21 -0
- package/dist/template/package.json +29 -0
- package/dist/template/src/server.ts +70 -0
- package/dist/template/test/server.test.mjs +26 -0
- package/dist/template/tsconfig.json +15 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# `@emseepea/create-tool-server`
|
|
2
|
+
|
|
3
|
+
Create a private, standalone Em See Pea project with one public, read-only
|
|
4
|
+
tool. The package builds its starter from the maintained
|
|
5
|
+
[first public tool example](https://github.com/emseepea/emseepea/tree/main/examples/basic-no-ui).
|
|
6
|
+
|
|
7
|
+
## Create the Project
|
|
8
|
+
|
|
9
|
+
This initializer is queued for the next pre-alpha release and is not yet
|
|
10
|
+
available from npm.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm init @emseepea/tool-server@next -- my-server
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
cd my-server
|
|
18
|
+
npm install
|
|
19
|
+
npm test
|
|
20
|
+
npm run lint
|
|
21
|
+
npm start
|
|
22
|
+
```
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Windy Road Technology Pty. Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/create.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { cp, mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
const [destination, ...extra] = process.argv.slice(2);
|
|
7
|
+
if (extra.length > 0 || !destination || !/^[a-z0-9][a-z0-9._-]*$/.test(destination)) {
|
|
8
|
+
throw new Error("Provide one simple lowercase destination name, such as my-server");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const target = resolve(destination);
|
|
12
|
+
if (basename(target) !== destination) throw new Error("The destination must not contain a path");
|
|
13
|
+
const staging = await mkdtemp(join(dirname(target), ".emseepea-create-"));
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await copyContents(new URL("./template/", import.meta.url), staging);
|
|
17
|
+
const manifestPath = resolve(staging, "package.json");
|
|
18
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
19
|
+
await writeFile(manifestPath, `${JSON.stringify({ ...manifest, name: destination }, null, 2)}\n`);
|
|
20
|
+
await mkdir(target);
|
|
21
|
+
try {
|
|
22
|
+
await copyContents(staging, target);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
await rm(target, { recursive: true, force: true });
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (["EEXIST", "ENOTEMPTY"].includes(error.code)) {
|
|
29
|
+
throw new Error(`The destination already exists: ${destination}`);
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
} finally {
|
|
33
|
+
await rm(staging, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function copyContents(source, destination) {
|
|
37
|
+
for (const entry of await readdir(source)) {
|
|
38
|
+
const from = source instanceof URL ? new URL(entry, source) : join(source, entry);
|
|
39
|
+
await cp(from, join(destination, entry), { recursive: true, errorOnExist: true, force: false });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(`Created ${destination}.`);
|
|
44
|
+
console.log(`Next: cd ${destination}; npm install; npm test; npm start`);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Your First Public Tool
|
|
2
|
+
|
|
3
|
+
Choose this example when you want the smallest working server with one public,
|
|
4
|
+
read-only tool and no web page.
|
|
5
|
+
|
|
6
|
+
The `get-bean-details` tool returns useful details about one sample coffee. Em
|
|
7
|
+
See Pea checks the question and result before returning them through the public
|
|
8
|
+
`@emseepea/server` API.
|
|
9
|
+
|
|
10
|
+
## What This Example Includes
|
|
11
|
+
|
|
12
|
+
- Model Context Protocol (MCP) `2026-07-28` over `POST /mcp`
|
|
13
|
+
- one public, read-only tool with sample data
|
|
14
|
+
- checks for tool input and output
|
|
15
|
+
- local use on your computer only
|
|
16
|
+
|
|
17
|
+
It does not include sign-in, saved sessions, live progress, changes to data, or
|
|
18
|
+
production network setup.
|
|
19
|
+
|
|
20
|
+
## Run
|
|
21
|
+
|
|
22
|
+
From this directory:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install
|
|
26
|
+
npm run build
|
|
27
|
+
npm start
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The endpoint is `http://127.0.0.1:3000/mcp` and the health check is
|
|
31
|
+
`http://127.0.0.1:3000/healthz`.
|
|
32
|
+
|
|
33
|
+
## Check This Example
|
|
34
|
+
|
|
35
|
+
[Ordinary tests](test/) live in `test/`.
|
|
36
|
+
The [AI tool-choice and understanding test](eval/meaning.test.mjs) lives separately in `eval/`.
|
|
37
|
+
The commands below run each suite independently.
|
|
38
|
+
|
|
39
|
+
Run its build and MCP checks:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Check that Claude chooses the details tool and understands its result:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm run test:llm
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If Claude is not already signed in, run `claude auth login` first.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { toolSelectionTest } from "@emseepea/testing/semantic";
|
|
2
|
+
|
|
3
|
+
toolSelectionTest("Basic bean details keep each concept distinct", {
|
|
4
|
+
server: new URL("../dist/server.js", import.meta.url),
|
|
5
|
+
question:
|
|
6
|
+
"For Highland Bloom, give me its origin, variety, processing method, roast, and " +
|
|
7
|
+
"tasting notes. Keep those concepts distinct.",
|
|
8
|
+
criticalFacts: [
|
|
9
|
+
"Sample Highlands",
|
|
10
|
+
"Bourbon",
|
|
11
|
+
"natural",
|
|
12
|
+
"medium",
|
|
13
|
+
"berry",
|
|
14
|
+
"cocoa"
|
|
15
|
+
],
|
|
16
|
+
criteria:
|
|
17
|
+
"The answer says Highland Bloom is a medium-roast, naturally processed Bourbon " +
|
|
18
|
+
"from Sample Highlands with berry and cocoa tasting notes. It does not confuse " +
|
|
19
|
+
"origin, variety, process, roast, or tasting notes.",
|
|
20
|
+
expectedTools: ["get-bean-details"],
|
|
21
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "emseepea-starter",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.json",
|
|
9
|
+
"start": "node dist/server.js",
|
|
10
|
+
"test": "npm run build && npm run test:built",
|
|
11
|
+
"test:built": "node --test test/*.test.mjs",
|
|
12
|
+
"test:llm": "npm run build && npm run test:llm:built",
|
|
13
|
+
"test:llm:built": "emseepea-test eval",
|
|
14
|
+
"lint": "oxlint src test eval"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@emseepea/server": "0.0.3",
|
|
18
|
+
"zod": "4.4.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@emseepea/testing": "0.2.0",
|
|
22
|
+
"@types/node": "24.13.3",
|
|
23
|
+
"typescript": "6.0.3",
|
|
24
|
+
"oxlint": "1.80.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defineTool, createEmseepea, serveEmseepea } from "@emseepea/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const beanNames = ["Harbour Dawn", "Highland Bloom"] as const;
|
|
5
|
+
const beanDetailsSchema = z.object({
|
|
6
|
+
name: z.enum(beanNames),
|
|
7
|
+
origin: z.string(),
|
|
8
|
+
variety: z.string(),
|
|
9
|
+
process: z.string(),
|
|
10
|
+
roast: z.enum(["light", "medium", "dark"]),
|
|
11
|
+
tastingNotes: z.array(z.string()),
|
|
12
|
+
});
|
|
13
|
+
const beans: Record<(typeof beanNames)[number], z.input<typeof beanDetailsSchema>> = {
|
|
14
|
+
"Harbour Dawn": {
|
|
15
|
+
name: "Harbour Dawn",
|
|
16
|
+
origin: "Sample Coast",
|
|
17
|
+
variety: "Caturra",
|
|
18
|
+
process: "washed",
|
|
19
|
+
roast: "light",
|
|
20
|
+
tastingNotes: ["citrus", "honey"],
|
|
21
|
+
},
|
|
22
|
+
"Highland Bloom": {
|
|
23
|
+
name: "Highland Bloom",
|
|
24
|
+
origin: "Sample Highlands",
|
|
25
|
+
variety: "Bourbon",
|
|
26
|
+
process: "natural",
|
|
27
|
+
roast: "medium",
|
|
28
|
+
tastingNotes: ["berry", "cocoa"],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getBeanDetails = defineTool({
|
|
33
|
+
name: "get-bean-details",
|
|
34
|
+
access: "public",
|
|
35
|
+
title: "Coffee Bean Details",
|
|
36
|
+
description: "Get origin, processing, roast, and tasting details for a sample coffee bean.",
|
|
37
|
+
inputSchema: z.object({
|
|
38
|
+
name: z.enum(beanNames),
|
|
39
|
+
}),
|
|
40
|
+
outputSchema: beanDetailsSchema,
|
|
41
|
+
handler: ({ name }) => {
|
|
42
|
+
const data = beans[name];
|
|
43
|
+
return {
|
|
44
|
+
text: `${data.name} is a ${data.roast} ${data.process} ${data.variety} from ` +
|
|
45
|
+
`${data.origin}, with notes of ${data.tastingNotes.join(" and ")}.`,
|
|
46
|
+
data,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const handler = createEmseepea({
|
|
52
|
+
name: "emseepea-basic-no-ui",
|
|
53
|
+
version: "0.0.0",
|
|
54
|
+
instructions: "Use get-bean-details for information about a sample coffee bean.",
|
|
55
|
+
tools: [getBeanDetails],
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const running = await serveEmseepea(handler, {
|
|
59
|
+
port: Number.parseInt(process.env.PORT ?? "3000", 10),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log(`Em See Pea basic no-UI example listening at ${running.url}`);
|
|
63
|
+
|
|
64
|
+
async function shutdown(): Promise<void> {
|
|
65
|
+
await running.close();
|
|
66
|
+
process.exitCode = 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
process.once("SIGINT", () => void shutdown());
|
|
70
|
+
process.once("SIGTERM", () => void shutdown());
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { startMcpServer } from "@emseepea/testing";
|
|
5
|
+
|
|
6
|
+
test("advertises and returns understandable bean details", async (t) => {
|
|
7
|
+
const running = await startMcpServer(t, new URL("../dist/server.js", import.meta.url));
|
|
8
|
+
const client = await running.connect();
|
|
9
|
+
|
|
10
|
+
const listed = await client.listTools();
|
|
11
|
+
assert.deepEqual(listed.tools.map(({ name }) => name), ["get-bean-details"]);
|
|
12
|
+
|
|
13
|
+
const result = await client.callTool({
|
|
14
|
+
name: "get-bean-details",
|
|
15
|
+
arguments: { name: "Highland Bloom" },
|
|
16
|
+
});
|
|
17
|
+
assert.equal(result.isError, false);
|
|
18
|
+
assert.deepEqual(result.structuredContent, {
|
|
19
|
+
name: "Highland Bloom",
|
|
20
|
+
origin: "Sample Highlands",
|
|
21
|
+
variety: "Bourbon",
|
|
22
|
+
process: "natural",
|
|
23
|
+
roast: "medium",
|
|
24
|
+
tastingNotes: ["berry", "cocoa"],
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"moduleResolution": "NodeNext",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"target": "ES2023",
|
|
9
|
+
"types": ["node"],
|
|
10
|
+
"verbatimModuleSyntax": true
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src/**/*.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@emseepea/create-tool-server",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Create an Em See Pea server with one public tool.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/emseepea/emseepea.git",
|
|
9
|
+
"directory": "packages/create-tool-server"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://emseepea.github.io/emseepea/examples/",
|
|
12
|
+
"bugs": "https://github.com/emseepea/emseepea/issues",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"provenance": false,
|
|
16
|
+
"tag": "next"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"bin": {
|
|
20
|
+
"create-tool-server": "./dist/create.mjs"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22"
|
|
27
|
+
}
|
|
28
|
+
}
|