@emseepea/create-resources-and-prompts-server 0.0.1 → 0.0.3
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 +43 -11
- package/{dist → initializer-dist}/template/package.json +6 -5
- package/initializer-dist/template/src/capabilities/prompt.brew-guide.ts +24 -0
- package/initializer-dist/template/src/capabilities/resource.getting-started.ts +18 -0
- package/initializer-dist/template/src/capabilities/resource.method-guide.ts +21 -0
- package/initializer-dist/template/src/server.ts +21 -0
- package/package.json +28 -13
- package/dist/template/src/server.ts +0 -82
- /package/{dist → initializer-dist}/LICENSE +0 -0
- /package/{dist → initializer-dist}/create.mjs +0 -0
- /package/{dist → initializer-dist}/template/README.md +0 -0
- /package/{dist → initializer-dist}/template/eval/meaning.test.mjs +0 -0
- /package/{dist → initializer-dist}/template/test/server.test.mjs +0 -0
- /package/{dist → initializer-dist}/template/tsconfig.json +0 -0
package/README.md
CHANGED
|
@@ -1,22 +1,54 @@
|
|
|
1
1
|
# `@emseepea/create-resources-and-prompts-server`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
The package builds its starter from the maintained
|
|
5
|
-
[resources and prompts example](https://github.com/emseepea/emseepea/tree/main/examples/resources-prompts).
|
|
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.
|
|
3
|
+
This directory is both the maintained example and its public npm initializer.
|
|
11
4
|
|
|
12
5
|
```sh
|
|
13
6
|
npm init @emseepea/resources-and-prompts-server@next -- my-server
|
|
14
7
|
```
|
|
15
8
|
|
|
9
|
+
<!-- generated-project-readme -->
|
|
10
|
+
|
|
11
|
+
## Resources and Prompts Example
|
|
12
|
+
|
|
13
|
+
Choose this example when you want to give an assistant reusable reference
|
|
14
|
+
content and guided starting questions, without adding another tool.
|
|
15
|
+
|
|
16
|
+
It provides:
|
|
17
|
+
|
|
18
|
+
- a fixed resource at one known address
|
|
19
|
+
- a resource pattern for related content at predictable addresses
|
|
20
|
+
- a reusable prompt with one checked argument
|
|
21
|
+
- optional suggestions for the resource and prompt fields
|
|
22
|
+
|
|
23
|
+
## Run
|
|
24
|
+
|
|
25
|
+
From this directory:
|
|
26
|
+
|
|
16
27
|
```sh
|
|
17
|
-
cd my-server
|
|
18
28
|
npm install
|
|
19
|
-
npm
|
|
20
|
-
npm run lint
|
|
29
|
+
npm run build
|
|
21
30
|
npm start
|
|
22
31
|
```
|
|
32
|
+
|
|
33
|
+
The server listens on `http://127.0.0.1:3000/mcp` by default. Set `PORT` to
|
|
34
|
+
choose another port.
|
|
35
|
+
|
|
36
|
+
## Check This Example
|
|
37
|
+
|
|
38
|
+
[Ordinary tests](test/) live in `test/`.
|
|
39
|
+
The [AI understanding test](eval/meaning.test.mjs) lives separately in `eval/`.
|
|
40
|
+
The commands below run each suite independently.
|
|
41
|
+
|
|
42
|
+
Run its build and MCP resource and prompt checks:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Check that Claude keeps coffee strength and extraction distinct:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npm run test:llm
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If Claude is not already signed in, run `claude auth login` first.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emseepea-starter",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
-
"
|
|
4
|
+
"description": "Create an Em See Pea server with resources and prompts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
"test:llm:built": "emseepea-test eval",
|
|
14
14
|
"lint": "oxlint src test eval"
|
|
15
15
|
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@emseepea/server": "0.0.4",
|
|
18
|
-
"zod": "4.4.3"
|
|
19
|
-
},
|
|
20
16
|
"devDependencies": {
|
|
21
17
|
"@emseepea/testing": "0.2.1",
|
|
22
18
|
"@types/node": "24.13.3",
|
|
@@ -25,5 +21,10 @@
|
|
|
25
21
|
},
|
|
26
22
|
"engines": {
|
|
27
23
|
"node": ">=22"
|
|
24
|
+
},
|
|
25
|
+
"private": true,
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@emseepea/server": "0.2.1",
|
|
28
|
+
"zod": "4.4.3"
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { definePrompt, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const topics = ["brew-ratio", "grind-size", "water-temperature"];
|
|
5
|
+
|
|
6
|
+
export default (() => definePrompt({
|
|
7
|
+
name: "brew-guide",
|
|
8
|
+
title: "Brew guide",
|
|
9
|
+
description: "Create a prompt for a sample brewing topic.",
|
|
10
|
+
argsSchema: z.object({ topic: z.string().min(1) }),
|
|
11
|
+
complete: {
|
|
12
|
+
topic: (value) => topics.filter((topic) => topic.startsWith(value)),
|
|
13
|
+
},
|
|
14
|
+
handler: ({ topic }) => ({
|
|
15
|
+
description: `Guide for ${topic}`,
|
|
16
|
+
messages: [{
|
|
17
|
+
role: "user",
|
|
18
|
+
content: {
|
|
19
|
+
type: "text",
|
|
20
|
+
text: `Explain ${topic} for a home brewer. Distinguish any commonly confused concepts.`,
|
|
21
|
+
},
|
|
22
|
+
}],
|
|
23
|
+
}),
|
|
24
|
+
})) satisfies CapabilityModuleFactory;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineResource, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
|
+
|
|
3
|
+
const guideUri = "guide://coffee/getting-started";
|
|
4
|
+
|
|
5
|
+
export default (() => defineResource({
|
|
6
|
+
name: "getting-started",
|
|
7
|
+
uri: guideUri,
|
|
8
|
+
title: "Coffee getting started",
|
|
9
|
+
description: "A sample guide exposed as an MCP resource.",
|
|
10
|
+
mimeType: "text/markdown",
|
|
11
|
+
handler: () => ({
|
|
12
|
+
contents: [{
|
|
13
|
+
uri: guideUri,
|
|
14
|
+
mimeType: "text/markdown",
|
|
15
|
+
text: "# Brew clearly\n\nStrength is concentration; extraction is how much material left the grounds. They are related, but not interchangeable.\n",
|
|
16
|
+
}],
|
|
17
|
+
}),
|
|
18
|
+
})) satisfies CapabilityModuleFactory;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineResourceTemplate, type CapabilityModuleFactory } from "@emseepea/server";
|
|
2
|
+
|
|
3
|
+
const methods = ["aeropress", "espresso", "pour-over"];
|
|
4
|
+
|
|
5
|
+
export default (() => defineResourceTemplate({
|
|
6
|
+
name: "method-guide",
|
|
7
|
+
uriTemplate: "guide://coffee/method/{method}",
|
|
8
|
+
title: "Coffee method guide",
|
|
9
|
+
description: "A sample guide selected by brewing method.",
|
|
10
|
+
mimeType: "text/markdown",
|
|
11
|
+
complete: {
|
|
12
|
+
method: (value) => methods.filter((method) => method.startsWith(value)),
|
|
13
|
+
},
|
|
14
|
+
handler: ({ uri, variables }) => ({
|
|
15
|
+
contents: [{
|
|
16
|
+
uri,
|
|
17
|
+
mimeType: "text/markdown",
|
|
18
|
+
text: `# ${String(variables.method)}\n`,
|
|
19
|
+
}],
|
|
20
|
+
}),
|
|
21
|
+
})) satisfies CapabilityModuleFactory;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEmseepea,
|
|
3
|
+
discoverCapabilities,
|
|
4
|
+
serveEmseepea,
|
|
5
|
+
} from "@emseepea/server";
|
|
6
|
+
|
|
7
|
+
const running = await serveEmseepea(createEmseepea({
|
|
8
|
+
name: "emseepea-resources-prompts",
|
|
9
|
+
version: "0.0.0",
|
|
10
|
+
...await discoverCapabilities(new URL("./capabilities/", import.meta.url)),
|
|
11
|
+
}), { port: Number.parseInt(process.env.PORT ?? "3000", 10) });
|
|
12
|
+
|
|
13
|
+
console.log(`Em See Pea resources and prompts example listening at ${running.url}`);
|
|
14
|
+
|
|
15
|
+
async function shutdown(): Promise<void> {
|
|
16
|
+
await running.close();
|
|
17
|
+
process.exitCode = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
process.once("SIGINT", () => void shutdown());
|
|
21
|
+
process.once("SIGTERM", () => void shutdown());
|
package/package.json
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emseepea/create-resources-and-prompts-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Create an Em See Pea server with resources and prompts.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"starterDependencies": ["@emseepea/server", "zod"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npm run build:example && npm run build:initializer",
|
|
10
|
+
"build:example": "tsc -p tsconfig.json",
|
|
11
|
+
"build:initializer": "node ../../scripts/build-initializer.mjs",
|
|
12
|
+
"start": "node dist/server.js",
|
|
13
|
+
"test": "npm run build && npm run test:built",
|
|
14
|
+
"test:built": "node --test test/*.test.mjs",
|
|
15
|
+
"test:llm": "npm run build && npm run test:llm:built",
|
|
16
|
+
"test:llm:built": "emseepea-test eval",
|
|
17
|
+
"lint": "oxlint src test eval",
|
|
18
|
+
"prepack": "npm run build:initializer"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@emseepea/server": "0.2.1",
|
|
22
|
+
"zod": "4.4.3",
|
|
23
|
+
"@emseepea/testing": "0.2.1",
|
|
24
|
+
"@types/node": "24.13.3",
|
|
25
|
+
"typescript": "6.0.3",
|
|
26
|
+
"oxlint": "1.80.0"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22"
|
|
10
30
|
},
|
|
31
|
+
"repository": { "type": "git", "url": "git+https://github.com/emseepea/emseepea.git", "directory": "examples/resources-prompts" },
|
|
11
32
|
"homepage": "https://emseepea.github.io/emseepea/examples/",
|
|
12
33
|
"bugs": "https://github.com/emseepea/emseepea/issues",
|
|
13
34
|
"publishConfig": { "access": "public", "provenance": true, "tag": "next" },
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"files": ["dist"],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "node ../../scripts/build-initializer.mjs",
|
|
19
|
-
"prepack": "npm run build"
|
|
20
|
-
},
|
|
21
|
-
"engines": { "node": ">=22" }
|
|
35
|
+
"bin": { "create-resources-and-prompts-server": "./initializer-dist/create.mjs" },
|
|
36
|
+
"files": ["initializer-dist"]
|
|
22
37
|
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createEmseepea,
|
|
3
|
-
definePrompt,
|
|
4
|
-
defineResource,
|
|
5
|
-
defineResourceTemplate,
|
|
6
|
-
serveEmseepea,
|
|
7
|
-
} from "@emseepea/server";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
|
|
10
|
-
const guideUri = "guide://coffee/getting-started";
|
|
11
|
-
const methods = ["aeropress", "espresso", "pour-over"];
|
|
12
|
-
const topics = ["brew-ratio", "grind-size", "water-temperature"];
|
|
13
|
-
|
|
14
|
-
const guide = defineResource({
|
|
15
|
-
name: "getting-started",
|
|
16
|
-
uri: guideUri,
|
|
17
|
-
title: "Coffee getting started",
|
|
18
|
-
description: "A sample guide exposed as an MCP resource.",
|
|
19
|
-
mimeType: "text/markdown",
|
|
20
|
-
handler: () => ({
|
|
21
|
-
contents: [{
|
|
22
|
-
uri: guideUri,
|
|
23
|
-
mimeType: "text/markdown",
|
|
24
|
-
text: "# Brew clearly\n\nStrength is concentration; extraction is how much material left the grounds. They are related, but not interchangeable.\n",
|
|
25
|
-
}],
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const methodGuide = defineResourceTemplate({
|
|
30
|
-
name: "method-guide",
|
|
31
|
-
uriTemplate: "guide://coffee/method/{method}",
|
|
32
|
-
title: "Coffee method guide",
|
|
33
|
-
description: "A sample guide selected by brewing method.",
|
|
34
|
-
mimeType: "text/markdown",
|
|
35
|
-
complete: {
|
|
36
|
-
method: (value) => methods.filter((method) => method.startsWith(value)),
|
|
37
|
-
},
|
|
38
|
-
handler: ({ uri, variables }) => ({
|
|
39
|
-
contents: [{
|
|
40
|
-
uri,
|
|
41
|
-
mimeType: "text/markdown",
|
|
42
|
-
text: `# ${String(variables.method)}\n`,
|
|
43
|
-
}],
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const brew = definePrompt({
|
|
48
|
-
name: "brew-guide",
|
|
49
|
-
title: "Brew guide",
|
|
50
|
-
description: "Create a prompt for a sample brewing topic.",
|
|
51
|
-
argsSchema: z.object({ topic: z.string().min(1) }),
|
|
52
|
-
complete: {
|
|
53
|
-
topic: (value) => topics.filter((topic) => topic.startsWith(value)),
|
|
54
|
-
},
|
|
55
|
-
handler: ({ topic }) => ({
|
|
56
|
-
description: `Guide for ${topic}`,
|
|
57
|
-
messages: [{
|
|
58
|
-
role: "user",
|
|
59
|
-
content: {
|
|
60
|
-
type: "text",
|
|
61
|
-
text: `Explain ${topic} for a home brewer. Distinguish any commonly confused concepts.`,
|
|
62
|
-
},
|
|
63
|
-
}],
|
|
64
|
-
}),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const running = await serveEmseepea(createEmseepea({
|
|
68
|
-
name: "emseepea-resources-prompts",
|
|
69
|
-
version: "0.0.0",
|
|
70
|
-
resources: [guide, methodGuide],
|
|
71
|
-
prompts: [brew],
|
|
72
|
-
}), { port: Number.parseInt(process.env.PORT ?? "3000", 10) });
|
|
73
|
-
|
|
74
|
-
console.log(`Em See Pea resources and prompts example listening at ${running.url}`);
|
|
75
|
-
|
|
76
|
-
async function shutdown(): Promise<void> {
|
|
77
|
-
await running.close();
|
|
78
|
-
process.exitCode = 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
process.once("SIGINT", () => void shutdown());
|
|
82
|
-
process.once("SIGTERM", () => void shutdown());
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|