@emseepea/create-resources-and-prompts-server 0.0.3 → 0.0.4
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 +11 -2
- package/initializer-dist/template/README.md +1 -1
- package/initializer-dist/template/eval/meaning.test.mjs +11 -11
- package/initializer-dist/template/package.json +2 -2
- package/initializer-dist/template/src/capabilities/{prompt.brew-guide.ts → prompt.growing-guide.ts} +5 -5
- package/initializer-dist/template/src/capabilities/resource.getting-started.ts +3 -3
- package/initializer-dist/template/src/capabilities/{resource.method-guide.ts → resource.planting-guide.ts} +5 -5
- package/initializer-dist/template/src/server.ts +1 -1
- package/initializer-dist/template/test/server.test.mjs +8 -8
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This directory is both the maintained example and its public npm initializer.
|
|
4
4
|
|
|
5
|
+
## Use This Template
|
|
6
|
+
|
|
7
|
+
Use this template to publish readable resources, parameterized resource
|
|
8
|
+
addresses, reusable prompts, and prompt-field suggestions. Choose the
|
|
9
|
+
[tool server](../tool-server/README.md) when the model needs to call an
|
|
10
|
+
operation instead of reading material or rendering a prompt. [Compare all eight templates](https://emseepea.github.io/emseepea/examples/).
|
|
11
|
+
|
|
12
|
+
## Create a Project
|
|
13
|
+
|
|
5
14
|
```sh
|
|
6
|
-
npm init @emseepea/resources-and-prompts-server
|
|
15
|
+
npm init @emseepea/resources-and-prompts-server -- my-server
|
|
7
16
|
```
|
|
8
17
|
|
|
9
18
|
<!-- generated-project-readme -->
|
|
@@ -45,7 +54,7 @@ Run its build and MCP resource and prompt checks:
|
|
|
45
54
|
npm test
|
|
46
55
|
```
|
|
47
56
|
|
|
48
|
-
Check that Claude keeps
|
|
57
|
+
Check that Claude keeps sowing depth and plant spacing distinct:
|
|
49
58
|
|
|
50
59
|
```sh
|
|
51
60
|
npm run test:llm
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { semanticTest } from "@emseepea/testing/semantic";
|
|
3
3
|
|
|
4
|
-
semanticTest("
|
|
4
|
+
semanticTest("Sowing depth and plant spacing remain separate concepts", {
|
|
5
5
|
server: new URL("../dist/server.js", import.meta.url),
|
|
6
6
|
question:
|
|
7
|
-
"
|
|
8
|
-
"Explain the distinction for a home
|
|
7
|
+
"If I sow pea seeds deeper, should I also space the plants farther apart? " +
|
|
8
|
+
"Explain the distinction for a home gardener.",
|
|
9
9
|
criticalFacts: [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"sowing depth",
|
|
11
|
+
"plant spacing"
|
|
12
12
|
],
|
|
13
13
|
criteria:
|
|
14
|
-
"The answer says
|
|
15
|
-
"It explains that
|
|
16
|
-
"
|
|
14
|
+
"The answer says sowing peas deeper does not mean spacing the plants farther " +
|
|
15
|
+
"apart. It explains that sowing depth is how deep a seed goes while plant " +
|
|
16
|
+
"spacing is the gap between plants, and it does not treat the measurements as " +
|
|
17
17
|
"interchangeable.",
|
|
18
|
-
requiredPaths: ["resources/read:guide://
|
|
18
|
+
requiredPaths: ["resources/read:guide://peas/getting-started","prompts/get:growing-guide"],
|
|
19
19
|
async exercise(client) {
|
|
20
|
-
const result1 = await client.readResource({"uri":"guide://
|
|
20
|
+
const result1 = await client.readResource({"uri":"guide://peas/getting-started"});
|
|
21
21
|
assert.ok(result1);
|
|
22
|
-
const result2 = await client.getPrompt({"name":"
|
|
22
|
+
const result2 = await client.getPrompt({"name":"growing-guide","arguments":{"topic":"sowing-depth"}});
|
|
23
23
|
assert.ok(result2);
|
|
24
24
|
},
|
|
25
25
|
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint": "oxlint src test eval"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@emseepea/testing": "0.2.
|
|
17
|
+
"@emseepea/testing": "0.2.2",
|
|
18
18
|
"@types/node": "24.13.3",
|
|
19
19
|
"typescript": "6.0.3",
|
|
20
20
|
"oxlint": "1.80.0"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"private": true,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@emseepea/server": "0.2.
|
|
27
|
+
"@emseepea/server": "0.2.2",
|
|
28
28
|
"zod": "4.4.3"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/initializer-dist/template/src/capabilities/{prompt.brew-guide.ts → prompt.growing-guide.ts}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { definePrompt, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
const topics = ["
|
|
4
|
+
const topics = ["sowing-depth", "plant-spacing", "trellis-support"];
|
|
5
5
|
|
|
6
6
|
export default (() => definePrompt({
|
|
7
|
-
name: "
|
|
8
|
-
title: "
|
|
9
|
-
description: "Create a prompt for a sample
|
|
7
|
+
name: "growing-guide",
|
|
8
|
+
title: "Pea growing guide",
|
|
9
|
+
description: "Create a prompt for a sample pea-growing topic.",
|
|
10
10
|
argsSchema: z.object({ topic: z.string().min(1) }),
|
|
11
11
|
complete: {
|
|
12
12
|
topic: (value) => topics.filter((topic) => topic.startsWith(value)),
|
|
@@ -17,7 +17,7 @@ export default (() => definePrompt({
|
|
|
17
17
|
role: "user",
|
|
18
18
|
content: {
|
|
19
19
|
type: "text",
|
|
20
|
-
text: `Explain ${topic} for a home
|
|
20
|
+
text: `Explain ${topic} for a home gardener. Distinguish any commonly confused concepts.`,
|
|
21
21
|
},
|
|
22
22
|
}],
|
|
23
23
|
}),
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { defineResource, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
2
|
|
|
3
|
-
const guideUri = "guide://
|
|
3
|
+
const guideUri = "guide://peas/getting-started";
|
|
4
4
|
|
|
5
5
|
export default (() => defineResource({
|
|
6
6
|
name: "getting-started",
|
|
7
7
|
uri: guideUri,
|
|
8
|
-
title: "
|
|
8
|
+
title: "Pea growing: getting started",
|
|
9
9
|
description: "A sample guide exposed as an MCP resource.",
|
|
10
10
|
mimeType: "text/markdown",
|
|
11
11
|
handler: () => ({
|
|
12
12
|
contents: [{
|
|
13
13
|
uri: guideUri,
|
|
14
14
|
mimeType: "text/markdown",
|
|
15
|
-
text: "#
|
|
15
|
+
text: "# Plant peas clearly\n\nSowing depth is how deep a seed goes; plant spacing is the gap between plants. They are separate choices, not interchangeable measurements.\n",
|
|
16
16
|
}],
|
|
17
17
|
}),
|
|
18
18
|
})) satisfies CapabilityModuleFactory;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineResourceTemplate, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
2
|
|
|
3
|
-
const methods = ["
|
|
3
|
+
const methods = ["container", "raised-bed", "row"];
|
|
4
4
|
|
|
5
5
|
export default (() => defineResourceTemplate({
|
|
6
|
-
name: "
|
|
7
|
-
uriTemplate: "guide://
|
|
8
|
-
title: "
|
|
9
|
-
description: "A sample guide selected by
|
|
6
|
+
name: "planting-guide",
|
|
7
|
+
uriTemplate: "guide://peas/planting/{method}",
|
|
8
|
+
title: "Pea planting guide",
|
|
9
|
+
description: "A sample guide selected by planting method.",
|
|
10
10
|
mimeType: "text/markdown",
|
|
11
11
|
complete: {
|
|
12
12
|
method: (value) => methods.filter((method) => method.startsWith(value)),
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "@emseepea/server";
|
|
6
6
|
|
|
7
7
|
const running = await serveEmseepea(createEmseepea({
|
|
8
|
-
name: "emseepea-resources-prompts",
|
|
8
|
+
name: "emseepea-resources-and-prompts-server",
|
|
9
9
|
version: "0.0.0",
|
|
10
10
|
...await discoverCapabilities(new URL("./capabilities/", import.meta.url)),
|
|
11
11
|
}), { port: Number.parseInt(process.env.PORT ?? "3000", 10) });
|
|
@@ -8,16 +8,16 @@ test("lists and reads the advertised resource and prompt", async (t) => {
|
|
|
8
8
|
const client = await running.connect();
|
|
9
9
|
|
|
10
10
|
assert.deepEqual((await client.listResources()).resources.map(({ uri }) => uri), [
|
|
11
|
-
"guide://
|
|
11
|
+
"guide://peas/getting-started",
|
|
12
12
|
]);
|
|
13
|
-
const resource = await client.readResource({ uri: "guide://
|
|
14
|
-
assert.match(resource.contents[0].text, /
|
|
15
|
-
assert.match(resource.contents[0].text, /
|
|
13
|
+
const resource = await client.readResource({ uri: "guide://peas/getting-started" });
|
|
14
|
+
assert.match(resource.contents[0].text, /Sowing depth is how deep a seed goes/);
|
|
15
|
+
assert.match(resource.contents[0].text, /plant spacing is the gap between plants/);
|
|
16
16
|
|
|
17
|
-
assert.deepEqual((await client.listPrompts()).prompts.map(({ name }) => name), ["
|
|
17
|
+
assert.deepEqual((await client.listPrompts()).prompts.map(({ name }) => name), ["growing-guide"]);
|
|
18
18
|
const prompt = await client.getPrompt({
|
|
19
|
-
name: "
|
|
20
|
-
arguments: { topic: "
|
|
19
|
+
name: "growing-guide",
|
|
20
|
+
arguments: { topic: "sowing-depth" },
|
|
21
21
|
});
|
|
22
|
-
assert.match(prompt.messages[0].content.text, /Explain
|
|
22
|
+
assert.match(prompt.messages[0].content.text, /Explain sowing-depth/);
|
|
23
23
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emseepea/create-resources-and-prompts-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Create an Em See Pea server with resources and prompts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"prepack": "npm run build:initializer"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@emseepea/server": "0.2.
|
|
21
|
+
"@emseepea/server": "0.2.2",
|
|
22
22
|
"zod": "4.4.3",
|
|
23
|
-
"@emseepea/testing": "0.2.
|
|
23
|
+
"@emseepea/testing": "0.2.2",
|
|
24
24
|
"@types/node": "24.13.3",
|
|
25
25
|
"typescript": "6.0.3",
|
|
26
26
|
"oxlint": "1.80.0"
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=22"
|
|
30
30
|
},
|
|
31
|
-
"repository": { "type": "git", "url": "git+https://github.com/emseepea/emseepea.git", "directory": "examples/resources-prompts" },
|
|
31
|
+
"repository": { "type": "git", "url": "git+https://github.com/emseepea/emseepea.git", "directory": "examples/resources-and-prompts-server" },
|
|
32
32
|
"homepage": "https://emseepea.github.io/emseepea/examples/",
|
|
33
33
|
"bugs": "https://github.com/emseepea/emseepea/issues",
|
|
34
|
-
"publishConfig": { "access": "public", "provenance": true
|
|
34
|
+
"publishConfig": { "access": "public", "provenance": true },
|
|
35
35
|
"bin": { "create-resources-and-prompts-server": "./initializer-dist/create.mjs" },
|
|
36
36
|
"files": ["initializer-dist"]
|
|
37
37
|
}
|