@webhooks-cc/mcp 1.24.0 → 2.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 +41 -14
- package/dist/bin/mcp.js +1030 -583
- package/dist/{chunk-SOQIUGLA.mjs → chunk-VANGXSK7.mjs} +222 -3
- package/dist/index.d.mts +84 -10
- package/dist/index.d.ts +84 -10
- package/dist/index.js +1051 -580
- package/dist/index.mjs +290 -34
- package/dist/tools-Bg9zP80n.d.mts +276 -0
- package/dist/tools-Bg9zP80n.d.ts +276 -0
- package/dist/tools.d.mts +3 -200
- package/dist/tools.d.ts +3 -200
- package/dist/tools.js +226 -3
- package/dist/tools.mjs +15 -1
- package/package.json +4 -3
|
@@ -241,6 +241,209 @@ function compactRequest(request) {
|
|
|
241
241
|
return compact;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
// src/catalog.ts
|
|
245
|
+
var TOOL_GROUPS = {
|
|
246
|
+
core: "Endpoints, captured requests and emails, sending test webhooks, signatures, forwarding destinations, deliveries, previews of your local app and their logs, usage and approvals",
|
|
247
|
+
forwarding: "The rest of forwarding: preview what a destination would send, the endpoint's forwarding settings and signing secret, test deliveries",
|
|
248
|
+
layouts: "Email layouts and named fields: try layouts and fields on a captured email, add ready-made layouts, and AI setup",
|
|
249
|
+
extras: "Bulk endpoint changes, favourites, request counts and payload schemas",
|
|
250
|
+
teams: "Teams: members, invites, sharing endpoints with a team, and pricing team changes",
|
|
251
|
+
account: "The account: billing, API keys, connected agents, public share links to requests, and the display name",
|
|
252
|
+
domains: "Custom inbound email domains: add, verify, route and remove them",
|
|
253
|
+
sheets: "Google Sheets destinations: Google accounts, spreadsheets and their tabs",
|
|
254
|
+
names: "Preview names: reserve, release and password-protect them"
|
|
255
|
+
};
|
|
256
|
+
var TOOL_GROUP_NAMES = Object.keys(TOOL_GROUPS);
|
|
257
|
+
var read = { readOnly: true };
|
|
258
|
+
var write = {};
|
|
259
|
+
var update = { idempotent: true };
|
|
260
|
+
var remove = { destructive: true, idempotent: true };
|
|
261
|
+
var replace = { destructive: true, idempotent: true };
|
|
262
|
+
var outward = { openWorld: true };
|
|
263
|
+
function group(name, tools) {
|
|
264
|
+
return Object.fromEntries(
|
|
265
|
+
Object.entries(tools).map(([tool, behaviour]) => [tool, { group: name, ...behaviour }])
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
var TOOL_CATALOG = {
|
|
269
|
+
...group("core", {
|
|
270
|
+
create_endpoint: write,
|
|
271
|
+
list_endpoints: read,
|
|
272
|
+
get_endpoint: read,
|
|
273
|
+
// Replaces what it is given (a mock response, the signing secret).
|
|
274
|
+
update_endpoint: replace,
|
|
275
|
+
delete_endpoint: remove,
|
|
276
|
+
list_requests: read,
|
|
277
|
+
search_requests: read,
|
|
278
|
+
get_request: read,
|
|
279
|
+
wait_for_request: read,
|
|
280
|
+
wait_for_requests: read,
|
|
281
|
+
replay_request: outward,
|
|
282
|
+
compare_requests: read,
|
|
283
|
+
extract_from_request: read,
|
|
284
|
+
clear_requests: remove,
|
|
285
|
+
send_webhook: write,
|
|
286
|
+
send_to: outward,
|
|
287
|
+
test_webhook_flow: outward,
|
|
288
|
+
preview_webhook: read,
|
|
289
|
+
preview_response: read,
|
|
290
|
+
list_provider_templates: read,
|
|
291
|
+
verify_signature: read,
|
|
292
|
+
list_emails: read,
|
|
293
|
+
get_email: read,
|
|
294
|
+
wait_for_email: read,
|
|
295
|
+
send_test_email: write,
|
|
296
|
+
render_email: outward,
|
|
297
|
+
list_destinations: read,
|
|
298
|
+
add_destination: write,
|
|
299
|
+
update_destination: replace,
|
|
300
|
+
remove_destination: remove,
|
|
301
|
+
list_deliveries: read,
|
|
302
|
+
redeliver: outward,
|
|
303
|
+
share_port: outward,
|
|
304
|
+
list_shares: read,
|
|
305
|
+
share_requests: read,
|
|
306
|
+
stop_share: remove,
|
|
307
|
+
get_usage: read,
|
|
308
|
+
// Collecting an approved key hands it over once: not a pure read.
|
|
309
|
+
wait_for_approval: write,
|
|
310
|
+
describe: read
|
|
311
|
+
}),
|
|
312
|
+
...group("forwarding", {
|
|
313
|
+
preview_destination: read,
|
|
314
|
+
configure_forwarding: replace,
|
|
315
|
+
// rotate: true replaces the secret, and receivers holding the old one fail.
|
|
316
|
+
get_forwarding_secret: { destructive: true },
|
|
317
|
+
test_forwarding: outward
|
|
318
|
+
}),
|
|
319
|
+
...group("layouts", {
|
|
320
|
+
preview_layouts: read,
|
|
321
|
+
list_layout_templates: read,
|
|
322
|
+
add_layout_template: write,
|
|
323
|
+
preview_email_fields: read,
|
|
324
|
+
ai_setup_status: read,
|
|
325
|
+
// Sends the chosen emails to Anthropic once the owner approves.
|
|
326
|
+
ai_setup: outward
|
|
327
|
+
}),
|
|
328
|
+
...group("extras", {
|
|
329
|
+
create_endpoints: write,
|
|
330
|
+
delete_endpoints: remove,
|
|
331
|
+
favorite_endpoint: update,
|
|
332
|
+
count_requests: read,
|
|
333
|
+
generate_payload_schema: read
|
|
334
|
+
}),
|
|
335
|
+
...group("teams", {
|
|
336
|
+
list_teams: read,
|
|
337
|
+
list_team_members: read,
|
|
338
|
+
share_endpoint: update,
|
|
339
|
+
unshare_endpoint: remove,
|
|
340
|
+
create_team: write,
|
|
341
|
+
rename_team: update,
|
|
342
|
+
delete_team: remove,
|
|
343
|
+
remove_team_member: remove,
|
|
344
|
+
leave_team: remove,
|
|
345
|
+
invite_to_team: outward,
|
|
346
|
+
list_invites: read,
|
|
347
|
+
answer_invite: write,
|
|
348
|
+
withdraw_invite: remove,
|
|
349
|
+
quote_team_change: read
|
|
350
|
+
}),
|
|
351
|
+
...group("account", {
|
|
352
|
+
get_billing: read,
|
|
353
|
+
list_api_keys: read,
|
|
354
|
+
create_api_key: write,
|
|
355
|
+
revoke_api_key: remove,
|
|
356
|
+
rename_account: update,
|
|
357
|
+
list_connected_agents: read,
|
|
358
|
+
disconnect_agent: remove,
|
|
359
|
+
list_share_links: read,
|
|
360
|
+
create_share_link: write,
|
|
361
|
+
revoke_share_link: remove
|
|
362
|
+
}),
|
|
363
|
+
...group("domains", {
|
|
364
|
+
list_domains: read,
|
|
365
|
+
add_domain: write,
|
|
366
|
+
// A failed check counts toward lapsing a verified domain: not safe to repeat.
|
|
367
|
+
verify_domain: { destructive: true },
|
|
368
|
+
// Replaces the routing; a missing catch-all refuses mail.
|
|
369
|
+
route_domain: replace,
|
|
370
|
+
remove_domain: remove
|
|
371
|
+
}),
|
|
372
|
+
...group("sheets", {
|
|
373
|
+
list_google_connections: read,
|
|
374
|
+
connect_google: outward,
|
|
375
|
+
pick_spreadsheet: outward,
|
|
376
|
+
create_spreadsheet: outward,
|
|
377
|
+
list_sheet_tabs: { readOnly: true, openWorld: true },
|
|
378
|
+
disconnect_google: remove
|
|
379
|
+
}),
|
|
380
|
+
...group("names", {
|
|
381
|
+
// The log of what visitors asked a running preview for.
|
|
382
|
+
list_names: read,
|
|
383
|
+
reserve_name: write,
|
|
384
|
+
release_name: remove,
|
|
385
|
+
set_name_password: update,
|
|
386
|
+
// Opens the name to anyone again.
|
|
387
|
+
clear_name_password: { destructive: true, idempotent: true }
|
|
388
|
+
})
|
|
389
|
+
};
|
|
390
|
+
var ENABLE_TOOLS = "enable_tools";
|
|
391
|
+
function toolAnnotations(name) {
|
|
392
|
+
const entry = TOOL_CATALOG[name];
|
|
393
|
+
const readOnly = entry?.readOnly === true;
|
|
394
|
+
return {
|
|
395
|
+
title: toolTitle(name),
|
|
396
|
+
readOnlyHint: readOnly,
|
|
397
|
+
// MCP reads a missing destructiveHint as true on any tool that writes.
|
|
398
|
+
destructiveHint: !readOnly && entry?.destructive === true,
|
|
399
|
+
idempotentHint: readOnly || entry?.idempotent === true,
|
|
400
|
+
openWorldHint: entry?.openWorld === true
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function toolTitle(name) {
|
|
404
|
+
const words = name.split("_").map((word) => TITLE_WORDS[word] ?? word);
|
|
405
|
+
const first = words[0] ?? "";
|
|
406
|
+
return [first.charAt(0).toUpperCase() + first.slice(1), ...words.slice(1)].join(" ");
|
|
407
|
+
}
|
|
408
|
+
var TITLE_WORDS = {
|
|
409
|
+
api: "API",
|
|
410
|
+
ai: "AI",
|
|
411
|
+
mcp: "MCP"
|
|
412
|
+
};
|
|
413
|
+
function parseToolGroups(setting) {
|
|
414
|
+
if (setting === null || setting === void 0 || setting.trim() === "") return null;
|
|
415
|
+
const groups = /* @__PURE__ */ new Set(["core"]);
|
|
416
|
+
const unknown = [];
|
|
417
|
+
for (const raw of setting.split(/[\s,+]+/)) {
|
|
418
|
+
const name = raw.trim().toLowerCase();
|
|
419
|
+
if (!name) continue;
|
|
420
|
+
if (name === "all") {
|
|
421
|
+
for (const g of TOOL_GROUP_NAMES) groups.add(g);
|
|
422
|
+
} else if (TOOL_GROUP_NAMES.includes(name)) {
|
|
423
|
+
groups.add(name);
|
|
424
|
+
} else {
|
|
425
|
+
unknown.push(raw.trim());
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return { groups, unknown };
|
|
429
|
+
}
|
|
430
|
+
var LOADS_EVERYTHING = [
|
|
431
|
+
/^claude-code$/i,
|
|
432
|
+
/^claude-ai$/i,
|
|
433
|
+
/^claude$/i,
|
|
434
|
+
/codex/i,
|
|
435
|
+
/^openai-mcp$/i,
|
|
436
|
+
/chatgpt/i
|
|
437
|
+
];
|
|
438
|
+
function clientLoadsEverything(clientName) {
|
|
439
|
+
if (!clientName) return false;
|
|
440
|
+
const name = clientName.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
441
|
+
return LOADS_EVERYTHING.some((pattern) => pattern.test(name));
|
|
442
|
+
}
|
|
443
|
+
function defaultToolGroups(clientName) {
|
|
444
|
+
return clientLoadsEverything(clientName) ? new Set(TOOL_GROUP_NAMES) : /* @__PURE__ */ new Set(["core"]);
|
|
445
|
+
}
|
|
446
|
+
|
|
244
447
|
// src/tools.ts
|
|
245
448
|
var MAX_BODY_SIZE = MAX_OUTPUT;
|
|
246
449
|
var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
@@ -927,11 +1130,18 @@ function durationMs(value) {
|
|
|
927
1130
|
return null;
|
|
928
1131
|
}
|
|
929
1132
|
}
|
|
930
|
-
function toolTarget(target,
|
|
1133
|
+
function toolTarget(target, options, handles) {
|
|
1134
|
+
const remote = options.remote === true;
|
|
931
1135
|
return {
|
|
932
1136
|
tool(name, description, shape, handler) {
|
|
933
1137
|
if (remote && LOCAL_ONLY_TOOLS.has(name)) return { remove() {
|
|
934
1138
|
} };
|
|
1139
|
+
const entry = TOOL_CATALOG[name];
|
|
1140
|
+
if (!entry) throw new Error(`${name} has no entry in catalog.ts`);
|
|
1141
|
+
if (options.groups && !options.groups.has(entry.group)) return { remove() {
|
|
1142
|
+
} };
|
|
1143
|
+
if (options.readOnly && entry.readOnly !== true) return { remove() {
|
|
1144
|
+
} };
|
|
935
1145
|
const wrapped = remote ? async (args) => {
|
|
936
1146
|
const input = args;
|
|
937
1147
|
if (TARGET_URL_TOOLS.has(name) && input.targetUrl !== void 0) {
|
|
@@ -965,7 +1175,7 @@ function toolTarget(target, remote, handles) {
|
|
|
965
1175
|
}
|
|
966
1176
|
return handler(bounded);
|
|
967
1177
|
} : handler;
|
|
968
|
-
const handle = target.tool(name, description, shape, wrapped);
|
|
1178
|
+
const handle = target.tool(name, description, shape, wrapped, toolAnnotations(name));
|
|
969
1179
|
handles.push(handle);
|
|
970
1180
|
return handle;
|
|
971
1181
|
}
|
|
@@ -1041,7 +1251,7 @@ function withShareHints(list, remote = false) {
|
|
|
1041
1251
|
function registerTools(target, client, options = {}) {
|
|
1042
1252
|
const handles = [];
|
|
1043
1253
|
const remote = options.remote === true;
|
|
1044
|
-
const server = toolTarget(target,
|
|
1254
|
+
const server = toolTarget(target, options, handles);
|
|
1045
1255
|
const shareWith = remote ? REMOTE_SHARE : "share_port";
|
|
1046
1256
|
server.tool(
|
|
1047
1257
|
"create_endpoint",
|
|
@@ -2743,6 +2953,15 @@ function registerTools(target, client, options = {}) {
|
|
|
2743
2953
|
}
|
|
2744
2954
|
|
|
2745
2955
|
export {
|
|
2956
|
+
TOOL_GROUPS,
|
|
2957
|
+
TOOL_GROUP_NAMES,
|
|
2958
|
+
TOOL_CATALOG,
|
|
2959
|
+
ENABLE_TOOLS,
|
|
2960
|
+
toolAnnotations,
|
|
2961
|
+
toolTitle,
|
|
2962
|
+
parseToolGroups,
|
|
2963
|
+
clientLoadsEverything,
|
|
2964
|
+
defaultToolGroups,
|
|
2746
2965
|
compactRequest,
|
|
2747
2966
|
createEndpointShape,
|
|
2748
2967
|
listEndpointsShape,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,72 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/
|
|
2
|
-
export { REMOTE_MAX_WAIT_MS, RegisterToolsOptions, RegisteredToolHandle, ToolServer, registerTools } from './tools.mjs';
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
3
2
|
import { WebhooksCC } from '@webhooks-cc/sdk';
|
|
3
|
+
import { T as ToolGroup, a as ToolServer, R as RegisteredToolHandle } from './tools-Bg9zP80n.mjs';
|
|
4
|
+
export { E as ENABLE_TOOLS, b as REMOTE_MAX_WAIT_MS, c as RegisterToolsOptions, d as TOOL_CATALOG, e as TOOL_GROUPS, f as TOOL_GROUP_NAMES, g as ToolAnnotationsHint, h as clientLoadsEverything, i as defaultToolGroups, p as parseToolGroups, r as registerTools, t as toolAnnotations } from './tools-Bg9zP80n.mjs';
|
|
4
5
|
import 'zod';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The local (stdio) server's view of its tools: which groups it loads, and
|
|
9
|
+
* the enable_tools tool that loads more. The hosted server chooses its own
|
|
10
|
+
* groups per request and has no enable_tools.
|
|
11
|
+
*/
|
|
12
|
+
/** registerTools' view of a v2 McpServer: each tool with its title and annotations. */
|
|
13
|
+
declare function asToolServer(server: McpServer): ToolServer;
|
|
14
|
+
/** Which tools a local server lists. */
|
|
15
|
+
interface ToolSelection {
|
|
16
|
+
/** The groups named by WHK_MCP_TOOLS (or the tools option); null to choose by client. */
|
|
17
|
+
groups: ReadonlySet<ToolGroup> | null;
|
|
18
|
+
/** Only the tools that change nothing (WHK_MCP_READ_ONLY). */
|
|
19
|
+
readOnly: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ToolSelectionOptions {
|
|
22
|
+
/** Tool groups, such as "all" or "core,teams" (default: WHK_MCP_TOOLS, else by client). */
|
|
23
|
+
tools?: string;
|
|
24
|
+
/** Only the tools that change nothing (default: WHK_MCP_READ_ONLY). */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** The selection from the options, else the environment. Unknown group names go to stderr. */
|
|
28
|
+
declare function toolSelection(options?: ToolSelectionOptions): ToolSelection;
|
|
29
|
+
/**
|
|
30
|
+
* An account's tools on a local server, by group. show() registers the
|
|
31
|
+
* groups the server starts with (and enable_tools while any group is left),
|
|
32
|
+
* load() adds groups, and the client's name (clientIdentified) loads every
|
|
33
|
+
* group for clients that take long tool lists, unless WHK_MCP_TOOLS chose.
|
|
34
|
+
* Everything registered in one tick reaches the client as one list_changed,
|
|
35
|
+
* since the server debounces it.
|
|
36
|
+
*/
|
|
37
|
+
declare class LocalToolGroups {
|
|
38
|
+
private readonly server;
|
|
39
|
+
readonly selection: ToolSelection;
|
|
40
|
+
private client;
|
|
41
|
+
private loaded;
|
|
42
|
+
private handles;
|
|
43
|
+
private enableTools;
|
|
44
|
+
private clientKnown;
|
|
45
|
+
private clientName;
|
|
46
|
+
constructor(server: ToolServer, selection: ToolSelection);
|
|
47
|
+
/** The groups an account's tools start with. */
|
|
48
|
+
private startingGroups;
|
|
49
|
+
/** Registers the tools for an account; the handle removes them all again. */
|
|
50
|
+
show(client: WebhooksCC): RegisteredToolHandle;
|
|
51
|
+
/** Removes every account tool, enable_tools included. */
|
|
52
|
+
hide(): void;
|
|
53
|
+
/** The groups loaded now. */
|
|
54
|
+
loadedGroups(): ToolGroup[];
|
|
55
|
+
/**
|
|
56
|
+
* The client named itself (initialize, or a 2026-07-28 request's _meta).
|
|
57
|
+
* Without a WHK_MCP_TOOLS setting, a client that takes long tool lists
|
|
58
|
+
* gets every group. Only the first name counts.
|
|
59
|
+
*/
|
|
60
|
+
clientIdentified(name: string | undefined): void;
|
|
61
|
+
/** Registers the groups not loaded yet; returns the tools each one added. */
|
|
62
|
+
load(groups: readonly ToolGroup[]): Partial<Record<ToolGroup, string[]>>;
|
|
63
|
+
/** (Re)registers enable_tools with the current groups, or drops it once all are loaded. */
|
|
64
|
+
private showEnableTools;
|
|
65
|
+
}
|
|
66
|
+
/** Groups for a server, watching for the client that connects. */
|
|
67
|
+
declare function localToolGroups(server: McpServer, selection: ToolSelection): LocalToolGroups;
|
|
68
|
+
|
|
69
|
+
interface SandboxToolOptions extends ToolSelectionOptions {
|
|
7
70
|
/** API base URL (default: WHK_BASE_URL or https://webhooks.cc). */
|
|
8
71
|
baseUrl?: string;
|
|
9
72
|
/** Webhook receiver URL (default: WHK_WEBHOOK_URL or https://go.webhooks.cc). */
|
|
@@ -18,6 +81,11 @@ interface SandboxToolOptions {
|
|
|
18
81
|
credentialsFile?: string | false;
|
|
19
82
|
/** Called whenever the tools switch to a human's account, with a client for it. */
|
|
20
83
|
onConnected?: (client: WebhooksCC) => void;
|
|
84
|
+
/**
|
|
85
|
+
* The account tools' groups, when the caller already made them for this
|
|
86
|
+
* server (createServer does); otherwise made from tools and readOnly.
|
|
87
|
+
*/
|
|
88
|
+
toolGroups?: LocalToolGroups;
|
|
21
89
|
}
|
|
22
90
|
/**
|
|
23
91
|
* Registers the agent tools: the full tools when the credential file holds a
|
|
@@ -37,7 +105,7 @@ declare function registerPrompts(server: McpServer): void;
|
|
|
37
105
|
|
|
38
106
|
declare function registerResources(server: McpServer, client: WebhooksCC): void;
|
|
39
107
|
|
|
40
|
-
interface CreateServerOptions {
|
|
108
|
+
interface CreateServerOptions extends ToolSelectionOptions {
|
|
41
109
|
/** API key for webhooks.cc (default: reads WHK_API_KEY env var) */
|
|
42
110
|
apiKey?: string;
|
|
43
111
|
/** Custom webhook receiver URL (default: reads WHK_WEBHOOK_URL or https://go.webhooks.cc) */
|
|
@@ -52,18 +120,24 @@ interface CreateServerOptions {
|
|
|
52
120
|
credentialsFile?: string | false;
|
|
53
121
|
}
|
|
54
122
|
/**
|
|
55
|
-
* Create an MCP server with
|
|
123
|
+
* Create an MCP server with the webhooks.cc tools, prompts, and resources registered.
|
|
124
|
+
*
|
|
125
|
+
* Which tools it lists: the groups in `tools` (default WHK_MCP_TOOLS, such
|
|
126
|
+
* as "all" or "core,teams"); without a setting, the core tools, and every
|
|
127
|
+
* group for clients that take long tool lists (Claude Code, Codex, ChatGPT)
|
|
128
|
+
* once they connect. enable_tools loads more groups during a session.
|
|
129
|
+
* `readOnly` (default WHK_MCP_READ_ONLY) lists only the tools that change
|
|
130
|
+
* nothing.
|
|
56
131
|
*
|
|
57
132
|
* @example
|
|
58
133
|
* ```ts
|
|
59
134
|
* import { createServer } from "@webhooks-cc/mcp";
|
|
60
|
-
* import {
|
|
135
|
+
* import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
61
136
|
*
|
|
62
|
-
*
|
|
63
|
-
* await server.connect(new StdioServerTransport());
|
|
137
|
+
* serveStdio(() => createServer({ apiKey: "whcc_..." }));
|
|
64
138
|
* ```
|
|
65
139
|
*/
|
|
66
140
|
declare function createServer(options?: CreateServerOptions): McpServer;
|
|
67
141
|
|
|
68
|
-
export { createServer, registerAgentRegistrationTools, registerPrompts, registerResources, registerSandboxTools };
|
|
69
|
-
export type { CreateServerOptions, SandboxToolOptions };
|
|
142
|
+
export { LocalToolGroups, RegisteredToolHandle, ToolGroup, ToolServer, asToolServer, createServer, localToolGroups, registerAgentRegistrationTools, registerPrompts, registerResources, registerSandboxTools, toolSelection };
|
|
143
|
+
export type { CreateServerOptions, SandboxToolOptions, ToolSelection, ToolSelectionOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,72 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/
|
|
2
|
-
export { REMOTE_MAX_WAIT_MS, RegisterToolsOptions, RegisteredToolHandle, ToolServer, registerTools } from './tools.js';
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
3
2
|
import { WebhooksCC } from '@webhooks-cc/sdk';
|
|
3
|
+
import { T as ToolGroup, a as ToolServer, R as RegisteredToolHandle } from './tools-Bg9zP80n.js';
|
|
4
|
+
export { E as ENABLE_TOOLS, b as REMOTE_MAX_WAIT_MS, c as RegisterToolsOptions, d as TOOL_CATALOG, e as TOOL_GROUPS, f as TOOL_GROUP_NAMES, g as ToolAnnotationsHint, h as clientLoadsEverything, i as defaultToolGroups, p as parseToolGroups, r as registerTools, t as toolAnnotations } from './tools-Bg9zP80n.js';
|
|
4
5
|
import 'zod';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The local (stdio) server's view of its tools: which groups it loads, and
|
|
9
|
+
* the enable_tools tool that loads more. The hosted server chooses its own
|
|
10
|
+
* groups per request and has no enable_tools.
|
|
11
|
+
*/
|
|
12
|
+
/** registerTools' view of a v2 McpServer: each tool with its title and annotations. */
|
|
13
|
+
declare function asToolServer(server: McpServer): ToolServer;
|
|
14
|
+
/** Which tools a local server lists. */
|
|
15
|
+
interface ToolSelection {
|
|
16
|
+
/** The groups named by WHK_MCP_TOOLS (or the tools option); null to choose by client. */
|
|
17
|
+
groups: ReadonlySet<ToolGroup> | null;
|
|
18
|
+
/** Only the tools that change nothing (WHK_MCP_READ_ONLY). */
|
|
19
|
+
readOnly: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ToolSelectionOptions {
|
|
22
|
+
/** Tool groups, such as "all" or "core,teams" (default: WHK_MCP_TOOLS, else by client). */
|
|
23
|
+
tools?: string;
|
|
24
|
+
/** Only the tools that change nothing (default: WHK_MCP_READ_ONLY). */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** The selection from the options, else the environment. Unknown group names go to stderr. */
|
|
28
|
+
declare function toolSelection(options?: ToolSelectionOptions): ToolSelection;
|
|
29
|
+
/**
|
|
30
|
+
* An account's tools on a local server, by group. show() registers the
|
|
31
|
+
* groups the server starts with (and enable_tools while any group is left),
|
|
32
|
+
* load() adds groups, and the client's name (clientIdentified) loads every
|
|
33
|
+
* group for clients that take long tool lists, unless WHK_MCP_TOOLS chose.
|
|
34
|
+
* Everything registered in one tick reaches the client as one list_changed,
|
|
35
|
+
* since the server debounces it.
|
|
36
|
+
*/
|
|
37
|
+
declare class LocalToolGroups {
|
|
38
|
+
private readonly server;
|
|
39
|
+
readonly selection: ToolSelection;
|
|
40
|
+
private client;
|
|
41
|
+
private loaded;
|
|
42
|
+
private handles;
|
|
43
|
+
private enableTools;
|
|
44
|
+
private clientKnown;
|
|
45
|
+
private clientName;
|
|
46
|
+
constructor(server: ToolServer, selection: ToolSelection);
|
|
47
|
+
/** The groups an account's tools start with. */
|
|
48
|
+
private startingGroups;
|
|
49
|
+
/** Registers the tools for an account; the handle removes them all again. */
|
|
50
|
+
show(client: WebhooksCC): RegisteredToolHandle;
|
|
51
|
+
/** Removes every account tool, enable_tools included. */
|
|
52
|
+
hide(): void;
|
|
53
|
+
/** The groups loaded now. */
|
|
54
|
+
loadedGroups(): ToolGroup[];
|
|
55
|
+
/**
|
|
56
|
+
* The client named itself (initialize, or a 2026-07-28 request's _meta).
|
|
57
|
+
* Without a WHK_MCP_TOOLS setting, a client that takes long tool lists
|
|
58
|
+
* gets every group. Only the first name counts.
|
|
59
|
+
*/
|
|
60
|
+
clientIdentified(name: string | undefined): void;
|
|
61
|
+
/** Registers the groups not loaded yet; returns the tools each one added. */
|
|
62
|
+
load(groups: readonly ToolGroup[]): Partial<Record<ToolGroup, string[]>>;
|
|
63
|
+
/** (Re)registers enable_tools with the current groups, or drops it once all are loaded. */
|
|
64
|
+
private showEnableTools;
|
|
65
|
+
}
|
|
66
|
+
/** Groups for a server, watching for the client that connects. */
|
|
67
|
+
declare function localToolGroups(server: McpServer, selection: ToolSelection): LocalToolGroups;
|
|
68
|
+
|
|
69
|
+
interface SandboxToolOptions extends ToolSelectionOptions {
|
|
7
70
|
/** API base URL (default: WHK_BASE_URL or https://webhooks.cc). */
|
|
8
71
|
baseUrl?: string;
|
|
9
72
|
/** Webhook receiver URL (default: WHK_WEBHOOK_URL or https://go.webhooks.cc). */
|
|
@@ -18,6 +81,11 @@ interface SandboxToolOptions {
|
|
|
18
81
|
credentialsFile?: string | false;
|
|
19
82
|
/** Called whenever the tools switch to a human's account, with a client for it. */
|
|
20
83
|
onConnected?: (client: WebhooksCC) => void;
|
|
84
|
+
/**
|
|
85
|
+
* The account tools' groups, when the caller already made them for this
|
|
86
|
+
* server (createServer does); otherwise made from tools and readOnly.
|
|
87
|
+
*/
|
|
88
|
+
toolGroups?: LocalToolGroups;
|
|
21
89
|
}
|
|
22
90
|
/**
|
|
23
91
|
* Registers the agent tools: the full tools when the credential file holds a
|
|
@@ -37,7 +105,7 @@ declare function registerPrompts(server: McpServer): void;
|
|
|
37
105
|
|
|
38
106
|
declare function registerResources(server: McpServer, client: WebhooksCC): void;
|
|
39
107
|
|
|
40
|
-
interface CreateServerOptions {
|
|
108
|
+
interface CreateServerOptions extends ToolSelectionOptions {
|
|
41
109
|
/** API key for webhooks.cc (default: reads WHK_API_KEY env var) */
|
|
42
110
|
apiKey?: string;
|
|
43
111
|
/** Custom webhook receiver URL (default: reads WHK_WEBHOOK_URL or https://go.webhooks.cc) */
|
|
@@ -52,18 +120,24 @@ interface CreateServerOptions {
|
|
|
52
120
|
credentialsFile?: string | false;
|
|
53
121
|
}
|
|
54
122
|
/**
|
|
55
|
-
* Create an MCP server with
|
|
123
|
+
* Create an MCP server with the webhooks.cc tools, prompts, and resources registered.
|
|
124
|
+
*
|
|
125
|
+
* Which tools it lists: the groups in `tools` (default WHK_MCP_TOOLS, such
|
|
126
|
+
* as "all" or "core,teams"); without a setting, the core tools, and every
|
|
127
|
+
* group for clients that take long tool lists (Claude Code, Codex, ChatGPT)
|
|
128
|
+
* once they connect. enable_tools loads more groups during a session.
|
|
129
|
+
* `readOnly` (default WHK_MCP_READ_ONLY) lists only the tools that change
|
|
130
|
+
* nothing.
|
|
56
131
|
*
|
|
57
132
|
* @example
|
|
58
133
|
* ```ts
|
|
59
134
|
* import { createServer } from "@webhooks-cc/mcp";
|
|
60
|
-
* import {
|
|
135
|
+
* import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
61
136
|
*
|
|
62
|
-
*
|
|
63
|
-
* await server.connect(new StdioServerTransport());
|
|
137
|
+
* serveStdio(() => createServer({ apiKey: "whcc_..." }));
|
|
64
138
|
* ```
|
|
65
139
|
*/
|
|
66
140
|
declare function createServer(options?: CreateServerOptions): McpServer;
|
|
67
141
|
|
|
68
|
-
export { createServer, registerAgentRegistrationTools, registerPrompts, registerResources, registerSandboxTools };
|
|
69
|
-
export type { CreateServerOptions, SandboxToolOptions };
|
|
142
|
+
export { LocalToolGroups, RegisteredToolHandle, ToolGroup, ToolServer, asToolServer, createServer, localToolGroups, registerAgentRegistrationTools, registerPrompts, registerResources, registerSandboxTools, toolSelection };
|
|
143
|
+
export type { CreateServerOptions, SandboxToolOptions, ToolSelection, ToolSelectionOptions };
|