@notifkit/mcp 0.1.5 → 0.1.6

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/tools/operations.d.ts +4 -0
  3. package/dist/tools/operations.d.ts.map +1 -0
  4. package/dist/tools/operations.js +54 -0
  5. package/dist/tools/operations.js.map +1 -0
  6. package/dist/tools/projects.d.ts +4 -0
  7. package/dist/tools/projects.d.ts.map +1 -0
  8. package/dist/tools/projects.js +88 -0
  9. package/dist/tools/projects.js.map +1 -0
  10. package/dist/tools/sending.d.ts +4 -0
  11. package/dist/tools/sending.d.ts.map +1 -0
  12. package/dist/tools/sending.js +375 -0
  13. package/dist/tools/sending.js.map +1 -0
  14. package/dist/tools/shared.d.ts +17 -0
  15. package/dist/tools/shared.d.ts.map +1 -0
  16. package/dist/tools/shared.js +110 -0
  17. package/dist/tools/shared.js.map +1 -0
  18. package/dist/tools/templates.d.ts +4 -0
  19. package/dist/tools/templates.d.ts.map +1 -0
  20. package/dist/tools/templates.js +149 -0
  21. package/dist/tools/templates.js.map +1 -0
  22. package/dist/tools/users.d.ts +4 -0
  23. package/dist/tools/users.d.ts.map +1 -0
  24. package/dist/tools/users.js +251 -0
  25. package/dist/tools/users.js.map +1 -0
  26. package/dist/tools/workflows.d.ts +4 -0
  27. package/dist/tools/workflows.d.ts.map +1 -0
  28. package/dist/tools/workflows.js +115 -0
  29. package/dist/tools/workflows.js.map +1 -0
  30. package/dist/tools.d.ts.map +1 -1
  31. package/dist/tools.js +12 -1124
  32. package/dist/tools.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/tools/operations.ts +84 -0
  35. package/src/tools/projects.ts +131 -0
  36. package/src/tools/sending.ts +484 -0
  37. package/src/tools/shared.ts +129 -0
  38. package/src/tools/templates.ts +206 -0
  39. package/src/tools/users.ts +330 -0
  40. package/src/tools/workflows.ts +158 -0
  41. package/src/tools.ts +12 -1502
@@ -0,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C,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpF,OAAO,oCAAoC,IAAI,CAAC,MAAM,GAAG,CAAC;IAC5D,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { NotifkitApi } from \"../client.js\";\nimport { CHANNELS, CONTACT_CHANNELS, PRIORITIES, handler } from \"./shared.js\";\n\nexport function registerSendingTools(server: McpServer, api: NotifkitApi): void {\n server.registerTool(\n \"send_notification\",\n {\n title: \"Send a notification\",\n description:\n \"Queue a notification and return immediately with its message id. This is the primitive behind \" +\n \"both one-off sends and broadcasts: target a single user by id, a list of user ids, a `segment` \" +\n \"(every user tagged with it), or a `topic` (every user opted in to it). Exactly one of `user`, \" +\n \"`segment`, or `topic` must be given. Set `sendAt` to schedule a future send, which can then be \" +\n \"inspected with list_scheduled. Delivery is filtered by each recipient's preferences, consent, and \" +\n \"quiet hours, so the number of messages actually delivered is usually lower than the audience size. \" +\n \"Call list_segments first when the user names an audience you have not confirmed exists, and \" +\n \"list_templates when you are unsure of the template id.\",\n inputSchema: {\n template: z.string().min(1).describe(\"Template id to render, e.g. 'order-shipped'.\"),\n user: z\n .union([z.string().min(1), z.array(z.string().min(1)).nonempty()])\n .optional()\n .describe(\n \"A single user id or a list of user ids. Mutually exclusive with segment and topic.\",\n ),\n segment: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"Send to every user tagged with this segment. Mutually exclusive with user and topic.\",\n ),\n topic: z\n .string()\n .min(1)\n .optional()\n .describe(\n \"Send to every user opted in to this topic. Mutually exclusive with user and segment.\",\n ),\n data: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Variables interpolated into the template's {{placeholders}}.\"),\n channels: z\n .array(z.enum(CHANNELS))\n .nonempty()\n .optional()\n .describe(\"Channels to use. Defaults to ['email'].\"),\n fallback: z\n .boolean()\n .optional()\n .describe(\n \"When true, channels are tried in order and only the first success counts. When false or \" +\n \"omitted, every listed channel is delivered to.\",\n ),\n priority: z\n .enum(PRIORITIES)\n .optional()\n .describe(\"Queue lane. 'critical' bypasses quiet hours and per-user rate limits.\"),\n sendAt: z\n .string()\n .datetime()\n .optional()\n .describe(\"ISO 8601 timestamp to send at. Omit to send now.\"),\n campaign: z\n .string()\n .min(1)\n .max(128)\n .optional()\n .describe(\n \"Label grouping this send for later reporting via get_campaign_stats. Set it on any send \" +\n \"whose results someone may ask about; without it the messages cannot be attributed.\",\n ),\n },\n annotations: { title: \"Send a notification\", readOnlyHint: false, idempotentHint: false },\n },\n handler(async (args) => {\n const targets = [args.user, args.segment, args.topic].filter((t) => t !== undefined);\n if (targets.length !== 1) {\n throw new Error(\"Provide exactly one of `user`, `segment`, or `topic`.\");\n }\n return api.post(\"/v1/notify\", args);\n }),\n );\n\n server.registerTool(\n \"send_campaign\",\n {\n title: \"Send a campaign to a list of addresses\",\n description:\n \"Send one template to a list of recipient destinations (email, SMS/phone, push tokens, webhook URLs, \" +\n \"Telegram chat ids, Discord webhook URLs, WhatsApp phone numbers, or Slack channel/user IDs/webhook URLs) given directly — the tool creates or updates a user \" +\n \"record for each address, then sends, and tags every message with a campaign label so the results \" +\n \"can be read back later with get_campaign_stats. Supports 'email', 'sms', 'push', 'webhook', \" +\n \"'telegram', 'discord', 'whatsapp', and 'slack' channels. Use this when the person supplies the recipients themselves \" +\n \"(a pasted list, a spreadsheet column). Always report the returned campaign label back to the user \" +\n \"— it is how they ask about results later. Suppressed addresses (previous unsubscribes, complaints, \" +\n \"hard bounces) are dropped automatically at send time, so the delivered count is normally lower than \" +\n \"the list size.\",\n inputSchema: {\n campaign: z\n .string()\n .min(1)\n .max(128)\n .describe(\n \"Label for this send, e.g. 'spring-sale-2026-08-13'. Must be unique per send — reusing a \" +\n \"label merges the two into one set of statistics.\",\n ),\n template: z.string().min(1).describe(\"Template id to render.\"),\n channel: z\n .enum(CONTACT_CHANNELS)\n .optional()\n .describe(\n \"Channel to send on ('email', 'sms', 'push', 'webhook', 'telegram', 'discord', 'whatsapp', or 'slack'). Defaults to 'email'.\",\n ),\n recipients: z\n .array(z.string().min(1))\n .min(1)\n .max(10000)\n .optional()\n .describe(\n \"Recipient destination addresses: email addresses for email, E.164 phone numbers for sms/whatsapp, \" +\n \"device tokens for push, URLs for webhook, chat ids for telegram, webhook URLs for discord, or channel/user IDs for slack.\",\n ),\n emails: z\n .array(z.string().email())\n .min(1)\n .max(10000)\n .optional()\n .describe(\n \"Recipient email addresses (alias for recipients when sending on email channel).\",\n ),\n data: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Variables interpolated into the template, shared by every recipient.\"),\n priority: z\n .enum(PRIORITIES)\n .optional()\n .describe(\n \"Queue lane. Leave unset for 'normal'; do not use 'critical' for marketing sends.\",\n ),\n sendAt: z\n .string()\n .datetime()\n .optional()\n .describe(\"ISO 8601 timestamp to send at. Omit to send now.\"),\n },\n annotations: { title: \"Send a campaign\", readOnlyHint: false, idempotentHint: false },\n },\n handler(async (args) => {\n const channel = args.channel ?? \"email\";\n const rawList = args.recipients ?? args.emails;\n if (!rawList || rawList.length === 0) {\n throw new Error(\"Provide a list of `recipients` (or `emails`) to send to.\");\n }\n\n const seen = new Set<string>();\n const recipients = [];\n for (const raw of rawList) {\n const target = channel === \"email\" ? raw.trim().toLowerCase() : raw.trim();\n if (seen.has(target)) continue;\n seen.add(target);\n\n // Every channel needs a contact on that channel to be reached. Chat\n // channels used to get a bare user record, and WhatsApp a phone\n // number filed as an SMS contact, so those campaigns sent nothing.\n const userRecord: Record<string, unknown> =\n channel === \"email\"\n ? { id: `email:${target}`, email: target }\n : channel === \"sms\"\n ? { id: `phone:${target}`, phone: target }\n : channel === \"push\"\n ? { id: `push:${target}`, pushToken: target }\n : { id: `${channel}:${target}`, contacts: [{ channel, target }] };\n recipients.push(userRecord);\n }\n\n const result = await api.post<Record<string, unknown>>(\"/v1/notify\", {\n user: recipients,\n template: args.template,\n campaign: args.campaign,\n channels: [channel],\n ...(args.data ? { data: args.data } : {}),\n ...(args.priority ? { priority: args.priority } : {}),\n ...(args.sendAt ? { sendAt: args.sendAt } : {}),\n });\n\n const duplicates = rawList.length - recipients.length;\n return {\n campaign: args.campaign,\n channel,\n queued: recipients.length,\n ...(duplicates > 0 ? { duplicatesRemoved: duplicates } : {}),\n note:\n \"Queued, not yet delivered. Preferences, quiet hours, and suppressions are applied during \" +\n \"delivery — call get_campaign_stats for what actually landed.\",\n result,\n };\n }),\n );\n\n server.registerTool(\n \"list_campaigns\",\n {\n title: \"List campaigns\",\n description:\n \"List recent campaign labels with their size and when they last saw activity, newest first. Call \" +\n \"this when the user refers to a past send without naming its exact label ('the one I sent \" +\n \"yesterday') to find the label to pass to get_campaign_stats. Supports filtering by search query, \" +\n \"channel, date range, or minimum message count.\",\n inputSchema: {\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"How many campaigns to return. Defaults to 20.\"),\n search: z\n .string()\n .optional()\n .describe(\"Filter campaigns whose label contains this string (case-insensitive).\"),\n channel: z\n .enum(CHANNELS)\n .optional()\n .describe(\"Only list campaigns that sent messages on this channel.\"),\n since: z\n .string()\n .datetime()\n .optional()\n .describe(\n \"ISO 8601 timestamp; only return campaigns with activity on or after this date.\",\n ),\n until: z\n .string()\n .datetime()\n .optional()\n .describe(\n \"ISO 8601 timestamp; only return campaigns with activity on or before this date.\",\n ),\n minMessages: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(\"Minimum number of distinct messages/recipients for a campaign.\"),\n },\n annotations: { title: \"List campaigns\", readOnlyHint: true },\n },\n handler(async (args) => api.get(\"/v1/campaigns\", args)),\n );\n\n server.registerTool(\n \"get_campaign_stats\",\n {\n title: \"Get campaign performance\",\n description:\n \"The delivery and engagement funnel for one campaign: sent, delivered, failed, opened, clicked, \" +\n \"bounced, complained, unsubscribed, with rates and a per-channel breakdown. This is the tool for \" +\n \"'how did that send perform?'. Every count is people, not events — opening an email twice counts \" +\n \"once. Always surface the `warnings` field to the user: it says when opens and clicks are not \" +\n \"tracked on a channel, which is different from them being zero. A high complaint rate (above \" +\n \"~0.3%) is worth flagging unprompted, as it damages deliverability for all future sends.\",\n inputSchema: {\n campaign: z.string().min(1).describe(\"Campaign label, as returned by list_campaigns.\"),\n },\n annotations: { title: \"Get campaign performance\", readOnlyHint: true },\n },\n handler(async (args) => api.get(`/v1/campaigns/${encodeURIComponent(args.campaign)}/stats`)),\n );\n\n server.registerTool(\n \"list_suppressions\",\n {\n title: \"List suppressed addresses\",\n description:\n \"List destinations that will not be contacted again, with the reason each was suppressed \" +\n \"(unsubscribed, complained, bounced, or manual). Call this to explain why someone did not receive \" +\n \"a message, or to review unsubscribes after a campaign.\",\n inputSchema: {\n limit: z.number().int().min(1).max(500).optional().describe(\"How many rows to return.\"),\n channel: z.enum(CONTACT_CHANNELS).optional().describe(\"Only this channel.\"),\n reason: z\n .enum([\"unsubscribed\", \"complained\", \"bounced\", \"manual\"])\n .optional()\n .describe(\"Only suppressions with this reason.\"),\n target: z\n .string()\n .optional()\n .describe(\"Filter suppressions matching this email, phone, or push token.\"),\n },\n annotations: { title: \"List suppressed addresses\", readOnlyHint: true },\n },\n handler(async (args) => api.get(\"/v1/suppressions\", args)),\n );\n\n server.registerTool(\n \"suppress_address\",\n {\n title: \"Suppress an address\",\n description:\n \"Stop sending to a destination on a channel — use when someone asks to be removed by replying, \" +\n \"over the phone, or any route the provider does not report automatically. Takes effect on the \" +\n \"next send and outranks every other setting, including 'critical' priority.\",\n inputSchema: {\n channel: z.enum(CONTACT_CHANNELS).describe(\"Channel to suppress on.\"),\n target: z.string().min(1).describe(\"The address: email, phone number, or push token.\"),\n reason: z\n .enum([\"unsubscribed\", \"complained\", \"bounced\", \"manual\"])\n .optional()\n .describe(\"Why. Defaults to 'manual'.\"),\n },\n annotations: { title: \"Suppress an address\", readOnlyHint: false, idempotentHint: true },\n },\n handler(async (args) => api.post(\"/v1/suppressions\", args)),\n );\n\n server.registerTool(\n \"unsuppress_address\",\n {\n title: \"Remove a suppression\",\n description:\n \"Re-enable sending to a previously suppressed destination. Only do this on an explicit request \" +\n \"from the user — a suppression usually records that the person asked not to be contacted, and \" +\n \"removing it to fix a low delivery count is how a sending domain gets blocked. Confirm before \" +\n \"calling.\",\n inputSchema: {\n channel: z.enum(CONTACT_CHANNELS).describe(\"Channel the suppression is on.\"),\n target: z.string().min(1).describe(\"The suppressed address.\"),\n },\n annotations: {\n title: \"Remove a suppression\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n },\n },\n handler(async (args) => {\n await api.request(\n \"DELETE\",\n `/v1/suppressions/${encodeURIComponent(args.channel)}/${encodeURIComponent(args.target)}`,\n );\n return `Removed the suppression on ${args.target} for ${args.channel}.`;\n }),\n );\n\n server.registerTool(\n \"list_segments\",\n {\n title: \"List segments\",\n description:\n \"List every segment tag currently in use across the project's users. Call this to discover the \" +\n \"valid audiences for send_notification's `segment` argument before broadcasting.\",\n annotations: { title: \"List segments\", readOnlyHint: true },\n },\n handler(async () => api.get(\"/v1/segments\")),\n );\n\n server.registerTool(\n \"list_scheduled\",\n {\n title: \"List scheduled sends\",\n description:\n \"List notifications queued for future delivery — those given a `sendAt`, plus any deferred by a \" +\n \"recipient's quiet hours. Supports filtering by channel and pagination.\",\n inputSchema: {\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"How many rows to return. Defaults to 50.\"),\n cursor: z\n .string()\n .optional()\n .describe(\"Pagination cursor (taskId) from a previous call's `nextCursor`.\"),\n channel: z\n .enum(CHANNELS)\n .optional()\n .describe(\"Only list scheduled messages intended for this channel.\"),\n },\n annotations: { title: \"List scheduled sends\", readOnlyHint: true },\n },\n handler(async (args) => api.get(\"/v1/notifications/scheduled\", args)),\n );\n\n server.registerTool(\n \"get_delivery_logs\",\n {\n title: \"Get delivery logs\",\n description:\n \"Query the durable delivery log: what was sent, on which channel, and whether it succeeded. Call \" +\n \"this to answer 'did it go out?' after a send, or to investigate failures. Filter by template, \" +\n \"channel, status, campaign, or task ID. Results are paginated — pass the returned `nextCursor` \" +\n \"back as `cursor` for the next page.\",\n inputSchema: {\n limit: z\n .number()\n .int()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Rows per page. Defaults to the server's page size.\"),\n cursor: z\n .string()\n .optional()\n .describe(\"Pagination cursor from a previous call's `nextCursor`.\"),\n templateId: z.string().optional().describe(\"Only log entries rendered from this template.\"),\n workflowInstanceId: z\n .string()\n .optional()\n .describe(\"Only entries emitted by this workflow instance.\"),\n channel: z.enum(CHANNELS).optional().describe(\"Only entries delivered on this channel.\"),\n status: z\n .string()\n .optional()\n .describe(\n \"Delivery status to filter on, e.g. 'dispatched', 'delivered', 'failed', 'opened'.\",\n ),\n campaign: z\n .string()\n .optional()\n .describe(\"Only log entries tagged with this campaign label.\"),\n taskId: z\n .string()\n .optional()\n .describe(\"Only log entries for this specific notification task ID.\"),\n search: z\n .string()\n .optional()\n .describe(\n \"Search keyword across task IDs, template IDs, provider message IDs, or campaign labels.\",\n ),\n },\n annotations: { title: \"Get delivery logs\", readOnlyHint: true },\n },\n handler(async (args) => api.get(\"/v1/notifications/logs\", args)),\n );\n\n server.registerTool(\n \"get_notification\",\n {\n title: \"Get notification status\",\n description:\n \"Fetch the delivery history and latest state of a specific notification by its task ID. \" +\n \"Shows each attempt, provider status, timestamps, and error messages.\",\n inputSchema: {\n taskId: z\n .string()\n .min(1)\n .describe(\"Task ID returned from send_notification or send_campaign.\"),\n },\n annotations: { title: \"Get notification status\", readOnlyHint: true },\n },\n handler(async (args) => api.get(`/v1/notifications/${encodeURIComponent(args.taskId)}`)),\n );\n\n server.registerTool(\n \"cancel_notification\",\n {\n title: \"Cancel a scheduled notification\",\n description:\n \"Cancel a pending or quiet-hours deferred notification before it is dispatched to the provider. \" +\n \"Takes the taskId from send_notification or list_scheduled.\",\n inputSchema: {\n taskId: z.string().min(1).describe(\"Task ID of the scheduled notification to cancel.\"),\n },\n annotations: {\n title: \"Cancel a scheduled notification\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n },\n },\n handler(async (args) => {\n await api.request(\"DELETE\", `/v1/notifications/${encodeURIComponent(args.taskId)}`);\n return `Cancelled scheduled notification ${args.taskId}.`;\n }),\n );\n}\n"]}
@@ -0,0 +1,17 @@
1
+ export declare const CHANNELS: readonly ["email", "sms", "push", "webhook", "in-app", "telegram", "discord", "whatsapp", "slack"];
2
+ export declare const CONTACT_CHANNELS: readonly ["email", "sms", "push", "webhook", "in-app", "telegram", "discord", "whatsapp", "slack"];
3
+ export declare const PRIORITIES: readonly ["low", "normal", "high", "critical"];
4
+ interface ToolResult {
5
+ [key: string]: unknown;
6
+ content: {
7
+ type: "text";
8
+ text: string;
9
+ }[];
10
+ isError?: boolean;
11
+ }
12
+ /** Wrap a handler so a failed request is reported to the model instead of killing the server. */
13
+ export declare function handler<T>(fn: (args: T) => Promise<unknown>): (args: T) => Promise<ToolResult>;
14
+ export type EscapeMode = "html" | "header" | "text";
15
+ export declare function renderContentNode(node: unknown, variables: Record<string, unknown>, mode: EscapeMode): unknown;
16
+ export {};
17
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,oGAUX,CAAC;AAEX,eAAO,MAAM,gBAAgB,oGAAW,CAAC;AACzC,eAAO,MAAM,UAAU,gDAAiD,CAAC;AAEzE,UAAU,UAAU;IAGlB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuBD,iGAAiG;AACjG,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,IAC5C,MAAM,CAAC,KAAG,OAAO,CAAC,UAAU,CAAC,CAO5C;AAiBD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAyCpD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,IAAI,EAAE,UAAU,GACf,OAAO,CAWT"}
@@ -0,0 +1,110 @@
1
+ import { NotifkitApiError } from "../client.js";
2
+ export const CHANNELS = [
3
+ "email",
4
+ "sms",
5
+ "push",
6
+ "webhook",
7
+ "in-app",
8
+ "telegram",
9
+ "discord",
10
+ "whatsapp",
11
+ "slack",
12
+ ];
13
+ // The server accepts contacts on every channel, in-app included.
14
+ export const CONTACT_CHANNELS = CHANNELS;
15
+ export const PRIORITIES = ["low", "normal", "high", "critical"];
16
+ /** Render any handler return value as the text payload MCP clients expect. */
17
+ function ok(value) {
18
+ const text = value === undefined
19
+ ? "Done."
20
+ : typeof value === "string"
21
+ ? value
22
+ : JSON.stringify(value, null, 2);
23
+ return { content: [{ type: "text", text }] };
24
+ }
25
+ function fail(error) {
26
+ const text = error instanceof NotifkitApiError
27
+ ? `notifkit API error (HTTP ${error.status}): ${error.message}`
28
+ : error instanceof Error
29
+ ? error.message
30
+ : String(error);
31
+ return { content: [{ type: "text", text }], isError: true };
32
+ }
33
+ /** Wrap a handler so a failed request is reported to the model instead of killing the server. */
34
+ export function handler(fn) {
35
+ return async (args) => {
36
+ try {
37
+ return ok(await fn(args));
38
+ }
39
+ catch (error) {
40
+ return fail(error);
41
+ }
42
+ };
43
+ }
44
+ function escapeHtml(unsafe) {
45
+ return String(unsafe)
46
+ .replace(/&/g, "&amp;")
47
+ .replace(/</g, "&lt;")
48
+ .replace(/>/g, "&gt;")
49
+ .replace(/"/g, "&quot;")
50
+ .replace(/'/g, "&#039;");
51
+ }
52
+ function escapeHeader(unsafe) {
53
+ return String(unsafe)
54
+ .replace(/[\r\n]+/g, " ")
55
+ .trim();
56
+ }
57
+ const HTML_FIELDS = new Set(["html", "htmlbody", "bodyhtml", "htmlcontent"]);
58
+ const HEADER_FIELDS = new Set([
59
+ "subject",
60
+ "title",
61
+ "from",
62
+ "replyto",
63
+ "cc",
64
+ "bcc",
65
+ "preheader",
66
+ "preview",
67
+ ]);
68
+ function escapeModeFor(key, inherited) {
69
+ const k = key.toLowerCase().replace(/[-_]/g, "");
70
+ if (HTML_FIELDS.has(k))
71
+ return "html";
72
+ if (HEADER_FIELDS.has(k))
73
+ return "header";
74
+ return inherited;
75
+ }
76
+ function interpolateValue(tmpl, variables, mode) {
77
+ return tmpl
78
+ .replace(/\{\{\{(\w+)\}\}\}/g, (_, k) => {
79
+ const raw = variables[k];
80
+ if (raw === undefined || raw === null)
81
+ return "";
82
+ return typeof raw === "string" ? raw : JSON.stringify(raw);
83
+ })
84
+ .replace(/\{\{(\w+)\}\}/g, (_, k) => {
85
+ const raw = variables[k];
86
+ if (raw === undefined || raw === null)
87
+ return "";
88
+ const val = typeof raw === "string" ? raw : JSON.stringify(raw);
89
+ if (mode === "html")
90
+ return escapeHtml(val);
91
+ if (mode === "header")
92
+ return escapeHeader(val);
93
+ return val;
94
+ });
95
+ }
96
+ export function renderContentNode(node, variables, mode) {
97
+ if (typeof node === "string")
98
+ return interpolateValue(node, variables, mode);
99
+ if (Array.isArray(node))
100
+ return node.map((item) => renderContentNode(item, variables, mode));
101
+ if (node && typeof node === "object") {
102
+ const out = {};
103
+ for (const [key, value] of Object.entries(node)) {
104
+ out[key] = renderContentNode(value, variables, escapeModeFor(key, mode));
105
+ }
106
+ return out;
107
+ }
108
+ return node;
109
+ }
110
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js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O,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7F,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAA+B,CAAC,EAAE,CAAC;YAC3E,GAAG,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { NotifkitApiError } from \"../client.js\";\n\nexport const CHANNELS = [\n \"email\",\n \"sms\",\n \"push\",\n \"webhook\",\n \"in-app\",\n \"telegram\",\n \"discord\",\n \"whatsapp\",\n \"slack\",\n] as const;\n// The server accepts contacts on every channel, in-app included.\nexport const CONTACT_CHANNELS = CHANNELS;\nexport const PRIORITIES = [\"low\", \"normal\", \"high\", \"critical\"] as const;\n\ninterface ToolResult {\n // The SDK's tool-result type carries an index signature for protocol\n // extensions; without one here an interface is not assignable to it.\n [key: string]: unknown;\n content: { type: \"text\"; text: string }[];\n isError?: boolean;\n}\n\n/** Render any handler return value as the text payload MCP clients expect. */\nfunction ok(value: unknown): ToolResult {\n const text =\n value === undefined\n ? \"Done.\"\n : typeof value === \"string\"\n ? value\n : JSON.stringify(value, null, 2);\n return { content: [{ type: \"text\", text }] };\n}\n\nfunction fail(error: unknown): ToolResult {\n const text =\n error instanceof NotifkitApiError\n ? `notifkit API error (HTTP ${error.status}): ${error.message}`\n : error instanceof Error\n ? error.message\n : String(error);\n return { content: [{ type: \"text\", text }], isError: true };\n}\n\n/** Wrap a handler so a failed request is reported to the model instead of killing the server. */\nexport function handler<T>(fn: (args: T) => Promise<unknown>) {\n return async (args: T): Promise<ToolResult> => {\n try {\n return ok(await fn(args));\n } catch (error) {\n return fail(error);\n }\n };\n}\n\nfunction escapeHtml(unsafe: string): string {\n return String(unsafe)\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n}\n\nfunction escapeHeader(unsafe: string): string {\n return String(unsafe)\n .replace(/[\\r\\n]+/g, \" \")\n .trim();\n}\n\nexport type EscapeMode = \"html\" | \"header\" | \"text\";\nconst HTML_FIELDS = new Set([\"html\", \"htmlbody\", \"bodyhtml\", \"htmlcontent\"]);\nconst HEADER_FIELDS = new Set([\n \"subject\",\n \"title\",\n \"from\",\n \"replyto\",\n \"cc\",\n \"bcc\",\n \"preheader\",\n \"preview\",\n]);\n\nfunction escapeModeFor(key: string, inherited: EscapeMode): EscapeMode {\n const k = key.toLowerCase().replace(/[-_]/g, \"\");\n if (HTML_FIELDS.has(k)) return \"html\";\n if (HEADER_FIELDS.has(k)) return \"header\";\n return inherited;\n}\n\nfunction interpolateValue(\n tmpl: string,\n variables: Record<string, unknown>,\n mode: EscapeMode,\n): string {\n return tmpl\n .replace(/\\{\\{\\{(\\w+)\\}\\}\\}/g, (_, k: string) => {\n const raw = variables[k];\n if (raw === undefined || raw === null) return \"\";\n return typeof raw === \"string\" ? raw : JSON.stringify(raw);\n })\n .replace(/\\{\\{(\\w+)\\}\\}/g, (_, k: string) => {\n const raw = variables[k];\n if (raw === undefined || raw === null) return \"\";\n const val = typeof raw === \"string\" ? raw : JSON.stringify(raw);\n if (mode === \"html\") return escapeHtml(val);\n if (mode === \"header\") return escapeHeader(val);\n return val;\n });\n}\n\nexport function renderContentNode(\n node: unknown,\n variables: Record<string, unknown>,\n mode: EscapeMode,\n): unknown {\n if (typeof node === \"string\") return interpolateValue(node, variables, mode);\n if (Array.isArray(node)) return node.map((item) => renderContentNode(item, variables, mode));\n if (node && typeof node === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node as Record<string, unknown>)) {\n out[key] = renderContentNode(value, variables, escapeModeFor(key, mode));\n }\n return out;\n }\n return node;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { NotifkitApi } from "../client.js";
3
+ export declare function registerTemplatesTools(server: McpServer, api: NotifkitApi): void;
4
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/tools/templates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAwMhF"}
@@ -0,0 +1,149 @@
1
+ import { z } from "zod";
2
+ import { CHANNELS, handler, renderContentNode } from "./shared.js";
3
+ export function registerTemplatesTools(server, api) {
4
+ server.registerTool("list_templates", {
5
+ title: "List templates",
6
+ description: "List registered templates with their channel and content. Supports filtering by channel, " +
7
+ "topic opt-out category, or limiting result count.",
8
+ inputSchema: {
9
+ limit: z
10
+ .number()
11
+ .int()
12
+ .min(1)
13
+ .max(100)
14
+ .optional()
15
+ .describe("Maximum number of templates to return."),
16
+ channel: z
17
+ .enum(CHANNELS)
18
+ .optional()
19
+ .describe("Only list templates that render for this channel."),
20
+ topic: z.string().optional().describe("Only list templates tagged with this topic."),
21
+ },
22
+ annotations: { title: "List templates", readOnlyHint: true },
23
+ }, handler(async (args) => api.get("/v1/templates", args)));
24
+ server.registerTool("get_template", {
25
+ title: "Get a template",
26
+ description: "Fetch one template by id, including its full per-channel content and any AI prompts.",
27
+ inputSchema: { id: z.string().min(1).describe("Template id.") },
28
+ annotations: { title: "Get a template", readOnlyHint: true },
29
+ }, handler(async (args) => api.get(`/v1/templates/${encodeURIComponent(args.id)}`)));
30
+ server.registerTool("upsert_template", {
31
+ title: "Create or update a template",
32
+ description: "Create a template, or overwrite an existing one with the same id. Content is a per-channel object " +
33
+ "whose values may contain {{variable}} placeholders filled by send_notification's `data`; escaping " +
34
+ "is decided by the destination field. Because this overwrites, call get_template first when " +
35
+ "editing one that already exists.",
36
+ inputSchema: {
37
+ id: z.string().min(1).describe("Template id, e.g. 'order-shipped'."),
38
+ channel: z.enum(CHANNELS).describe("Channel this template renders for."),
39
+ topic: z
40
+ .union([z.string().min(1), z.array(z.string().min(1))])
41
+ .optional()
42
+ .describe("Topic(s) this template belongs to, used for per-user topic opt-outs."),
43
+ content: z
44
+ .record(z.string(), z.unknown())
45
+ .describe("Channel-specific fields, e.g. { subject, body } for email."),
46
+ aiPrompts: z
47
+ .record(z.string(), z.string())
48
+ .optional()
49
+ .describe("Optional per-field LLM prompts applied before rendering."),
50
+ },
51
+ annotations: {
52
+ title: "Create or update a template",
53
+ readOnlyHint: false,
54
+ idempotentHint: true,
55
+ },
56
+ }, handler(async (args) => api.put("/v1/templates", { templates: [args] })));
57
+ server.registerTool("delete_template", {
58
+ title: "Delete a template",
59
+ description: "Permanently delete a registered template by its ID.",
60
+ inputSchema: {
61
+ id: z.string().min(1).describe("Template id to delete."),
62
+ },
63
+ annotations: {
64
+ title: "Delete a template",
65
+ readOnlyHint: false,
66
+ destructiveHint: true,
67
+ idempotentHint: true,
68
+ },
69
+ }, handler(async (args) => {
70
+ await api.delete(`/v1/templates/${encodeURIComponent(args.id)}`);
71
+ return `Deleted template ${args.id}.`;
72
+ }));
73
+ const previewTemplateHandler = async (args) => {
74
+ if (!args.id && !args.content) {
75
+ throw new Error("Provide either a template `id` or raw `content` to preview.");
76
+ }
77
+ let rawContent = args.content;
78
+ let templateChannel = args.channel;
79
+ if (args.id) {
80
+ const tmpl = await api.get(`/v1/templates/${encodeURIComponent(args.id)}`);
81
+ if (!rawContent) {
82
+ rawContent = tmpl.content;
83
+ }
84
+ if (!templateChannel && tmpl.channel) {
85
+ templateChannel = tmpl.channel;
86
+ }
87
+ }
88
+ const vars = args.data ?? {};
89
+ const rendered = renderContentNode(rawContent ?? {}, vars, "text");
90
+ const jsonStr = JSON.stringify(rawContent ?? {});
91
+ const placeholderMatches = Array.from(jsonStr.matchAll(/\{\{\{?(\w+)\}?\}\}/g)).map((m) => m[1]);
92
+ const placeholders = Array.from(new Set(placeholderMatches));
93
+ const resolvedVariables = placeholders.filter((p) => p in vars);
94
+ const unresolvedVariables = placeholders.filter((p) => !(p in vars));
95
+ return {
96
+ ...(args.id ? { templateId: args.id } : {}),
97
+ channel: templateChannel ?? "email",
98
+ rendered,
99
+ resolvedVariables,
100
+ unresolvedVariables: unresolvedVariables.length > 0 ? unresolvedVariables : undefined,
101
+ };
102
+ };
103
+ server.registerTool("preview_template", {
104
+ title: "Preview a template",
105
+ description: "Dry-run render a template with sample variable data before sending. Pass an existing template " +
106
+ "`id` or supply raw `content` directly. Interpolates {{variable}} placeholders and returns the " +
107
+ "rendered output alongside resolved/unresolved variable names.",
108
+ inputSchema: {
109
+ id: z.string().optional().describe("Template id to fetch and preview."),
110
+ content: z
111
+ .record(z.string(), z.unknown())
112
+ .optional()
113
+ .describe("Raw template content object (e.g. { subject, body }) to render without saving."),
114
+ data: z
115
+ .record(z.string(), z.unknown())
116
+ .optional()
117
+ .describe("Sample variable data to interpolate into the template's placeholders."),
118
+ channel: z
119
+ .enum(CHANNELS)
120
+ .optional()
121
+ .describe("Target channel (e.g. 'email', 'sms', 'push'). Defaults to the template's channel."),
122
+ },
123
+ annotations: { title: "Preview a template", readOnlyHint: true },
124
+ }, handler(previewTemplateHandler));
125
+ /** @deprecated Same handler as preview_template; removed at the next minor version. */
126
+ server.registerTool("render_template", {
127
+ title: "Render template content",
128
+ description: "Deprecated: use preview_template, which does the same thing; this tool will be removed. " +
129
+ "Render template content with variable data without dispatching any notifications. " +
130
+ "Accepts either an existing template `id` or raw `content` object.",
131
+ inputSchema: {
132
+ id: z.string().optional().describe("Template id to fetch and render."),
133
+ content: z
134
+ .record(z.string(), z.unknown())
135
+ .optional()
136
+ .describe("Raw template content object to render."),
137
+ data: z
138
+ .record(z.string(), z.unknown())
139
+ .optional()
140
+ .describe("Variables to interpolate into placeholders."),
141
+ channel: z
142
+ .enum(CHANNELS)
143
+ .optional()
144
+ .describe("Target channel. Defaults to template channel."),
145
+ },
146
+ annotations: { title: "Render template content", readOnlyHint: true },
147
+ }, handler(previewTemplateHandler));
148
+ }
149
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/tools/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,GAAgB;IACxE,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,2FAA2F;YAC3F,mDAAmD;QACrD,WAAW,EAAE;YACX,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,wCAAwC,CAAC;YACrD,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC,QAAQ,CAAC;iBACd,QAAQ,EAAE;iBACV,QAAQ,CAAC,mDAAmD,CAAC;YAChE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;SACrF;QACD,WAAW,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAA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AC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,yBAAyB;QAChC,WAAW,EACT,0FAA0F;YAC1F,oFAAoF;YACpF,mEAAmE;QACrE,WAAW,EAAE;YACX,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;YACtE,OAAO,EAAE,CAAC;iBACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;iBAC/B,QAAQ,EAAE;iBACV,QAAQ,CAAC,wCAAwC,CAAC;YACrD,IAAI,EAAE,CAAC;iBACJ,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;iBAC/B,QAAQ,EAAE;iBACV,QAAQ,CAAC,6CAA6C,CAAC;YAC1D,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC,QAAQ,CAAC;iBACd,QAAQ,EAAE;iBACV,QAAQ,CAAC,+CAA+C,CAAC;SAC7D;QACD,WAAW,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,IAAI,EAAE;KACtE,EACD,OAAO,CAAC,sBAAsB,CAAC,CAChC,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { NotifkitApi } from \"../client.js\";\nimport { CHANNELS, handler, renderContentNode } from \"./shared.js\";\n\nexport function registerTemplatesTools(server: McpServer, api: NotifkitApi): void {\n server.registerTool(\n \"list_templates\",\n {\n title: \"List templates\",\n description:\n \"List registered templates with their channel and content. Supports filtering by channel, \" +\n \"topic opt-out category, or limiting result count.\",\n inputSchema: {\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"Maximum number of templates to return.\"),\n channel: z\n .enum(CHANNELS)\n .optional()\n .describe(\"Only list templates that render for this channel.\"),\n topic: z.string().optional().describe(\"Only list templates tagged with this topic.\"),\n },\n annotations: { title: \"List templates\", readOnlyHint: true },\n },\n handler(async (args) => api.get(\"/v1/templates\", args)),\n );\n\n server.registerTool(\n \"get_template\",\n {\n title: \"Get a template\",\n description:\n \"Fetch one template by id, including its full per-channel content and any AI prompts.\",\n inputSchema: { id: z.string().min(1).describe(\"Template id.\") },\n annotations: { title: \"Get a template\", readOnlyHint: true },\n },\n handler(async (args) => api.get(`/v1/templates/${encodeURIComponent(args.id)}`)),\n );\n\n server.registerTool(\n \"upsert_template\",\n {\n title: \"Create or update a template\",\n description:\n \"Create a template, or overwrite an existing one with the same id. Content is a per-channel object \" +\n \"whose values may contain {{variable}} placeholders filled by send_notification's `data`; escaping \" +\n \"is decided by the destination field. Because this overwrites, call get_template first when \" +\n \"editing one that already exists.\",\n inputSchema: {\n id: z.string().min(1).describe(\"Template id, e.g. 'order-shipped'.\"),\n channel: z.enum(CHANNELS).describe(\"Channel this template renders for.\"),\n topic: z\n .union([z.string().min(1), z.array(z.string().min(1))])\n .optional()\n .describe(\"Topic(s) this template belongs to, used for per-user topic opt-outs.\"),\n content: z\n .record(z.string(), z.unknown())\n .describe(\"Channel-specific fields, e.g. { subject, body } for email.\"),\n aiPrompts: z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Optional per-field LLM prompts applied before rendering.\"),\n },\n annotations: {\n title: \"Create or update a template\",\n readOnlyHint: false,\n idempotentHint: true,\n },\n },\n handler(async (args) => api.put(\"/v1/templates\", { templates: [args] })),\n );\n\n server.registerTool(\n \"delete_template\",\n {\n title: \"Delete a template\",\n description: \"Permanently delete a registered template by its ID.\",\n inputSchema: {\n id: z.string().min(1).describe(\"Template id to delete.\"),\n },\n annotations: {\n title: \"Delete a template\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n },\n },\n handler(async (args) => {\n await api.delete(`/v1/templates/${encodeURIComponent(args.id)}`);\n return `Deleted template ${args.id}.`;\n }),\n );\n\n const previewTemplateHandler = async (args: {\n id?: string;\n content?: Record<string, unknown>;\n data?: Record<string, unknown>;\n channel?: (typeof CHANNELS)[number];\n }) => {\n if (!args.id && !args.content) {\n throw new Error(\"Provide either a template `id` or raw `content` to preview.\");\n }\n\n let rawContent = args.content;\n let templateChannel = args.channel;\n\n if (args.id) {\n const tmpl = await api.get<{\n id: string;\n channel?: (typeof CHANNELS)[number];\n content: Record<string, unknown>;\n }>(`/v1/templates/${encodeURIComponent(args.id)}`);\n if (!rawContent) {\n rawContent = tmpl.content;\n }\n if (!templateChannel && tmpl.channel) {\n templateChannel = tmpl.channel;\n }\n }\n\n const vars = args.data ?? {};\n const rendered = renderContentNode(rawContent ?? {}, vars, \"text\");\n\n const jsonStr = JSON.stringify(rawContent ?? {});\n const placeholderMatches = Array.from(jsonStr.matchAll(/\\{\\{\\{?(\\w+)\\}?\\}\\}/g)).map(\n (m) => m[1]!,\n );\n const placeholders = Array.from(new Set(placeholderMatches));\n const resolvedVariables = placeholders.filter((p) => p in vars);\n const unresolvedVariables = placeholders.filter((p) => !(p in vars));\n\n return {\n ...(args.id ? { templateId: args.id } : {}),\n channel: templateChannel ?? \"email\",\n rendered,\n resolvedVariables,\n unresolvedVariables: unresolvedVariables.length > 0 ? unresolvedVariables : undefined,\n };\n };\n\n server.registerTool(\n \"preview_template\",\n {\n title: \"Preview a template\",\n description:\n \"Dry-run render a template with sample variable data before sending. Pass an existing template \" +\n \"`id` or supply raw `content` directly. Interpolates {{variable}} placeholders and returns the \" +\n \"rendered output alongside resolved/unresolved variable names.\",\n inputSchema: {\n id: z.string().optional().describe(\"Template id to fetch and preview.\"),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Raw template content object (e.g. { subject, body }) to render without saving.\",\n ),\n data: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Sample variable data to interpolate into the template's placeholders.\"),\n channel: z\n .enum(CHANNELS)\n .optional()\n .describe(\n \"Target channel (e.g. 'email', 'sms', 'push'). Defaults to the template's channel.\",\n ),\n },\n annotations: { title: \"Preview a template\", readOnlyHint: true },\n },\n handler(previewTemplateHandler),\n );\n\n /** @deprecated Same handler as preview_template; removed at the next minor version. */\n server.registerTool(\n \"render_template\",\n {\n title: \"Render template content\",\n description:\n \"Deprecated: use preview_template, which does the same thing; this tool will be removed. \" +\n \"Render template content with variable data without dispatching any notifications. \" +\n \"Accepts either an existing template `id` or raw `content` object.\",\n inputSchema: {\n id: z.string().optional().describe(\"Template id to fetch and render.\"),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Raw template content object to render.\"),\n data: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Variables to interpolate into placeholders.\"),\n channel: z\n .enum(CHANNELS)\n .optional()\n .describe(\"Target channel. Defaults to template channel.\"),\n },\n annotations: { title: \"Render template content\", readOnlyHint: true },\n },\n handler(previewTemplateHandler),\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { NotifkitApi } from "../client.js";
3
+ export declare function registerUsersTools(server: McpServer, api: NotifkitApi): void;
4
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/tools/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAoU5E"}