agentic-notify 0.2.0 → 0.3.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 +6 -3
- package/dist/{chunk-6QCYA3X7.js → chunk-ARL7FN6Y.js} +0 -99
- package/dist/chunk-O574VONP.js +101 -0
- package/dist/cli.js +2 -1
- package/dist/index.js +4 -2
- package/dist/mcp-bin.js +23 -14
- package/dist/mcp.js +102 -6
- package/dist/worker.js +4 -2
- package/package.json +1 -1
- package/dist/chunk-POSHKDNY.js +0 -86
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Notifications for humans and agents: in-app inbox, email and webhook delivery, with a CLI, API, MCP server and SDK.
|
|
7
7
|
|
|
8
|
-
**Status: 0.
|
|
8
|
+
**Status: 0.3.0.** Breaking for 0.1.0 code and databases, see the CHANGELOG upgrade steps. Works today: the notification model, preferences and mute, digest, a store port from agentic-identity with its memory and D1 adapters, signed webhook and email delivery through a dispatcher, an HTTP API in a Worker, an SDK, a CLI, MCP tools, per-recipient export and erase, and a retention sweep. Not done: a real email provider adapter, webhook endpoint management, and a web UI.
|
|
9
9
|
|
|
10
10
|
## Live demo
|
|
11
11
|
|
|
@@ -59,10 +59,13 @@ CLI, SDK and MCP talk to that Worker:
|
|
|
59
59
|
export NOTIFY_URL=https://notify.example.org NOTIFY_TOKEN=...
|
|
60
60
|
npx agentic-notify send --to human:ana --type mention --resource doc:d1 --body "Look at this"
|
|
61
61
|
npx agentic-notify list --unread
|
|
62
|
-
npx agentic-notify mcp # tools: list_notifications, read_notification, mark_read,
|
|
63
|
-
# mark_all_read, get_preferences, set_preferences,
|
|
62
|
+
npx agentic-notify mcp # tools: ping, list_notifications, read_notification, mark_read,
|
|
63
|
+
# mark_all_read, get_preferences, set_preferences, unread_count, digest,
|
|
64
|
+
# export_data, erase_data, send_notification
|
|
64
65
|
```
|
|
65
66
|
|
|
67
|
+
The MCP server needs `NOTIFY_URL` and `NOTIFY_TOKEN`. Without them only `ping` works. `erase_data` needs `confirm: true`.
|
|
68
|
+
|
|
66
69
|
```ts
|
|
67
70
|
import { createClient } from "agentic-notify/sdk";
|
|
68
71
|
const client = createClient({ baseUrl: process.env.NOTIFY_URL!, token: process.env.NOTIFY_TOKEN! });
|
|
@@ -1,101 +1,3 @@
|
|
|
1
|
-
// package.json
|
|
2
|
-
var package_default = {
|
|
3
|
-
name: "agentic-notify",
|
|
4
|
-
version: "0.2.0",
|
|
5
|
-
description: "Notifications for humans and agents: in-app inbox, webhook and email delivery, with SDK, CLI, MCP server and Worker API.",
|
|
6
|
-
keywords: [
|
|
7
|
-
"notifications",
|
|
8
|
-
"inbox",
|
|
9
|
-
"webhook",
|
|
10
|
-
"agents",
|
|
11
|
-
"mcp",
|
|
12
|
-
"cli",
|
|
13
|
-
"cloudflare-workers",
|
|
14
|
-
"typescript"
|
|
15
|
-
],
|
|
16
|
-
license: "MIT",
|
|
17
|
-
author: "Pooria Arab",
|
|
18
|
-
repository: {
|
|
19
|
-
type: "git",
|
|
20
|
-
url: "git+https://github.com/pooriaarab/agentic-notify.git"
|
|
21
|
-
},
|
|
22
|
-
type: "module",
|
|
23
|
-
private: false,
|
|
24
|
-
engines: {
|
|
25
|
-
node: ">=20"
|
|
26
|
-
},
|
|
27
|
-
files: [
|
|
28
|
-
"dist"
|
|
29
|
-
],
|
|
30
|
-
publishConfig: {
|
|
31
|
-
access: "public"
|
|
32
|
-
},
|
|
33
|
-
mcpName: "io.github.pooriaarab/agentic-notify",
|
|
34
|
-
main: "./dist/index.js",
|
|
35
|
-
types: "./dist/index.d.ts",
|
|
36
|
-
exports: {
|
|
37
|
-
".": {
|
|
38
|
-
types: "./dist/index.d.ts",
|
|
39
|
-
import: "./dist/index.js"
|
|
40
|
-
},
|
|
41
|
-
"./testing": {
|
|
42
|
-
types: "./dist/testing.d.ts",
|
|
43
|
-
import: "./dist/testing.js"
|
|
44
|
-
},
|
|
45
|
-
"./sdk": {
|
|
46
|
-
types: "./dist/sdk.d.ts",
|
|
47
|
-
import: "./dist/sdk.js"
|
|
48
|
-
},
|
|
49
|
-
"./worker": {
|
|
50
|
-
types: "./dist/worker.d.ts",
|
|
51
|
-
import: "./dist/worker.js"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
bin: {
|
|
55
|
-
"agentic-notify": "./dist/cli.js",
|
|
56
|
-
"agentic-notify-mcp": "./dist/mcp-bin.js"
|
|
57
|
-
},
|
|
58
|
-
scripts: {
|
|
59
|
-
build: "tsup",
|
|
60
|
-
typecheck: "tsc --noEmit",
|
|
61
|
-
test: "vitest run",
|
|
62
|
-
clean: "rm -rf dist",
|
|
63
|
-
prepack: "npm run build",
|
|
64
|
-
"ci:local": "npm run build && npm run typecheck && npm run check:worker && npm test",
|
|
65
|
-
"deploy:demo": "wrangler deploy --config wrangler.demo.jsonc",
|
|
66
|
-
"check:worker": "esbuild src/worker.ts --bundle --platform=neutral --format=esm --log-level=warning --outfile=node_modules/.cache/worker-check.js"
|
|
67
|
-
},
|
|
68
|
-
dependencies: {
|
|
69
|
-
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
70
|
-
"agentic-identity": "^0.4.0",
|
|
71
|
-
hono: "^4.13.14",
|
|
72
|
-
zod: "^3.25.0"
|
|
73
|
-
},
|
|
74
|
-
devDependencies: {
|
|
75
|
-
"@types/node": "^22.0.0",
|
|
76
|
-
esbuild: "^0.28.2",
|
|
77
|
-
miniflare: "^4.20260730.0",
|
|
78
|
-
tsup: "^8.0.0",
|
|
79
|
-
typescript: "^5.6.0",
|
|
80
|
-
vitest: "^3.0.0",
|
|
81
|
-
wrangler: "^4.155.0"
|
|
82
|
-
},
|
|
83
|
-
peerDependencies: {
|
|
84
|
-
vitest: ">=3"
|
|
85
|
-
},
|
|
86
|
-
peerDependenciesMeta: {
|
|
87
|
-
vitest: {
|
|
88
|
-
optional: true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/version.ts
|
|
94
|
-
if (typeof package_default.version !== "string" || package_default.version.length === 0) {
|
|
95
|
-
throw new Error("package.json carries no version string");
|
|
96
|
-
}
|
|
97
|
-
var VERSION = package_default.version;
|
|
98
|
-
|
|
99
1
|
// src/core/types.ts
|
|
100
2
|
import { z } from "zod";
|
|
101
3
|
var CHANNELS = ["inbox", "webhook", "email"];
|
|
@@ -386,7 +288,6 @@ function createNotifier(options) {
|
|
|
386
288
|
}
|
|
387
289
|
|
|
388
290
|
export {
|
|
389
|
-
VERSION,
|
|
390
291
|
CHANNELS,
|
|
391
292
|
recipientSchema,
|
|
392
293
|
typeNameSchema,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var package_default = {
|
|
3
|
+
name: "agentic-notify",
|
|
4
|
+
version: "0.3.0",
|
|
5
|
+
description: "Notifications for humans and agents: in-app inbox, webhook and email delivery, with SDK, CLI, MCP server and Worker API.",
|
|
6
|
+
keywords: [
|
|
7
|
+
"notifications",
|
|
8
|
+
"inbox",
|
|
9
|
+
"webhook",
|
|
10
|
+
"agents",
|
|
11
|
+
"mcp",
|
|
12
|
+
"cli",
|
|
13
|
+
"cloudflare-workers",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
license: "MIT",
|
|
17
|
+
author: "Pooria Arab",
|
|
18
|
+
repository: {
|
|
19
|
+
type: "git",
|
|
20
|
+
url: "git+https://github.com/pooriaarab/agentic-notify.git"
|
|
21
|
+
},
|
|
22
|
+
type: "module",
|
|
23
|
+
private: false,
|
|
24
|
+
engines: {
|
|
25
|
+
node: ">=20"
|
|
26
|
+
},
|
|
27
|
+
files: [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
publishConfig: {
|
|
31
|
+
access: "public"
|
|
32
|
+
},
|
|
33
|
+
mcpName: "io.github.pooriaarab/agentic-notify",
|
|
34
|
+
main: "./dist/index.js",
|
|
35
|
+
types: "./dist/index.d.ts",
|
|
36
|
+
exports: {
|
|
37
|
+
".": {
|
|
38
|
+
types: "./dist/index.d.ts",
|
|
39
|
+
import: "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./testing": {
|
|
42
|
+
types: "./dist/testing.d.ts",
|
|
43
|
+
import: "./dist/testing.js"
|
|
44
|
+
},
|
|
45
|
+
"./sdk": {
|
|
46
|
+
types: "./dist/sdk.d.ts",
|
|
47
|
+
import: "./dist/sdk.js"
|
|
48
|
+
},
|
|
49
|
+
"./worker": {
|
|
50
|
+
types: "./dist/worker.d.ts",
|
|
51
|
+
import: "./dist/worker.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
bin: {
|
|
55
|
+
"agentic-notify": "./dist/cli.js",
|
|
56
|
+
"agentic-notify-mcp": "./dist/mcp-bin.js"
|
|
57
|
+
},
|
|
58
|
+
scripts: {
|
|
59
|
+
build: "tsup",
|
|
60
|
+
typecheck: "tsc --noEmit",
|
|
61
|
+
test: "vitest run",
|
|
62
|
+
clean: "rm -rf dist",
|
|
63
|
+
prepack: "npm run build",
|
|
64
|
+
"ci:local": "npm run build && npm run typecheck && npm run check:worker && npm test",
|
|
65
|
+
"deploy:demo": "wrangler deploy --config wrangler.demo.jsonc",
|
|
66
|
+
"check:worker": "esbuild src/worker.ts --bundle --platform=neutral --format=esm --log-level=warning --outfile=node_modules/.cache/worker-check.js"
|
|
67
|
+
},
|
|
68
|
+
dependencies: {
|
|
69
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
70
|
+
"agentic-identity": "^0.4.0",
|
|
71
|
+
hono: "^4.13.14",
|
|
72
|
+
zod: "^3.25.0"
|
|
73
|
+
},
|
|
74
|
+
devDependencies: {
|
|
75
|
+
"@types/node": "^22.0.0",
|
|
76
|
+
esbuild: "^0.28.2",
|
|
77
|
+
miniflare: "^4.20260730.0",
|
|
78
|
+
tsup: "^8.0.0",
|
|
79
|
+
typescript: "^5.6.0",
|
|
80
|
+
vitest: "^3.0.0",
|
|
81
|
+
wrangler: "^4.155.0"
|
|
82
|
+
},
|
|
83
|
+
peerDependencies: {
|
|
84
|
+
vitest: ">=3"
|
|
85
|
+
},
|
|
86
|
+
peerDependenciesMeta: {
|
|
87
|
+
vitest: {
|
|
88
|
+
optional: true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/version.ts
|
|
94
|
+
if (typeof package_default.version !== "string" || package_default.version.length === 0) {
|
|
95
|
+
throw new Error("package.json carries no version string");
|
|
96
|
+
}
|
|
97
|
+
var VERSION = package_default.version;
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
VERSION
|
|
101
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
createClient
|
|
8
8
|
} from "./chunk-FJPEUDTG.js";
|
|
9
9
|
import "./chunk-KJKM56FT.js";
|
|
10
|
+
import "./chunk-ARL7FN6Y.js";
|
|
10
11
|
import {
|
|
11
12
|
VERSION
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-O574VONP.js";
|
|
13
14
|
|
|
14
15
|
// src/cli.ts
|
|
15
16
|
import { realpathSync } from "fs";
|
package/dist/index.js
CHANGED
|
@@ -17,11 +17,13 @@ import {
|
|
|
17
17
|
CHANNELS,
|
|
18
18
|
DEFAULT_CHANNELS,
|
|
19
19
|
NotFoundError,
|
|
20
|
-
VERSION,
|
|
21
20
|
createNotifier,
|
|
22
21
|
defaultPreferences,
|
|
23
22
|
recipientKey
|
|
24
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ARL7FN6Y.js";
|
|
24
|
+
import {
|
|
25
|
+
VERSION
|
|
26
|
+
} from "./chunk-O574VONP.js";
|
|
25
27
|
export {
|
|
26
28
|
CHANNELS,
|
|
27
29
|
D1_SCHEMA,
|
package/dist/mcp-bin.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-3N77SYRA.js";
|
|
6
|
-
import {
|
|
7
|
-
createClient
|
|
8
|
-
} from "./chunk-FJPEUDTG.js";
|
|
9
|
-
import "./chunk-KJKM56FT.js";
|
|
10
|
-
import "./chunk-6QCYA3X7.js";
|
|
3
|
+
VERSION
|
|
4
|
+
} from "./chunk-O574VONP.js";
|
|
11
5
|
|
|
12
6
|
// src/mcp-bin.ts
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
var HELP = `agentic-notify-mcp ${VERSION}
|
|
8
|
+
Usage: agentic-notify-mcp [--help | --version]
|
|
9
|
+
|
|
10
|
+
Runs the MCP server on stdio. An MCP client starts it.
|
|
11
|
+
`;
|
|
12
|
+
var flag = process.argv[2];
|
|
13
|
+
if (flag === "--version" || flag === "-V") {
|
|
14
|
+
process.stdout.write(`${VERSION}
|
|
15
|
+
`);
|
|
16
|
+
} else if (flag === "--help" || flag === "-h") {
|
|
17
|
+
process.stdout.write(HELP);
|
|
18
|
+
} else {
|
|
19
|
+
Promise.all([import("./mcp.js"), import("./sdk.js")]).then(([{ startMcp }, { createClient }]) => {
|
|
20
|
+
const { NOTIFY_URL, NOTIFY_TOKEN } = process.env;
|
|
21
|
+
const client = NOTIFY_URL && NOTIFY_TOKEN ? createClient({ baseUrl: NOTIFY_URL, token: NOTIFY_TOKEN }) : void 0;
|
|
22
|
+
return startMcp(client);
|
|
23
|
+
}).catch((error) => {
|
|
24
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/mcp.js
CHANGED
|
@@ -1,11 +1,107 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
PACKAGE_NAME
|
|
3
|
+
} from "./chunk-3N77SYRA.js";
|
|
4
|
+
import {
|
|
5
|
+
ApiError
|
|
6
|
+
} from "./chunk-FJPEUDTG.js";
|
|
7
7
|
import "./chunk-KJKM56FT.js";
|
|
8
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
preferencesSchema,
|
|
10
|
+
recipientSchema,
|
|
11
|
+
resourceRefSchema,
|
|
12
|
+
typeNameSchema
|
|
13
|
+
} from "./chunk-ARL7FN6Y.js";
|
|
14
|
+
import {
|
|
15
|
+
VERSION
|
|
16
|
+
} from "./chunk-O574VONP.js";
|
|
17
|
+
|
|
18
|
+
// src/mcp.ts
|
|
19
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
async function wrap(fn) {
|
|
23
|
+
try {
|
|
24
|
+
return { content: [{ type: "text", text: JSON.stringify(await fn()) }] };
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error instanceof ApiError) {
|
|
27
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: error.code, status: error.status }) }], isError: true };
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function createMcpServer(client) {
|
|
33
|
+
const server = new McpServer({ name: PACKAGE_NAME, version: VERSION });
|
|
34
|
+
const need = (fn) => () => wrap(async () => {
|
|
35
|
+
if (!client) throw new ApiError(0, "not_configured");
|
|
36
|
+
return fn(client);
|
|
37
|
+
});
|
|
38
|
+
const read = { readOnlyHint: true };
|
|
39
|
+
const write = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
40
|
+
server.registerTool(
|
|
41
|
+
"ping",
|
|
42
|
+
{ description: "Check that the server runs. Returns the package version.", inputSchema: {}, annotations: read },
|
|
43
|
+
async () => ({ content: [{ type: "text", text: JSON.stringify({ ok: true, version: VERSION }) }] })
|
|
44
|
+
);
|
|
45
|
+
server.registerTool("list_notifications", {
|
|
46
|
+
description: "List your notifications, newest first.",
|
|
47
|
+
inputSchema: { unreadOnly: z.boolean().optional(), limit: z.number().int().min(1).max(200).optional(), cursor: z.string().optional() },
|
|
48
|
+
annotations: read
|
|
49
|
+
}, (a) => need((c) => c.list(a))());
|
|
50
|
+
server.registerTool(
|
|
51
|
+
"read_notification",
|
|
52
|
+
{ description: "Get one notification by id.", inputSchema: { id: z.string() }, annotations: read },
|
|
53
|
+
({ id }) => need((c) => c.get(id))()
|
|
54
|
+
);
|
|
55
|
+
server.registerTool(
|
|
56
|
+
"mark_read",
|
|
57
|
+
{ description: "Mark one notification as read.", inputSchema: { id: z.string() }, annotations: write },
|
|
58
|
+
({ id }) => need((c) => c.markRead(id))()
|
|
59
|
+
);
|
|
60
|
+
server.registerTool(
|
|
61
|
+
"mark_all_read",
|
|
62
|
+
{ description: "Mark all your notifications as read.", inputSchema: {}, annotations: write },
|
|
63
|
+
need((c) => c.markAllRead())
|
|
64
|
+
);
|
|
65
|
+
server.registerTool(
|
|
66
|
+
"get_preferences",
|
|
67
|
+
{ description: "Read your notification preferences.", inputSchema: {}, annotations: read },
|
|
68
|
+
need((c) => c.getPreferences())
|
|
69
|
+
);
|
|
70
|
+
server.registerTool("set_preferences", {
|
|
71
|
+
description: "Replace your notification preferences: channels per type, mute, muted types.",
|
|
72
|
+
inputSchema: preferencesSchema.shape,
|
|
73
|
+
annotations: write
|
|
74
|
+
}, (a) => need((c) => c.setPreferences(a))());
|
|
75
|
+
server.registerTool(
|
|
76
|
+
"unread_count",
|
|
77
|
+
{ description: "Count your unread notifications.", inputSchema: {}, annotations: read },
|
|
78
|
+
need((c) => c.unreadCount())
|
|
79
|
+
);
|
|
80
|
+
server.registerTool("digest", {
|
|
81
|
+
description: "Group your unread notifications by type. Optional since: epoch milliseconds.",
|
|
82
|
+
inputSchema: { since: z.number().int().min(0).optional() },
|
|
83
|
+
annotations: read
|
|
84
|
+
}, ({ since }) => need((c) => c.digest(since))());
|
|
85
|
+
server.registerTool(
|
|
86
|
+
"export_data",
|
|
87
|
+
{ description: "Export all data held about you.", inputSchema: {}, annotations: read },
|
|
88
|
+
need((c) => c.exportData())
|
|
89
|
+
);
|
|
90
|
+
server.registerTool("erase_data", {
|
|
91
|
+
description: "Permanently delete all data held about you. Pass confirm: true. This cannot be undone.",
|
|
92
|
+
inputSchema: { confirm: z.literal(true) },
|
|
93
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }
|
|
94
|
+
}, () => need((c) => c.erase())());
|
|
95
|
+
server.registerTool("send_notification", {
|
|
96
|
+
description: "Send a notification. You must hold the send right. You are the actor.",
|
|
97
|
+
inputSchema: { recipient: recipientSchema, type: typeNameSchema, resource: resourceRefSchema, body: z.string().max(2e3) },
|
|
98
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
99
|
+
}, (a) => need((c) => c.send(a))());
|
|
100
|
+
return server;
|
|
101
|
+
}
|
|
102
|
+
async function startMcp(client) {
|
|
103
|
+
await createMcpServer(client).connect(new StdioServerTransport());
|
|
104
|
+
}
|
|
9
105
|
export {
|
|
10
106
|
createMcpServer,
|
|
11
107
|
startMcp
|
package/dist/worker.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NOTES,
|
|
3
3
|
NotFoundError,
|
|
4
|
-
VERSION,
|
|
5
4
|
createNotifier,
|
|
6
5
|
preferencesSchema,
|
|
7
6
|
recipientSchema,
|
|
8
7
|
resourceRefSchema,
|
|
9
8
|
typeNameSchema
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ARL7FN6Y.js";
|
|
10
|
+
import {
|
|
11
|
+
VERSION
|
|
12
|
+
} from "./chunk-O574VONP.js";
|
|
11
13
|
|
|
12
14
|
// src/api.ts
|
|
13
15
|
import { Hono } from "hono";
|
package/package.json
CHANGED
package/dist/chunk-POSHKDNY.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PACKAGE_NAME
|
|
3
|
-
} from "./chunk-3N77SYRA.js";
|
|
4
|
-
import {
|
|
5
|
-
ApiError
|
|
6
|
-
} from "./chunk-FJPEUDTG.js";
|
|
7
|
-
import {
|
|
8
|
-
VERSION,
|
|
9
|
-
preferencesSchema,
|
|
10
|
-
recipientSchema,
|
|
11
|
-
resourceRefSchema,
|
|
12
|
-
typeNameSchema
|
|
13
|
-
} from "./chunk-6QCYA3X7.js";
|
|
14
|
-
|
|
15
|
-
// src/mcp.ts
|
|
16
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
18
|
-
import { z } from "zod";
|
|
19
|
-
async function wrap(fn) {
|
|
20
|
-
try {
|
|
21
|
-
return { content: [{ type: "text", text: JSON.stringify(await fn()) }] };
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error instanceof ApiError) {
|
|
24
|
-
return { content: [{ type: "text", text: JSON.stringify({ error: error.code, status: error.status }) }], isError: true };
|
|
25
|
-
}
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function createMcpServer(client) {
|
|
30
|
-
const server = new McpServer({ name: PACKAGE_NAME, version: VERSION });
|
|
31
|
-
const need = (fn) => () => wrap(async () => {
|
|
32
|
-
if (!client) throw new ApiError(0, "not_configured");
|
|
33
|
-
return fn(client);
|
|
34
|
-
});
|
|
35
|
-
const read = { readOnlyHint: true };
|
|
36
|
-
const write = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
37
|
-
server.registerTool(
|
|
38
|
-
"ping",
|
|
39
|
-
{ description: "Check that the server runs. Returns the package version.", inputSchema: {}, annotations: read },
|
|
40
|
-
async () => ({ content: [{ type: "text", text: JSON.stringify({ ok: true, version: VERSION }) }] })
|
|
41
|
-
);
|
|
42
|
-
server.registerTool("list_notifications", {
|
|
43
|
-
description: "List your notifications, newest first.",
|
|
44
|
-
inputSchema: { unreadOnly: z.boolean().optional(), limit: z.number().int().min(1).max(200).optional(), cursor: z.string().optional() },
|
|
45
|
-
annotations: read
|
|
46
|
-
}, (a) => need((c) => c.list(a))());
|
|
47
|
-
server.registerTool(
|
|
48
|
-
"read_notification",
|
|
49
|
-
{ description: "Get one notification by id.", inputSchema: { id: z.string() }, annotations: read },
|
|
50
|
-
({ id }) => need((c) => c.get(id))()
|
|
51
|
-
);
|
|
52
|
-
server.registerTool(
|
|
53
|
-
"mark_read",
|
|
54
|
-
{ description: "Mark one notification as read.", inputSchema: { id: z.string() }, annotations: write },
|
|
55
|
-
({ id }) => need((c) => c.markRead(id))()
|
|
56
|
-
);
|
|
57
|
-
server.registerTool(
|
|
58
|
-
"mark_all_read",
|
|
59
|
-
{ description: "Mark all your notifications as read.", inputSchema: {}, annotations: write },
|
|
60
|
-
need((c) => c.markAllRead())
|
|
61
|
-
);
|
|
62
|
-
server.registerTool(
|
|
63
|
-
"get_preferences",
|
|
64
|
-
{ description: "Read your notification preferences.", inputSchema: {}, annotations: read },
|
|
65
|
-
need((c) => c.getPreferences())
|
|
66
|
-
);
|
|
67
|
-
server.registerTool("set_preferences", {
|
|
68
|
-
description: "Replace your notification preferences: channels per type, mute, muted types.",
|
|
69
|
-
inputSchema: preferencesSchema.shape,
|
|
70
|
-
annotations: write
|
|
71
|
-
}, (a) => need((c) => c.setPreferences(a))());
|
|
72
|
-
server.registerTool("send_notification", {
|
|
73
|
-
description: "Send a notification. You must hold the send right. You are the actor.",
|
|
74
|
-
inputSchema: { recipient: recipientSchema, type: typeNameSchema, resource: resourceRefSchema, body: z.string().max(2e3) },
|
|
75
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
76
|
-
}, (a) => need((c) => c.send(a))());
|
|
77
|
-
return server;
|
|
78
|
-
}
|
|
79
|
-
async function startMcp(client) {
|
|
80
|
-
await createMcpServer(client).connect(new StdioServerTransport());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
createMcpServer,
|
|
85
|
-
startMcp
|
|
86
|
-
};
|