@emseepea/create-resources-and-prompts-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 ADDED
@@ -0,0 +1,22 @@
1
+ # `@emseepea/create-resources-and-prompts-server`
2
+
3
+ Create a private, standalone Em See Pea project with resources and prompts.
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.
11
+
12
+ ```sh
13
+ npm init @emseepea/resources-and-prompts-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.
@@ -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,44 @@
1
+ # Resources and Prompts Example
2
+
3
+ Choose this example when you want to give an assistant reusable reference
4
+ content and guided starting questions, without adding another tool.
5
+
6
+ It provides:
7
+
8
+ - a fixed resource at one known address
9
+ - a resource pattern for related content at predictable addresses
10
+ - a reusable prompt with one checked argument
11
+ - optional suggestions for the resource and prompt fields
12
+
13
+ ## Run
14
+
15
+ From this directory:
16
+
17
+ ```sh
18
+ npm install
19
+ npm run build
20
+ npm start
21
+ ```
22
+
23
+ The server listens on `http://127.0.0.1:3000/mcp` by default. Set `PORT` to
24
+ choose another port.
25
+
26
+ ## Check This Example
27
+
28
+ [Ordinary tests](test/) live in `test/`.
29
+ The [AI understanding test](eval/meaning.test.mjs) lives separately in `eval/`.
30
+ The commands below run each suite independently.
31
+
32
+ Run its build and MCP resource and prompt checks:
33
+
34
+ ```sh
35
+ npm test
36
+ ```
37
+
38
+ Check that Claude keeps coffee strength and extraction distinct:
39
+
40
+ ```sh
41
+ npm run test:llm
42
+ ```
43
+
44
+ If Claude is not already signed in, run `claude auth login` first.
@@ -0,0 +1,25 @@
1
+ import assert from "node:assert/strict";
2
+ import { semanticTest } from "@emseepea/testing/semantic";
3
+
4
+ semanticTest("Strength and extraction remain separate concepts", {
5
+ server: new URL("../dist/server.js", import.meta.url),
6
+ question:
7
+ "Does making coffee stronger necessarily mean that extraction is higher? " +
8
+ "Explain the distinction for a home brewer.",
9
+ criticalFacts: [
10
+ "concentration",
11
+ "extraction"
12
+ ],
13
+ criteria:
14
+ "The answer says stronger coffee does not necessarily mean higher extraction. " +
15
+ "It explains that strength is concentration while extraction is how much " +
16
+ "material left the grounds, and it does not describe the concepts as " +
17
+ "interchangeable.",
18
+ requiredPaths: ["resources/read:guide://coffee/getting-started","prompts/get:brew-guide"],
19
+ async exercise(client) {
20
+ const result1 = await client.readResource({"uri":"guide://coffee/getting-started"});
21
+ assert.ok(result1);
22
+ const result2 = await client.getPrompt({"name":"brew-guide","arguments":{"topic":"brew-ratio"}});
23
+ assert.ok(result2);
24
+ },
25
+ });
@@ -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.4",
18
+ "zod": "4.4.3"
19
+ },
20
+ "devDependencies": {
21
+ "@emseepea/testing": "0.2.1",
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,82 @@
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());
@@ -0,0 +1,23 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import { startMcpServer } from "@emseepea/testing";
5
+
6
+ test("lists and reads the advertised resource and prompt", async (t) => {
7
+ const running = await startMcpServer(t, new URL("../dist/server.js", import.meta.url));
8
+ const client = await running.connect();
9
+
10
+ assert.deepEqual((await client.listResources()).resources.map(({ uri }) => uri), [
11
+ "guide://coffee/getting-started",
12
+ ]);
13
+ const resource = await client.readResource({ uri: "guide://coffee/getting-started" });
14
+ assert.match(resource.contents[0].text, /Strength is concentration/);
15
+ assert.match(resource.contents[0].text, /extraction is how much material left the grounds/);
16
+
17
+ assert.deepEqual((await client.listPrompts()).prompts.map(({ name }) => name), ["brew-guide"]);
18
+ const prompt = await client.getPrompt({
19
+ name: "brew-guide",
20
+ arguments: { topic: "brew-ratio" },
21
+ });
22
+ assert.match(prompt.messages[0].content.text, /Explain brew-ratio/);
23
+ });
@@ -0,0 +1,13 @@
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": ["src/**/*.ts"]
13
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@emseepea/create-resources-and-prompts-server",
3
+ "version": "0.0.0",
4
+ "description": "Create an Em See Pea server with resources and prompts.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/emseepea/emseepea.git",
9
+ "directory": "packages/create-resources-and-prompts-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-resources-and-prompts-server": "./dist/create.mjs"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "engines": {
26
+ "node": ">=22"
27
+ }
28
+ }