@pidgeon-ai/mcp 0.2.0 → 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PCN Labs OÜ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -56,17 +56,39 @@ local checkout.
56
56
 
57
57
  ## Tools
58
58
 
59
- | Tool | What it does |
60
- | ----------------- | ----------------------------------------------------------- |
61
- | `list_addresses` | The addresses the key can reach; filter by `tenant_id` |
62
- | `create_address` | A new address, optionally `reply_only` and with an end date |
63
- | `get_address` | One address, its capabilities and its send policy |
64
- | `list_threads` | Conversations in one address |
65
- | `get_thread` | One conversation, by the `thread_id` a webhook gave you |
66
- | `list_messages` | The messages of a conversation |
67
- | `search_messages` | Full-text within one mailbox |
68
- | `send_message` | Send, subject to the address's send policy |
69
- | `list_send_rules` | Why a send was refused |
59
+ | Tool | What it does |
60
+ | ------------------ | ----------------------------------------------------------- |
61
+ | `list_addresses` | The addresses the key can reach; filter by `tenant_id` |
62
+ | `create_address` | A new address, optionally `reply_only` and with an end date |
63
+ | `get_address` | One address, its capabilities and its send policy |
64
+ | `list_threads` | Conversations in one address |
65
+ | `get_thread` | One conversation, by the `thread_id` a webhook gave you |
66
+ | `list_messages` | The messages of a conversation |
67
+ | `search_messages` | Full-text within one mailbox |
68
+ | `get_message` | One message with its body — a webhook carries only its id |
69
+ | `send_message` | Send, subject to the address's send policy |
70
+ | `reply_to_message` | Answer one; recipients and subject come off the original |
71
+ | `update_thread` | Hand a conversation to a person, or take it back |
72
+ | `update_message` | Mark read, star, or move to archive, spam or trash |
73
+ | `list_send_rules` | Why a send was refused |
74
+
75
+ ## Handing a conversation to a person
76
+
77
+ The thing this product is for, and the four tools above are the loop: read a
78
+ message, answer it, file it, and say who owns it.
79
+
80
+ ```
81
+ update_thread id=<thread_id> owner_type=human
82
+ ```
83
+
84
+ It appears in the web inbox and `thread.updated` tells whatever was driving
85
+ the conversation that it no longer is. `owner_type=agent` takes it back,
86
+ `status` is the queue it sits in, and `assignee_id` names which person has it.
87
+
88
+ **These were missing until 13 October**, when somebody built a procurement
89
+ desk on this server and found they could not draft a reply or hand a thread
90
+ over — four operations that all existed in the API and none of which was
91
+ exposed here. The promise at the bottom of this file was not true; it is now.
70
92
 
71
93
  ## Two settings worth knowing about
72
94
 
@@ -69,6 +69,11 @@ function configBlock(baseUrl) {
69
69
  if (baseUrl !== DEFAULT_BASE_URL) env.PIDGEON_BASE_URL = baseUrl;
70
70
  return { command: "npx", args: ["-y", "@pidgeon-ai/mcp"], env };
71
71
  }
72
+ var WHAT_IT_CAN_DO = {
73
+ read: "It can read mail and nothing else \u2014 a model holding it cannot reply, send or change anything.",
74
+ send: "It can read and send. It cannot create addresses, mint keys or grant access.",
75
+ admin: "It can do everything the API offers, including creating addresses and granting access."
76
+ };
72
77
  async function init(options) {
73
78
  const { apiKey, baseUrl, cwd, write, force, fetch, out } = options;
74
79
  if (!apiKey) {
@@ -78,10 +83,11 @@ async function init(options) {
78
83
  out(" PIDGEON_API_KEY=pgn_live_\u2026 npx -y @pidgeon-ai/mcp init");
79
84
  out("");
80
85
  out("Give it the narrowest access the agent needs \u2014 this hands it to a model.");
81
- return { ok: false, addresses: [], wrote: null };
86
+ return { ok: false, addresses: [], access: null, wrote: null };
82
87
  }
83
- const addresses = await reachableAddresses({ apiKey, baseUrl, fetch, out });
84
- if (addresses === null) return { ok: false, addresses: [], wrote: null };
88
+ const identity = await describeKey({ apiKey, baseUrl, fetch, out });
89
+ if (identity === null) return { ok: false, addresses: [], access: null, wrote: null };
90
+ const { addresses, access, reachesAll, expiresAt } = identity;
85
91
  if (addresses.length === 0) {
86
92
  out("That key works, and reaches no mailbox yet.");
87
93
  out("");
@@ -89,9 +95,27 @@ async function init(options) {
89
95
  out("a snapshot, so an address created after the key is not in it.");
90
96
  } else {
91
97
  const shown = addresses.slice(0, 5);
92
- out(`That key reaches ${addresses.length} address${addresses.length === 1 ? "" : "es"}:`);
98
+ const reach = reachesAll ? `That key reaches every address this workspace owns (${addresses.length} today):` : `That key reaches ${addresses.length} address${addresses.length === 1 ? "" : "es"}:`;
99
+ out(reach);
93
100
  for (const address of shown) out(` ${address}`);
94
101
  if (addresses.length > shown.length) out(` \u2026 and ${addresses.length - shown.length} more`);
102
+ if (reachesAll) {
103
+ out("");
104
+ out("An address created after this key will be in reach too, unlike a key");
105
+ out("granted a fixed list.");
106
+ }
107
+ }
108
+ if (access) {
109
+ out("");
110
+ out(`Access: ${access}. ${WHAT_IT_CAN_DO[access]}`);
111
+ }
112
+ if (expiresAt) {
113
+ const when = new Date(expiresAt);
114
+ const stale = Number.isNaN(when.getTime());
115
+ out("");
116
+ out(
117
+ stale ? `This key expires: ${expiresAt}.` : `This key stops working on ${when.toUTCString()}.`
118
+ );
95
119
  }
96
120
  const block = configBlock(baseUrl);
97
121
  const path = resolve(cwd, CONFIG_FILE);
@@ -101,7 +125,7 @@ async function init(options) {
101
125
  if (!result.ok) {
102
126
  out("");
103
127
  out(result.message);
104
- return { ok: false, addresses, wrote: null };
128
+ return { ok: false, addresses, access, wrote: null };
105
129
  }
106
130
  wrote = path;
107
131
  }
@@ -112,7 +136,42 @@ async function init(options) {
112
136
  out("");
113
137
  out("The key is read from the environment rather than written into the file,");
114
138
  out("so the config can be committed and the credential cannot.");
115
- return { ok: true, addresses, wrote };
139
+ return { ok: true, addresses, access, wrote };
140
+ }
141
+ async function describeKey(context) {
142
+ const [addresses, me] = await Promise.all([
143
+ reachableAddresses(context),
144
+ describeCredential(context)
145
+ ]);
146
+ if (addresses === null) return null;
147
+ return {
148
+ addresses,
149
+ access: me?.key?.access ?? null,
150
+ reachesAll: me?.key?.reaches_all_addresses ?? false,
151
+ expiresAt: me?.key?.expires_at ?? null
152
+ };
153
+ }
154
+ async function describeCredential(context) {
155
+ const { apiKey, baseUrl, fetch } = context;
156
+ try {
157
+ const response = await fetch(`${baseUrl}/me`, {
158
+ headers: { authorization: `Bearer ${apiKey}`, accept: "application/json" }
159
+ });
160
+ if (!response.ok) return null;
161
+ const body = await response.json();
162
+ const key = body.data?.key;
163
+ if (!key?.access) return null;
164
+ if (key.access !== "read" && key.access !== "send" && key.access !== "admin") return null;
165
+ return {
166
+ key: {
167
+ access: key.access,
168
+ reaches_all_addresses: key.reaches_all_addresses ?? false,
169
+ expires_at: key.expires_at ?? null
170
+ }
171
+ };
172
+ } catch {
173
+ return null;
174
+ }
116
175
  }
117
176
  async function reachableAddresses(context) {
118
177
  const { apiKey, baseUrl, fetch, out } = context;
@@ -184,12 +243,27 @@ var TOOLS = [
184
243
  {
185
244
  name: "create_address",
186
245
  title: "Create an address",
187
- description: 'Create an address your software owns. `send_policy: "reply_only"` makes it unable to write to anybody who has not written to it first, which is the right default for an agent. `expires_at` gives it an end date, after which it stops accepting mail.',
246
+ description: 'Create an address for an agent to use. Say where with `domain_id`, `domain` ("yourdomain.com") or a whole `address` \u2014 every address you already have carries its `domain_id`. **`inbox` decides what it is**: with one, mail is stored and a person can open it; without one it becomes an event and your webhook fires. `send_policy: "reply_only"` makes it unable to write to anybody who has not written to it first, which is the right default for an agent. `expires_at` gives it an end date, after which it stops accepting mail.',
188
247
  endpoint: "POST /identities",
189
248
  readOnly: false,
190
249
  inputSchema: {
191
- domain_id: z.string(),
192
- local_part: z.string(),
250
+ /*
251
+ * Three ways to say where, because `domain_id` alone was a value an
252
+ * agent could not obtain. `GET /domains` lists what a workspace owns and
253
+ * a shared domain is owned by nobody, so for an account that signed
254
+ * itself up the id appeared nowhere — a customer read it out of the
255
+ * production database on 13 October. Every address carries its
256
+ * `domain_id` now, and `domain` or a whole `address` work too.
257
+ */
258
+ domain_id: z.string().optional(),
259
+ domain: z.string().optional(),
260
+ address: z.string().optional(),
261
+ local_part: z.string().optional(),
262
+ /*
263
+ * Whether it keeps mail, which is the only thing that decides what an
264
+ * address can do. `type` is a label now — see `capabilities.ts`.
265
+ */
266
+ inbox: z.boolean().optional(),
193
267
  display_name: z.string().nullish(),
194
268
  type: z.enum(["human", "team", "application", "workflow", "agent"]).optional(),
195
269
  send_policy: z.enum(["open", "reply_only", "list"]).optional(),
@@ -208,11 +282,22 @@ var TOOLS = [
208
282
  {
209
283
  name: "list_threads",
210
284
  title: "List conversations",
211
- description: "Conversations in one address, newest first. Filter by `status` for the queue an agent should be working, or by `assignee_id` for what one person has taken.",
285
+ description: "Conversations in one address, newest first. Filter by `status` for the queue an agent should be working, by `owner_type` for what kind of thing is answering, or by `assignee_id` for what one person has taken \u2014 `unassigned` is the queue nobody has.",
212
286
  endpoint: "GET /threads",
213
287
  readOnly: true,
288
+ /*
289
+ * **The schema had three of these and the description promised five.**
290
+ * Reported by a customer as a contradiction, and it was the schema that
291
+ * was short: the route has honoured all of them since it was written, and
292
+ * `GET /threads` published none of them because it declared
293
+ * `paginationSchema` — so every generated client was missing them too.
294
+ * Fixed in `listThreadsSchema`; this mirrors it.
295
+ */
214
296
  inputSchema: {
215
- identity_id: z.string(),
297
+ identity_id: z.string().optional(),
298
+ status: z.enum(["open", "waiting", "resolved", "human_review"]).optional(),
299
+ owner_type: z.enum(["human", "automation", "agent"]).optional(),
300
+ assignee_id: z.string().optional(),
216
301
  limit: z.number().int().min(1).max(200).optional(),
217
302
  cursor: z.string().optional()
218
303
  }
@@ -239,12 +324,20 @@ var TOOLS = [
239
324
  },
240
325
  {
241
326
  name: "search_messages",
242
- title: "Search one mailbox",
243
- description: "Full-text search within a single address, ranked by relevance. One mailbox at a time, because searching across addresses somebody cannot all read is not a thing to offer.",
327
+ title: "Search messages",
328
+ description: "Full-text search across every address this credential can reach, ranked by relevance. Name an `identity_id` to search exactly one. Every result carries the `identity_id` it was found in, because a hit you cannot attribute to an address is a hit you cannot open.",
244
329
  endpoint: "GET /messages/search",
245
330
  readOnly: true,
331
+ /*
332
+ * `identity_id` is optional here because it became optional on the
333
+ * endpoint, and this tool said "one mailbox at a time" for weeks after
334
+ * that stopped being true — a tool narrower than the endpoint it adapts
335
+ * is the one thing this package is not allowed to be. An agent reading
336
+ * the description concluded that *"where did that invoice go"* was not a
337
+ * question Pidgeon could answer, which it had been for a while.
338
+ */
246
339
  inputSchema: {
247
- identity_id: z.string(),
340
+ identity_id: z.string().optional(),
248
341
  q: z.string(),
249
342
  limit: z.number().int().min(1).max(200).optional()
250
343
  }
@@ -255,17 +348,104 @@ var TOOLS = [
255
348
  description: "Send from an address this credential may send as. Refused if the address\u2019s send policy does not permit the recipient, or if the recipient previously bounced or reported mail as spam.",
256
349
  endpoint: "POST /messages",
257
350
  readOnly: false,
351
+ /*
352
+ * **This tool could not have worked.** It declared `identity_id` and
353
+ * `thread_id` — `POST /messages` accepts neither, and its schema is
354
+ * `.strict()` — and it omitted `from`, which is required. `call.ts` sends
355
+ * the input as the body verbatim by design, so every call was a 400.
356
+ *
357
+ * A customer reported the smaller half, that `send_message` takes a
358
+ * `thread_id` the REST route does not. The route was right; the tool was
359
+ * describing an API that does not exist. `mcp-adapter.test.ts` checked
360
+ * that the `METHOD /path` pair is real and never that the *fields* were,
361
+ * which is the gap — it checks both now.
362
+ *
363
+ * `in_reply_to` is how a message joins a conversation. There is no
364
+ * `thread_id` on send and there never was: the thread is derived from
365
+ * what you are answering.
366
+ */
258
367
  inputSchema: {
259
- identity_id: z.string(),
368
+ from: z.string(),
260
369
  to: z.union([z.string(), z.array(z.string())]),
261
370
  cc: z.union([z.string(), z.array(z.string())]).optional(),
371
+ bcc: z.union([z.string(), z.array(z.string())]).optional(),
262
372
  subject: z.string().optional(),
263
373
  text: z.string().optional(),
264
374
  html: z.string().optional(),
265
- thread_id: z.string().optional(),
375
+ attachment_ids: z.array(z.string()).optional(),
266
376
  in_reply_to: z.string().optional()
267
377
  }
268
378
  },
379
+ /*
380
+ * ---------------------------------------------------------------------
381
+ * The desk: reading one message, answering it, and saying who has it.
382
+ *
383
+ * **Without these the product's headline cannot be done over MCP.** A
384
+ * customer built a procurement agent on 13 October with a human
385
+ * procurement desk on this server and found it could not *"draft a counter
386
+ * to supplier B"* or *"hand Ferrum back to the agent"* — the four
387
+ * operations those need all exist in the API and none was exposed. This
388
+ * README's own promise is *if something is missing here, it is missing
389
+ * from the API*, and that was not true.
390
+ *
391
+ * Four and not ten. The menu is read on every call, so `reply-all`,
392
+ * `forward`, the bulk `actions` endpoint, `undo`, `raw` and the label
393
+ * endpoints stay out: `reply` covers the common answer, bulk and undo are
394
+ * affordances for a person with a list in front of them, and raw bytes are
395
+ * no use to a model. These four are the loop — read it, answer it, file
396
+ * it, say who owns it.
397
+ * ---------------------------------------------------------------------
398
+ */
399
+ {
400
+ name: "get_message",
401
+ title: "Read one message",
402
+ description: "One message, by id, with its body and its headers. **A webhook carries ids and never a body**, so this is how a handler turns `message.received` into the thing it is about.",
403
+ endpoint: "GET /messages/{id}",
404
+ readOnly: true,
405
+ inputSchema: { id: z.string() }
406
+ },
407
+ {
408
+ name: "reply_to_message",
409
+ title: "Reply to a message",
410
+ description: "The recipients, the subject and the thread are read off the message being answered, so you bring the words and nothing else. Use `to` only to change who it goes to.",
411
+ endpoint: "POST /messages/{id}/reply",
412
+ readOnly: false,
413
+ inputSchema: {
414
+ id: z.string(),
415
+ text: z.string().optional(),
416
+ html: z.string().optional(),
417
+ to: z.union([z.string(), z.array(z.string())]).optional(),
418
+ cc: z.union([z.string(), z.array(z.string())]).optional(),
419
+ bcc: z.union([z.string(), z.array(z.string())]).optional(),
420
+ attachment_ids: z.array(z.string()).optional()
421
+ }
422
+ },
423
+ {
424
+ name: "update_thread",
425
+ title: "Hand a conversation over, or take it back",
426
+ description: 'Who owns a conversation and where it has got to. `owner_type: "human"` hands it to a person \u2014 it appears in the web inbox and `thread.updated` tells whatever was driving it that it no longer is; `"agent"` takes it back. `status` is the queue it sits in, and `assignee_id` names which person has it.',
427
+ endpoint: "PATCH /threads/{id}",
428
+ readOnly: false,
429
+ inputSchema: {
430
+ id: z.string(),
431
+ status: z.enum(["open", "waiting", "resolved", "human_review"]).optional(),
432
+ owner_type: z.enum(["human", "automation", "agent"]).optional(),
433
+ assignee_id: z.string().optional()
434
+ }
435
+ },
436
+ {
437
+ name: "update_message",
438
+ title: "File a message",
439
+ description: "Mark one read or unread, star it, or move it to `archive`, `spam` or `trash`. An agent that has dealt with something should be able to say so, or the inbox it is working is the same length tomorrow.",
440
+ endpoint: "PATCH /messages/{id}",
441
+ readOnly: false,
442
+ inputSchema: {
443
+ id: z.string(),
444
+ is_read: z.boolean().optional(),
445
+ is_starred: z.boolean().optional(),
446
+ folder: z.enum(["inbox", "archive", "spam", "trash"]).optional()
447
+ }
448
+ },
269
449
  {
270
450
  name: "list_send_rules",
271
451
  title: "What an address may write to",
@@ -293,8 +473,9 @@ var TOOLS = [
293
473
 
294
474
  // src/index.ts
295
475
  var DEFAULT_BASE_URL2 = "https://pidgeon.ai/api/v1";
476
+ var VERSION = "0.4.0";
296
477
  function createServer(context) {
297
- const server = new McpServer({ name: "pidgeon", version: "0.1.0" });
478
+ const server = new McpServer({ name: "pidgeon", version: VERSION });
298
479
  for (const tool of TOOLS) {
299
480
  server.registerTool(
300
481
  tool.name,
@@ -356,7 +537,8 @@ async function main() {
356
537
 
357
538
  export {
358
539
  TOOLS,
540
+ VERSION,
359
541
  createServer,
360
542
  main
361
543
  };
362
- //# sourceMappingURL=chunk-6R2DWW3P.js.map
544
+ //# sourceMappingURL=chunk-W4SUTYGB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/call.ts","../src/init.ts","../src/tools.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n\nimport { callEndpoint, PidgeonHttpError } from './call.js';\nimport { init } from './init.js';\nimport { TOOLS } from './tools.js';\n\n/**\n * Pidgeon, as a Model Context Protocol server.\n *\n * A **protocol adapter over an API already at parity**, and nothing else. No\n * business logic, no database, no LLM, no state of its own. Every tool is an\n * endpoint — `call.ts` dispatches on the endpoint the tool declares rather\n * than on its name, so there is nowhere to put behaviour the API does not\n * have. `tests/unit/mcp-adapter.test.ts` holds the other half: every declared\n * endpoint exists in `public/openapi.json`.\n *\n * `architecture.md` §7 listed MCP as deliberately absent, beside \"no LLM, no\n * RAG, no agent runtime\". That entry was written when this product was email\n * hosting; what it sells now is a programmable mailbox, and the person who\n * wants one is building an agent. The premise changed rather than the\n * judgement — an agent runtime is still not being built, and the constraints\n * above are what keep this from becoming one. `decisions.md` §154.\n *\n * ## Authorization is the key, and only the key\n *\n * The credential comes from `PIDGEON_API_KEY` and every call carries it.\n * Nothing here decides what may be reached: the key's own ceiling and the\n * addresses it was granted do all of it, server-side, exactly as they do for\n * any other caller.\n *\n * That matters more here than anywhere else, because this is the single most\n * likely place for a broad credential to be handed to a model. A key created\n * with `access: 'read'` can be given to an agent that must never send, and\n * `decisions.md` §143 is why that holds however generously the key is\n * granted. The README says so in the first paragraph.\n */\n\nconst DEFAULT_BASE_URL = 'https://pidgeon.ai/api/v1';\n\n/**\n * What the server tells a client it is.\n *\n * **It said `0.1.0` while the package said `0.2.0`** — a hand-written literal\n * beside a published number, drifting quietly, which a customer spotted on 13\n * October by comparing the hosted server's `initialize` with npm. Nothing\n * breaks when these disagree, which is exactly why nobody notices: the only\n * person who can tell is somebody holding both.\n *\n * Still a literal, because reading `package.json` from a bundle that runs in\n * three places — npm, a stdio binary, and the hosted route — is a build\n * problem for no gain. `package-manifests.test.ts` pins it instead, the same\n * way it pins the clients to the contract.\n */\nexport const VERSION = '0.4.0';\n\nexport function createServer(context: { baseUrl: string; apiKey: string }): McpServer {\n const server = new McpServer({ name: 'pidgeon', version: VERSION });\n\n for (const tool of TOOLS) {\n server.registerTool(\n tool.name,\n {\n title: tool.title,\n description: tool.description,\n inputSchema: tool.inputSchema,\n annotations: {\n readOnlyHint: tool.readOnly,\n /*\n * Sending mail is not undoable and reaches somebody who did not ask\n * to be part of this. A client that asks before a destructive call\n * should be asking before that one.\n */\n destructiveHint: !tool.readOnly,\n openWorldHint: true,\n },\n },\n async (input: Record<string, unknown>) => {\n try {\n const result = await callEndpoint(tool, input, context);\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],\n };\n } catch (error) {\n /*\n * Reported as a tool error rather than thrown, which is what lets a\n * model read the reason and act on it — \"that address can only\n * reply to people who have written to it\" is a sentence it can do\n * something about, where a transport-level failure is not.\n */\n const message =\n error instanceof PidgeonHttpError\n ? `${error.code}: ${error.message}`\n : error instanceof Error\n ? error.message\n : 'The request failed.';\n\n return { isError: true, content: [{ type: 'text' as const, text: message }] };\n }\n },\n );\n }\n\n return server;\n}\n\nexport async function main(): Promise<void> {\n const apiKey = process.env.PIDGEON_API_KEY;\n const baseUrl = process.env.PIDGEON_BASE_URL ?? DEFAULT_BASE_URL;\n\n /*\n * `init` is a person at a terminal, not a client at a pipe.\n *\n * It is the only path in this package that may write to stdout — everywhere\n * else stdout is the protocol channel and a sentence there is a parse error\n * at the other end. Checked before the key, so a missing key gets the\n * installer's explanation rather than the server's one-line refusal.\n */\n if (process.argv[2] === 'init') {\n const result = await init({\n apiKey,\n baseUrl,\n cwd: process.cwd(),\n write: !process.argv.includes('--print'),\n force: process.argv.includes('--force'),\n fetch: globalThis.fetch,\n out: (line) => process.stdout.write(`${line}\\n`),\n });\n\n process.exit(result.ok ? 0 : 1);\n }\n\n if (!apiKey) {\n /*\n * To stderr and a non-zero exit. stdout is the protocol channel on a\n * stdio server, so a message written there is a parse error at the other\n * end rather than something a person reads.\n */\n process.stderr.write(\n 'PIDGEON_API_KEY is not set. Create a key at https://pidgeon.ai/app/developers/keys — ' +\n 'and give it the narrowest access the agent needs, because this hands it to a model.\\n',\n );\n process.exit(1);\n }\n\n const server = createServer({ baseUrl, apiKey });\n\n await server.connect(new StdioServerTransport());\n}\n\nexport { TOOLS } from './tools.js';\nexport type { ToolDefinition } from './tools.js';\n\n/*\n * **Nothing runs on import.** `cli.ts` is the binary; this file is a\n * library.\n *\n * It used to end with `if (process.env.PIDGEON_MCP_NO_MAIN !== '1')\n * void main()` — a guard the tests set so that importing `createServer`\n * did not open a transport on stdio. That worked for the tests and was a\n * trap for everybody else: the hosted server imports this package, and\n * importing it ran `main()`, which found no `PIDGEON_API_KEY` and called\n * `process.exit(1)`. **The whole web server died on boot**, with the MCP\n * server's own error message as the only clue. §345.\n *\n * An environment variable cannot fix that, because the problem is not\n * which value it has — it is that a library had a side effect at all.\n */\n","import type { ToolDefinition } from './tools.js';\n\n/**\n * Calling the endpoint a tool declares.\n *\n * **The tool's `endpoint` is its implementation**, not a label beside one.\n * That is deliberate and it is what makes \"this package is an adapter\" a\n * structural fact rather than a promise: there is no place to put behaviour\n * the API does not have, because nothing here dispatches on the tool's name.\n *\n * Path parameters come out of the input by name, and what is left becomes the\n * query string on a `GET` or `DELETE` and the body on a `POST` or `PATCH`.\n * The API's own schemas then validate it — this does not re-declare their\n * rules, because two copies of a validation rule is one copy that is wrong.\n *\n * It does not use `@pidgeon-ai/sdk` at runtime, only its types. The SDK is a\n * thin wrapper over the same requests, and going through it would add a layer\n * whose only job is to be a second place a path can be spelled wrong.\n */\n\nexport interface CallContext {\n baseUrl: string;\n apiKey: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport class PidgeonHttpError extends Error {\n readonly status: number;\n readonly code: string;\n\n constructor(message: string, status: number, code: string) {\n super(message);\n this.name = 'PidgeonHttpError';\n this.status = status;\n this.code = code;\n }\n}\n\nconst PATH_PARAM = /\\{([^}]+)\\}/g;\n\nexport async function callEndpoint(\n tool: ToolDefinition,\n input: Record<string, unknown>,\n context: CallContext,\n): Promise<unknown> {\n const [method, template] = splitEndpoint(tool.endpoint);\n\n const remaining = { ...input };\n\n /*\n * `{id}` is filled from the input and removed from it, so it cannot also\n * arrive as a query parameter — where the API would reject it as an unknown\n * field, since every request schema here is `.strict()`.\n */\n const path = template.replace(PATH_PARAM, (_match, name: string) => {\n const value = remaining[name];\n\n if (value === undefined || value === null || value === '') {\n throw new PidgeonHttpError(`\\`${name}\\` is required.`, 400, 'validation');\n }\n\n delete remaining[name];\n return encodeURIComponent(String(value));\n });\n\n const url = new URL(`${context.baseUrl}${path}`);\n const sendsBody = method === 'POST' || method === 'PATCH';\n\n if (!sendsBody) {\n for (const [key, value] of Object.entries(remaining)) {\n if (value !== undefined && value !== null) url.searchParams.set(key, String(value));\n }\n }\n\n const doFetch = context.fetch ?? globalThis.fetch;\n\n const response = await doFetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${context.apiKey}`,\n ...(sendsBody ? { 'Content-Type': 'application/json' } : {}),\n },\n body: sendsBody ? JSON.stringify(remaining) : undefined,\n });\n\n const payload = (await response.json().catch(() => null)) as {\n data?: unknown;\n error?: { code: string; message: string };\n } | null;\n\n if (!response.ok || payload?.error) {\n /*\n * The API's own sentence, passed through rather than rewritten. It is\n * written for somebody debugging an integration — \"that address is on\n * this address's block list\" — and a model relaying it to a person is\n * better served by the real reason than by \"the request failed\".\n */\n throw new PidgeonHttpError(\n payload?.error?.message ?? `Request failed with ${response.status}.`,\n response.status,\n payload?.error?.code ?? 'internal',\n );\n }\n\n return payload?.data ?? payload;\n}\n\nexport function splitEndpoint(endpoint: string): [string, string] {\n const space = endpoint.indexOf(' ');\n return [endpoint.slice(0, space), endpoint.slice(space + 1)];\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\n/**\n * `npx -y @pidgeon-ai/mcp init` — the install, as one command.\n *\n * The README has carried a correct block of JSON for as long as this package\n * has existed, and a block of JSON is not an install: somebody has to know\n * which file it goes in, paste it without breaking the file already there,\n * invent a name for the server, and then find out whether their key works by\n * asking a model to try.\n *\n * **The check is the part worth having.** A wrong key, a revoked key, or a\n * key granted no mailbox all fail the same way through an MCP client — the\n * tools are listed, the model calls one, and the answer is an error the\n * person never sees. This asks the API first and says what the key can\n * actually reach, which is the one question a copy-paste cannot answer.\n *\n * ## It writes `.mcp.json`, and says so\n *\n * That filename is the convention a project-scoped MCP config uses and\n * several clients read it from a project root. Deliberately **not** a map of\n * each client's own config path: those differ, they move between releases,\n * and a tool that writes confidently to the wrong one is worse than a tool\n * that writes somewhere predictable and tells you. The block it wrote is\n * printed either way, so moving it is a copy rather than a re-derivation.\n */\n\n/** The server's name in the config. One word, because a person types it. */\nconst SERVER_NAME = 'pidgeon';\n\nconst CONFIG_FILE = '.mcp.json';\n\nconst DEFAULT_BASE_URL = 'https://pidgeon.ai/api/v1';\n\ninterface InitOptions {\n apiKey: string | undefined;\n baseUrl: string;\n cwd: string;\n write: boolean;\n force: boolean;\n fetch: typeof globalThis.fetch;\n out: (line: string) => void;\n}\n\n/** What goes in the config. The key is referenced, never printed. */\nfunction configBlock(baseUrl: string): Record<string, unknown> {\n const env: Record<string, string> = { PIDGEON_API_KEY: '${PIDGEON_API_KEY}' };\n\n // Only when it is not production, so the common case stays the short case.\n if (baseUrl !== DEFAULT_BASE_URL) env.PIDGEON_BASE_URL = baseUrl;\n\n return { command: 'npx', args: ['-y', '@pidgeon-ai/mcp'], env };\n}\n\nexport interface InitResult {\n ok: boolean;\n /** Addresses the key can reach, when the check ran. */\n addresses: string[];\n /** The highest rung it reaches on any of them, from `GET /v1/me`. */\n access: Access | null;\n wrote: string | null;\n}\n\n/** The rungs, lowest first. `admin` is what a key has unless narrowed. */\nexport type Access = 'read' | 'send' | 'admin';\n\n/**\n * What a model can actually do with this key, said plainly.\n *\n * The reason this command now makes a second call. It printed which\n * addresses a key reaches and never what it may *do* with them, and an\n * agent builder reported the consequence on 15 October: *\"`read` is the\n * thing that surprises someone later\"* — later being the first time the\n * agent tries to answer an email and is refused, inside a model's tool\n * call, where the error is nobody's to read.\n *\n * A rung is also the one property of a key whose wrongness is silent at\n * setup. A revoked key fails immediately; a key granted nothing prints an\n * empty list. A key at `read` sets up perfectly and then cannot work.\n */\nconst WHAT_IT_CAN_DO: Record<Access, string> = {\n read: 'It can read mail and nothing else — a model holding it cannot reply, send or change anything.',\n send: 'It can read and send. It cannot create addresses, mint keys or grant access.',\n admin: 'It can do everything the API offers, including creating addresses and granting access.',\n};\n\nexport async function init(options: InitOptions): Promise<InitResult> {\n const { apiKey, baseUrl, cwd, write, force, fetch, out } = options;\n\n if (!apiKey) {\n out('PIDGEON_API_KEY is not set.');\n out('');\n out('Create one at https://pidgeon.ai/app/developers/keys, then:');\n out(' PIDGEON_API_KEY=pgn_live_… npx -y @pidgeon-ai/mcp init');\n out('');\n out('Give it the narrowest access the agent needs — this hands it to a model.');\n return { ok: false, addresses: [], access: null, wrote: null };\n }\n\n /*\n * The check, before anything is written. `GET /identities` is the cheapest\n * call that proves all three things at once: the key parses, it is live,\n * and it has been granted something. A key granted nothing returns an empty\n * list rather than an error, which is its own answer and a common one — a\n * key is created and the mailbox is granted separately.\n */\n const identity = await describeKey({ apiKey, baseUrl, fetch, out });\n if (identity === null) return { ok: false, addresses: [], access: null, wrote: null };\n\n const { addresses, access, reachesAll, expiresAt } = identity;\n\n if (addresses.length === 0) {\n out('That key works, and reaches no mailbox yet.');\n out('');\n out('Grant it one at https://pidgeon.ai/app/developers/keys — a key’s reach is');\n out('a snapshot, so an address created after the key is not in it.');\n } else {\n const shown = addresses.slice(0, 5);\n const reach = reachesAll\n ? `That key reaches every address this workspace owns (${addresses.length} today):`\n : `That key reaches ${addresses.length} address${addresses.length === 1 ? '' : 'es'}:`;\n\n out(reach);\n for (const address of shown) out(` ${address}`);\n if (addresses.length > shown.length) out(` … and ${addresses.length - shown.length} more`);\n\n if (reachesAll) {\n out('');\n out('An address created after this key will be in reach too, unlike a key');\n out('granted a fixed list.');\n }\n }\n\n /*\n * The rung, on its own line, whatever the reach. Printed even for a key\n * that reaches nothing: *what this key could do if you granted it\n * something* is the thing somebody is about to get wrong.\n */\n if (access) {\n out('');\n out(`Access: ${access}. ${WHAT_IT_CAN_DO[access]}`);\n }\n\n /*\n * And the date, which is the other way a key that works today stops.\n * `§342` gave keys an end; nothing told the person setting one up.\n */\n if (expiresAt) {\n const when = new Date(expiresAt);\n const stale = Number.isNaN(when.getTime());\n\n out('');\n out(\n stale\n ? `This key expires: ${expiresAt}.`\n : `This key stops working on ${when.toUTCString()}.`,\n );\n }\n\n const block = configBlock(baseUrl);\n const path = resolve(cwd, CONFIG_FILE);\n let wrote: string | null = null;\n\n if (write) {\n const result = merge(path, block, force);\n if (!result.ok) {\n out('');\n out(result.message);\n return { ok: false, addresses, access, wrote: null };\n }\n wrote = path;\n }\n\n out('');\n out(wrote ? `Wrote ${CONFIG_FILE}:` : `Add this to your MCP client’s config:`);\n out('');\n out(JSON.stringify({ mcpServers: { [SERVER_NAME]: block } }, null, 2));\n out('');\n out('The key is read from the environment rather than written into the file,');\n out('so the config can be committed and the credential cannot.');\n\n return { ok: true, addresses, access, wrote };\n}\n\n/**\n * Everything this command knows about the key, or `null` when the key itself\n * is the problem.\n *\n * **Two calls, in parallel, because they answer different questions.**\n * `GET /identities` names the addresses; `GET /v1/me` says what the\n * credential may do with them, which no other endpoint will tell you — the\n * reason that endpoint was built. They go together rather than in sequence\n * because neither depends on the other and this runs while somebody waits.\n *\n * `/v1/me` failing is not fatal on its own. It is newer than this command,\n * and a client pointed at a deployment that predates it should still get the\n * setup it came for — the rung is then simply unknown, which is honest, and\n * better than refusing to write a config over a field that did not exist\n * last month.\n */\nasync function describeKey(context: {\n apiKey: string;\n baseUrl: string;\n fetch: typeof globalThis.fetch;\n out: (line: string) => void;\n}): Promise<{\n addresses: string[];\n access: Access | null;\n reachesAll: boolean;\n expiresAt: string | null;\n} | null> {\n const [addresses, me] = await Promise.all([\n reachableAddresses(context),\n describeCredential(context),\n ]);\n\n if (addresses === null) return null;\n\n return {\n addresses,\n access: me?.key?.access ?? null,\n reachesAll: me?.key?.reaches_all_addresses ?? false,\n expiresAt: me?.key?.expires_at ?? null,\n };\n}\n\n/** `GET /v1/me`, or null on any failure. See `describeKey` for why. */\nasync function describeCredential(context: {\n apiKey: string;\n baseUrl: string;\n fetch: typeof globalThis.fetch;\n}): Promise<{\n key: { access: Access; reaches_all_addresses: boolean; expires_at: string | null } | null;\n} | null> {\n const { apiKey, baseUrl, fetch } = context;\n\n try {\n const response = await fetch(`${baseUrl}/me`, {\n headers: { authorization: `Bearer ${apiKey}`, accept: 'application/json' },\n });\n\n if (!response.ok) return null;\n\n const body = (await response.json()) as {\n data?: {\n key?: { access?: string; reaches_all_addresses?: boolean; expires_at?: string | null };\n };\n };\n\n const key = body.data?.key;\n if (!key?.access) return null;\n\n // A rung this client does not know is a rung it must not print.\n if (key.access !== 'read' && key.access !== 'send' && key.access !== 'admin') return null;\n\n return {\n key: {\n access: key.access,\n reaches_all_addresses: key.reaches_all_addresses ?? false,\n expires_at: key.expires_at ?? null,\n },\n };\n } catch {\n return null;\n }\n}\n\n/**\n * The addresses this key can reach, or `null` when the key is the problem.\n *\n * Every failure gets a sentence that says what to do, because \"401\" through\n * an MCP client is a model's problem and this is a person's.\n */\nasync function reachableAddresses(context: {\n apiKey: string;\n baseUrl: string;\n fetch: typeof globalThis.fetch;\n out: (line: string) => void;\n}): Promise<string[] | null> {\n const { apiKey, baseUrl, fetch, out } = context;\n\n let response: Response;\n\n try {\n response = await fetch(`${baseUrl}/identities`, {\n headers: { authorization: `Bearer ${apiKey}`, accept: 'application/json' },\n });\n } catch (error) {\n out(`Could not reach ${baseUrl}: ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n\n if (response.status === 401 || response.status === 403) {\n out('That key was refused. It may be revoked, or from another deployment.');\n out('Keys live at https://pidgeon.ai/app/developers/keys.');\n return null;\n }\n\n if (!response.ok) {\n out(`The API answered ${response.status}. Nothing was written.`);\n return null;\n }\n\n const body = (await response.json()) as { data?: { email?: string }[] };\n return (body.data ?? []).map((identity) => identity.email ?? '').filter(Boolean);\n}\n\n/**\n * Add the entry without destroying what is already in the file.\n *\n * A developer running this in a project that already talks to three MCP\n * servers must not lose them, and one who runs it twice must not be told off.\n * An entry that is already ours and already correct is a no-op; one that is\n * ours and different is the only case that needs a decision, and the decision\n * is theirs.\n */\nfunction merge(\n path: string,\n block: Record<string, unknown>,\n force: boolean,\n): { ok: true } | { ok: false; message: string } {\n let existing: Record<string, unknown> = {};\n\n try {\n existing = JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>;\n } catch (error) {\n // A missing file is the normal case. Anything else is a file we must not\n // overwrite, because we could not read what it holds.\n if ((error as { code?: string }).code !== 'ENOENT') {\n return {\n ok: false,\n message: `${path} exists and is not valid JSON, so nothing was written.`,\n };\n }\n }\n\n const servers = (existing.mcpServers ?? {}) as Record<string, unknown>;\n const current = servers[SERVER_NAME];\n\n if (current && !force && JSON.stringify(current) !== JSON.stringify(block)) {\n return {\n ok: false,\n message:\n `${path} already has a different \"${SERVER_NAME}\" server, so nothing was written.\\n` +\n 'Run again with --force to replace it, or edit the file by hand.',\n };\n }\n\n writeFileSync(\n path,\n `${JSON.stringify({ ...existing, mcpServers: { ...servers, [SERVER_NAME]: block } }, null, 2)}\\n`,\n );\n\n return { ok: true };\n}\n","import { z } from 'zod';\n\n/**\n * The tools this server offers, and the endpoint each one is.\n *\n * **This is an adapter, and this file is where that stays true.** Every tool\n * names the `METHOD /path` it calls, and `tests/unit/mcp-adapter.test.ts`\n * asserts that pair exists in `public/openapi.json`. So a tool cannot be\n * added for behaviour the API does not have — if one needs logic that is not\n * an endpoint, **the API is missing it**, and it gets built there.\n *\n * That constraint is the whole reason this package is allowed to exist.\n * `architecture.md` §7 put MCP on the do-not-build list when this product was\n * email hosting, and the premise changed rather than the judgement: what is\n * sold now is a programmable mailbox, and the buyer is somebody building an\n * agent. A protocol adapter over an API already at parity is thin. An agent\n * runtime is not, and this file is what keeps the second from growing out of\n * the first. `decisions.md` §153.\n */\n\nexport interface ToolDefinition {\n name: string;\n title: string;\n description: string;\n /** The endpoint this tool *is*. Checked against the published contract. */\n endpoint: `${'GET' | 'POST' | 'PATCH' | 'DELETE'} ${string}`;\n inputSchema: z.ZodRawShape;\n /** Whether it changes anything. MCP clients surface this before confirming. */\n readOnly: boolean;\n}\n\n/*\n * Deliberately not every endpoint.\n *\n * A tool list is a menu a model reads on every call, so length is a real\n * cost, and the ones left out are left out for reasons rather than by\n * omission: minting API keys and granting mailbox access are credential\n * operations that should be done by a person who can see what they are\n * agreeing to, and the raw attachment and export endpoints move bytes a\n * model has no use for. Anything here is something an agent doing the job\n * this product is for actually needs.\n */\nexport const TOOLS: ToolDefinition[] = [\n {\n name: 'list_addresses',\n title: 'List addresses',\n description:\n 'The addresses this credential can reach. Use `tenant_id` to list the addresses ' +\n 'belonging to one of your own customers.',\n endpoint: 'GET /identities',\n readOnly: true,\n inputSchema: {\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n tenant_id: z.string().optional(),\n },\n },\n {\n name: 'create_address',\n title: 'Create an address',\n description:\n 'Create an address for an agent to use. Say where with `domain_id`, `domain` ' +\n '(\"yourdomain.com\") or a whole `address` — every address you already have carries its ' +\n '`domain_id`. **`inbox` decides what it is**: with one, mail is stored and a person can ' +\n 'open it; without one it becomes an event and your webhook fires. ' +\n '`send_policy: \"reply_only\"` makes it unable to write to anybody who has not written to ' +\n 'it first, which is the right default for an agent. `expires_at` gives it an end date, ' +\n 'after which it stops accepting mail.',\n endpoint: 'POST /identities',\n readOnly: false,\n inputSchema: {\n /*\n * Three ways to say where, because `domain_id` alone was a value an\n * agent could not obtain. `GET /domains` lists what a workspace owns and\n * a shared domain is owned by nobody, so for an account that signed\n * itself up the id appeared nowhere — a customer read it out of the\n * production database on 13 October. Every address carries its\n * `domain_id` now, and `domain` or a whole `address` work too.\n */\n domain_id: z.string().optional(),\n domain: z.string().optional(),\n address: z.string().optional(),\n local_part: z.string().optional(),\n /*\n * Whether it keeps mail, which is the only thing that decides what an\n * address can do. `type` is a label now — see `capabilities.ts`.\n */\n inbox: z.boolean().optional(),\n display_name: z.string().nullish(),\n type: z.enum(['human', 'team', 'application', 'workflow', 'agent']).optional(),\n send_policy: z.enum(['open', 'reply_only', 'list']).optional(),\n expires_at: z.string().optional(),\n tenant_id: z.string().optional(),\n },\n },\n {\n name: 'get_address',\n title: 'Read one address',\n description:\n 'One address, by id. Answers its type, its capabilities, its send policy and its end ' +\n 'date, which is how to check what an address is allowed to do before using it.',\n endpoint: 'GET /identities/{id}',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n {\n name: 'list_threads',\n title: 'List conversations',\n description:\n 'Conversations in one address, newest first. Filter by `status` for the queue an agent ' +\n 'should be working, by `owner_type` for what kind of thing is answering, or by ' +\n '`assignee_id` for what one person has taken — `unassigned` is the queue nobody has.',\n endpoint: 'GET /threads',\n readOnly: true,\n /*\n * **The schema had three of these and the description promised five.**\n * Reported by a customer as a contradiction, and it was the schema that\n * was short: the route has honoured all of them since it was written, and\n * `GET /threads` published none of them because it declared\n * `paginationSchema` — so every generated client was missing them too.\n * Fixed in `listThreadsSchema`; this mirrors it.\n */\n inputSchema: {\n identity_id: z.string().optional(),\n status: z.enum(['open', 'waiting', 'resolved', 'human_review']).optional(),\n owner_type: z.enum(['human', 'automation', 'agent']).optional(),\n assignee_id: z.string().optional(),\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n },\n },\n {\n name: 'get_thread',\n title: 'Read a conversation',\n description:\n 'One conversation, by id. Every webhook payload carries a `thread_id`, so this is how a ' +\n 'handler turns an event into the conversation it is about.',\n endpoint: 'GET /threads/{id}',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n {\n name: 'list_messages',\n title: 'List messages in a conversation',\n description:\n 'The messages of one conversation, oldest first — the text to read before replying. ' +\n 'Bodies are here; attachments are metadata only.',\n endpoint: 'GET /messages',\n readOnly: true,\n inputSchema: {\n thread_id: z.string(),\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n },\n },\n {\n name: 'search_messages',\n title: 'Search messages',\n description:\n 'Full-text search across every address this credential can reach, ranked by relevance. ' +\n 'Name an `identity_id` to search exactly one. Every result carries the `identity_id` it ' +\n 'was found in, because a hit you cannot attribute to an address is a hit you cannot open.',\n endpoint: 'GET /messages/search',\n readOnly: true,\n /*\n * `identity_id` is optional here because it became optional on the\n * endpoint, and this tool said \"one mailbox at a time\" for weeks after\n * that stopped being true — a tool narrower than the endpoint it adapts\n * is the one thing this package is not allowed to be. An agent reading\n * the description concluded that *\"where did that invoice go\"* was not a\n * question Pidgeon could answer, which it had been for a while.\n */\n inputSchema: {\n identity_id: z.string().optional(),\n q: z.string(),\n limit: z.number().int().min(1).max(200).optional(),\n },\n },\n {\n name: 'send_message',\n title: 'Send a message',\n description:\n 'Send from an address this credential may send as. Refused if the address’s send ' +\n 'policy does not permit the recipient, or if the recipient previously bounced or ' +\n 'reported mail as spam.',\n endpoint: 'POST /messages',\n readOnly: false,\n /*\n * **This tool could not have worked.** It declared `identity_id` and\n * `thread_id` — `POST /messages` accepts neither, and its schema is\n * `.strict()` — and it omitted `from`, which is required. `call.ts` sends\n * the input as the body verbatim by design, so every call was a 400.\n *\n * A customer reported the smaller half, that `send_message` takes a\n * `thread_id` the REST route does not. The route was right; the tool was\n * describing an API that does not exist. `mcp-adapter.test.ts` checked\n * that the `METHOD /path` pair is real and never that the *fields* were,\n * which is the gap — it checks both now.\n *\n * `in_reply_to` is how a message joins a conversation. There is no\n * `thread_id` on send and there never was: the thread is derived from\n * what you are answering.\n */\n inputSchema: {\n from: z.string(),\n to: z.union([z.string(), z.array(z.string())]),\n cc: z.union([z.string(), z.array(z.string())]).optional(),\n bcc: z.union([z.string(), z.array(z.string())]).optional(),\n subject: z.string().optional(),\n text: z.string().optional(),\n html: z.string().optional(),\n attachment_ids: z.array(z.string()).optional(),\n in_reply_to: z.string().optional(),\n },\n },\n /*\n * ---------------------------------------------------------------------\n * The desk: reading one message, answering it, and saying who has it.\n *\n * **Without these the product's headline cannot be done over MCP.** A\n * customer built a procurement agent on 13 October with a human\n * procurement desk on this server and found it could not *\"draft a counter\n * to supplier B\"* or *\"hand Ferrum back to the agent\"* — the four\n * operations those need all exist in the API and none was exposed. This\n * README's own promise is *if something is missing here, it is missing\n * from the API*, and that was not true.\n *\n * Four and not ten. The menu is read on every call, so `reply-all`,\n * `forward`, the bulk `actions` endpoint, `undo`, `raw` and the label\n * endpoints stay out: `reply` covers the common answer, bulk and undo are\n * affordances for a person with a list in front of them, and raw bytes are\n * no use to a model. These four are the loop — read it, answer it, file\n * it, say who owns it.\n * ---------------------------------------------------------------------\n */\n {\n name: 'get_message',\n title: 'Read one message',\n description:\n 'One message, by id, with its body and its headers. **A webhook carries ids and never ' +\n 'a body**, so this is how a handler turns `message.received` into the thing it is ' +\n 'about.',\n endpoint: 'GET /messages/{id}',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n {\n name: 'reply_to_message',\n title: 'Reply to a message',\n description:\n 'The recipients, the subject and the thread are read off the message being answered, ' +\n 'so you bring the words and nothing else. Use `to` only to change who it goes to.',\n endpoint: 'POST /messages/{id}/reply',\n readOnly: false,\n inputSchema: {\n id: z.string(),\n text: z.string().optional(),\n html: z.string().optional(),\n to: z.union([z.string(), z.array(z.string())]).optional(),\n cc: z.union([z.string(), z.array(z.string())]).optional(),\n bcc: z.union([z.string(), z.array(z.string())]).optional(),\n attachment_ids: z.array(z.string()).optional(),\n },\n },\n {\n name: 'update_thread',\n title: 'Hand a conversation over, or take it back',\n description:\n 'Who owns a conversation and where it has got to. `owner_type: \"human\"` hands it to a ' +\n 'person — it appears in the web inbox and `thread.updated` tells whatever was driving ' +\n 'it that it no longer is; `\"agent\"` takes it back. `status` is the queue it sits in, ' +\n 'and `assignee_id` names which person has it.',\n endpoint: 'PATCH /threads/{id}',\n readOnly: false,\n inputSchema: {\n id: z.string(),\n status: z.enum(['open', 'waiting', 'resolved', 'human_review']).optional(),\n owner_type: z.enum(['human', 'automation', 'agent']).optional(),\n assignee_id: z.string().optional(),\n },\n },\n {\n name: 'update_message',\n title: 'File a message',\n description:\n 'Mark one read or unread, star it, or move it to `archive`, `spam` or `trash`. An ' +\n 'agent that has dealt with something should be able to say so, or the inbox it is ' +\n 'working is the same length tomorrow.',\n endpoint: 'PATCH /messages/{id}',\n readOnly: false,\n inputSchema: {\n id: z.string(),\n is_read: z.boolean().optional(),\n is_starred: z.boolean().optional(),\n folder: z.enum(['inbox', 'archive', 'spam', 'trash']).optional(),\n },\n },\n {\n name: 'list_send_rules',\n title: 'What an address may write to',\n description:\n 'The allow and block list of one address, and the send policy it hangs off. Read this ' +\n 'when a send was refused.',\n endpoint: 'GET /identities/{id}/send-rules',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n /*\n * The inbound mirror, and read-only for the same reason `list_send_rules`\n * is: an agent debugging \"why did nothing arrive\" needs to see the rules,\n * and an agent that can *write* them can quietly stop its own mail. Making\n * a rule is a decision with a person behind it — the dashboard, or an\n * explicit API call somebody wrote.\n */\n {\n name: 'list_receive_rules',\n title: 'Who may write to an address',\n description:\n 'The rules that decide what reaches one address — reject, spam, trash, archive or ' +\n 'inbox, per sender or per domain. Read this when mail you expected did not arrive.',\n endpo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
 
6
6
  // src/cli.ts
7
7
  void main();
package/dist/index.d.ts CHANGED
@@ -30,10 +30,25 @@ interface ToolDefinition {
30
30
  }
31
31
  declare const TOOLS: ToolDefinition[];
32
32
 
33
+ /**
34
+ * What the server tells a client it is.
35
+ *
36
+ * **It said `0.1.0` while the package said `0.2.0`** — a hand-written literal
37
+ * beside a published number, drifting quietly, which a customer spotted on 13
38
+ * October by comparing the hosted server's `initialize` with npm. Nothing
39
+ * breaks when these disagree, which is exactly why nobody notices: the only
40
+ * person who can tell is somebody holding both.
41
+ *
42
+ * Still a literal, because reading `package.json` from a bundle that runs in
43
+ * three places — npm, a stdio binary, and the hosted route — is a build
44
+ * problem for no gain. `package-manifests.test.ts` pins it instead, the same
45
+ * way it pins the clients to the contract.
46
+ */
47
+ declare const VERSION = "0.4.0";
33
48
  declare function createServer(context: {
34
49
  baseUrl: string;
35
50
  apiKey: string;
36
51
  }): McpServer;
37
52
  declare function main(): Promise<void>;
38
53
 
39
- export { TOOLS, type ToolDefinition, createServer, main };
54
+ export { TOOLS, type ToolDefinition, VERSION, createServer, main };
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  TOOLS,
4
+ VERSION,
4
5
  createServer,
5
6
  main
6
- } from "./chunk-6R2DWW3P.js";
7
+ } from "./chunk-W4SUTYGB.js";
7
8
  export {
8
9
  TOOLS,
10
+ VERSION,
9
11
  createServer,
10
12
  main
11
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pidgeon-ai/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Model Context Protocol server for Pidgeon. A protocol adapter over the API, and nothing more.",
5
5
  "keywords": [
6
6
  "pidgeon",
@@ -11,7 +11,7 @@
11
11
  "license": "MIT",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/patrickcneuhaus/pidgeon.git",
14
+ "url": "git+https://github.com/pidgeon-ai/pidgeon-js.git",
15
15
  "directory": "packages/mcp"
16
16
  },
17
17
  "homepage": "https://pidgeon.ai",
@@ -30,7 +30,8 @@
30
30
  "types": "./dist/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "README.md"
33
+ "README.md",
34
+ "LICENSE"
34
35
  ],
35
36
  "engines": {
36
37
  "node": ">=18"
@@ -41,13 +42,16 @@
41
42
  "dependencies": {
42
43
  "@modelcontextprotocol/sdk": "^1.32.1",
43
44
  "zod": "^4.6.5",
44
- "@pidgeon-ai/sdk": "1.0.0"
45
+ "@pidgeon-ai/sdk": "1.3.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "tsup": "^8.5.0",
48
49
  "typescript": "^5",
49
50
  "@types/node": "^24"
50
51
  },
52
+ "bugs": {
53
+ "url": "https://github.com/pidgeon-ai/pidgeon-js/issues"
54
+ },
51
55
  "scripts": {
52
56
  "build": "tsup",
53
57
  "typecheck": "tsc --noEmit"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/call.ts","../src/init.ts","../src/tools.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n\nimport { callEndpoint, PidgeonHttpError } from './call.js';\nimport { init } from './init.js';\nimport { TOOLS } from './tools.js';\n\n/**\n * Pidgeon, as a Model Context Protocol server.\n *\n * A **protocol adapter over an API already at parity**, and nothing else. No\n * business logic, no database, no LLM, no state of its own. Every tool is an\n * endpoint — `call.ts` dispatches on the endpoint the tool declares rather\n * than on its name, so there is nowhere to put behaviour the API does not\n * have. `tests/unit/mcp-adapter.test.ts` holds the other half: every declared\n * endpoint exists in `public/openapi.json`.\n *\n * `architecture.md` §7 listed MCP as deliberately absent, beside \"no LLM, no\n * RAG, no agent runtime\". That entry was written when this product was email\n * hosting; what it sells now is a programmable mailbox, and the person who\n * wants one is building an agent. The premise changed rather than the\n * judgement — an agent runtime is still not being built, and the constraints\n * above are what keep this from becoming one. `decisions.md` §154.\n *\n * ## Authorization is the key, and only the key\n *\n * The credential comes from `PIDGEON_API_KEY` and every call carries it.\n * Nothing here decides what may be reached: the key's own ceiling and the\n * addresses it was granted do all of it, server-side, exactly as they do for\n * any other caller.\n *\n * That matters more here than anywhere else, because this is the single most\n * likely place for a broad credential to be handed to a model. A key created\n * with `access: 'read'` can be given to an agent that must never send, and\n * `decisions.md` §143 is why that holds however generously the key is\n * granted. The README says so in the first paragraph.\n */\n\nconst DEFAULT_BASE_URL = 'https://pidgeon.ai/api/v1';\n\nexport function createServer(context: { baseUrl: string; apiKey: string }): McpServer {\n const server = new McpServer({ name: 'pidgeon', version: '0.1.0' });\n\n for (const tool of TOOLS) {\n server.registerTool(\n tool.name,\n {\n title: tool.title,\n description: tool.description,\n inputSchema: tool.inputSchema,\n annotations: {\n readOnlyHint: tool.readOnly,\n /*\n * Sending mail is not undoable and reaches somebody who did not ask\n * to be part of this. A client that asks before a destructive call\n * should be asking before that one.\n */\n destructiveHint: !tool.readOnly,\n openWorldHint: true,\n },\n },\n async (input: Record<string, unknown>) => {\n try {\n const result = await callEndpoint(tool, input, context);\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],\n };\n } catch (error) {\n /*\n * Reported as a tool error rather than thrown, which is what lets a\n * model read the reason and act on it — \"that address can only\n * reply to people who have written to it\" is a sentence it can do\n * something about, where a transport-level failure is not.\n */\n const message =\n error instanceof PidgeonHttpError\n ? `${error.code}: ${error.message}`\n : error instanceof Error\n ? error.message\n : 'The request failed.';\n\n return { isError: true, content: [{ type: 'text' as const, text: message }] };\n }\n },\n );\n }\n\n return server;\n}\n\nexport async function main(): Promise<void> {\n const apiKey = process.env.PIDGEON_API_KEY;\n const baseUrl = process.env.PIDGEON_BASE_URL ?? DEFAULT_BASE_URL;\n\n /*\n * `init` is a person at a terminal, not a client at a pipe.\n *\n * It is the only path in this package that may write to stdout — everywhere\n * else stdout is the protocol channel and a sentence there is a parse error\n * at the other end. Checked before the key, so a missing key gets the\n * installer's explanation rather than the server's one-line refusal.\n */\n if (process.argv[2] === 'init') {\n const result = await init({\n apiKey,\n baseUrl,\n cwd: process.cwd(),\n write: !process.argv.includes('--print'),\n force: process.argv.includes('--force'),\n fetch: globalThis.fetch,\n out: (line) => process.stdout.write(`${line}\\n`),\n });\n\n process.exit(result.ok ? 0 : 1);\n }\n\n if (!apiKey) {\n /*\n * To stderr and a non-zero exit. stdout is the protocol channel on a\n * stdio server, so a message written there is a parse error at the other\n * end rather than something a person reads.\n */\n process.stderr.write(\n 'PIDGEON_API_KEY is not set. Create a key at https://pidgeon.ai/app/developers/keys — ' +\n 'and give it the narrowest access the agent needs, because this hands it to a model.\\n',\n );\n process.exit(1);\n }\n\n const server = createServer({ baseUrl, apiKey });\n\n await server.connect(new StdioServerTransport());\n}\n\nexport { TOOLS } from './tools.js';\nexport type { ToolDefinition } from './tools.js';\n\n/*\n * **Nothing runs on import.** `cli.ts` is the binary; this file is a\n * library.\n *\n * It used to end with `if (process.env.PIDGEON_MCP_NO_MAIN !== '1')\n * void main()` — a guard the tests set so that importing `createServer`\n * did not open a transport on stdio. That worked for the tests and was a\n * trap for everybody else: the hosted server imports this package, and\n * importing it ran `main()`, which found no `PIDGEON_API_KEY` and called\n * `process.exit(1)`. **The whole web server died on boot**, with the MCP\n * server's own error message as the only clue. §345.\n *\n * An environment variable cannot fix that, because the problem is not\n * which value it has — it is that a library had a side effect at all.\n */\n","import type { ToolDefinition } from './tools.js';\n\n/**\n * Calling the endpoint a tool declares.\n *\n * **The tool's `endpoint` is its implementation**, not a label beside one.\n * That is deliberate and it is what makes \"this package is an adapter\" a\n * structural fact rather than a promise: there is no place to put behaviour\n * the API does not have, because nothing here dispatches on the tool's name.\n *\n * Path parameters come out of the input by name, and what is left becomes the\n * query string on a `GET` or `DELETE` and the body on a `POST` or `PATCH`.\n * The API's own schemas then validate it — this does not re-declare their\n * rules, because two copies of a validation rule is one copy that is wrong.\n *\n * It does not use `@pidgeon-ai/sdk` at runtime, only its types. The SDK is a\n * thin wrapper over the same requests, and going through it would add a layer\n * whose only job is to be a second place a path can be spelled wrong.\n */\n\nexport interface CallContext {\n baseUrl: string;\n apiKey: string;\n fetch?: typeof globalThis.fetch;\n}\n\nexport class PidgeonHttpError extends Error {\n readonly status: number;\n readonly code: string;\n\n constructor(message: string, status: number, code: string) {\n super(message);\n this.name = 'PidgeonHttpError';\n this.status = status;\n this.code = code;\n }\n}\n\nconst PATH_PARAM = /\\{([^}]+)\\}/g;\n\nexport async function callEndpoint(\n tool: ToolDefinition,\n input: Record<string, unknown>,\n context: CallContext,\n): Promise<unknown> {\n const [method, template] = splitEndpoint(tool.endpoint);\n\n const remaining = { ...input };\n\n /*\n * `{id}` is filled from the input and removed from it, so it cannot also\n * arrive as a query parameter — where the API would reject it as an unknown\n * field, since every request schema here is `.strict()`.\n */\n const path = template.replace(PATH_PARAM, (_match, name: string) => {\n const value = remaining[name];\n\n if (value === undefined || value === null || value === '') {\n throw new PidgeonHttpError(`\\`${name}\\` is required.`, 400, 'validation');\n }\n\n delete remaining[name];\n return encodeURIComponent(String(value));\n });\n\n const url = new URL(`${context.baseUrl}${path}`);\n const sendsBody = method === 'POST' || method === 'PATCH';\n\n if (!sendsBody) {\n for (const [key, value] of Object.entries(remaining)) {\n if (value !== undefined && value !== null) url.searchParams.set(key, String(value));\n }\n }\n\n const doFetch = context.fetch ?? globalThis.fetch;\n\n const response = await doFetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${context.apiKey}`,\n ...(sendsBody ? { 'Content-Type': 'application/json' } : {}),\n },\n body: sendsBody ? JSON.stringify(remaining) : undefined,\n });\n\n const payload = (await response.json().catch(() => null)) as {\n data?: unknown;\n error?: { code: string; message: string };\n } | null;\n\n if (!response.ok || payload?.error) {\n /*\n * The API's own sentence, passed through rather than rewritten. It is\n * written for somebody debugging an integration — \"that address is on\n * this address's block list\" — and a model relaying it to a person is\n * better served by the real reason than by \"the request failed\".\n */\n throw new PidgeonHttpError(\n payload?.error?.message ?? `Request failed with ${response.status}.`,\n response.status,\n payload?.error?.code ?? 'internal',\n );\n }\n\n return payload?.data ?? payload;\n}\n\nexport function splitEndpoint(endpoint: string): [string, string] {\n const space = endpoint.indexOf(' ');\n return [endpoint.slice(0, space), endpoint.slice(space + 1)];\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\n/**\n * `npx -y @pidgeon-ai/mcp init` — the install, as one command.\n *\n * The README has carried a correct block of JSON for as long as this package\n * has existed, and a block of JSON is not an install: somebody has to know\n * which file it goes in, paste it without breaking the file already there,\n * invent a name for the server, and then find out whether their key works by\n * asking a model to try.\n *\n * **The check is the part worth having.** A wrong key, a revoked key, or a\n * key granted no mailbox all fail the same way through an MCP client — the\n * tools are listed, the model calls one, and the answer is an error the\n * person never sees. This asks the API first and says what the key can\n * actually reach, which is the one question a copy-paste cannot answer.\n *\n * ## It writes `.mcp.json`, and says so\n *\n * That filename is the convention a project-scoped MCP config uses and\n * several clients read it from a project root. Deliberately **not** a map of\n * each client's own config path: those differ, they move between releases,\n * and a tool that writes confidently to the wrong one is worse than a tool\n * that writes somewhere predictable and tells you. The block it wrote is\n * printed either way, so moving it is a copy rather than a re-derivation.\n */\n\n/** The server's name in the config. One word, because a person types it. */\nconst SERVER_NAME = 'pidgeon';\n\nconst CONFIG_FILE = '.mcp.json';\n\nconst DEFAULT_BASE_URL = 'https://pidgeon.ai/api/v1';\n\ninterface InitOptions {\n apiKey: string | undefined;\n baseUrl: string;\n cwd: string;\n write: boolean;\n force: boolean;\n fetch: typeof globalThis.fetch;\n out: (line: string) => void;\n}\n\n/** What goes in the config. The key is referenced, never printed. */\nfunction configBlock(baseUrl: string): Record<string, unknown> {\n const env: Record<string, string> = { PIDGEON_API_KEY: '${PIDGEON_API_KEY}' };\n\n // Only when it is not production, so the common case stays the short case.\n if (baseUrl !== DEFAULT_BASE_URL) env.PIDGEON_BASE_URL = baseUrl;\n\n return { command: 'npx', args: ['-y', '@pidgeon-ai/mcp'], env };\n}\n\nexport interface InitResult {\n ok: boolean;\n /** Addresses the key can reach, when the check ran. */\n addresses: string[];\n wrote: string | null;\n}\n\nexport async function init(options: InitOptions): Promise<InitResult> {\n const { apiKey, baseUrl, cwd, write, force, fetch, out } = options;\n\n if (!apiKey) {\n out('PIDGEON_API_KEY is not set.');\n out('');\n out('Create one at https://pidgeon.ai/app/developers/keys, then:');\n out(' PIDGEON_API_KEY=pgn_live_… npx -y @pidgeon-ai/mcp init');\n out('');\n out('Give it the narrowest access the agent needs — this hands it to a model.');\n return { ok: false, addresses: [], wrote: null };\n }\n\n /*\n * The check, before anything is written. `GET /identities` is the cheapest\n * call that proves all three things at once: the key parses, it is live,\n * and it has been granted something. A key granted nothing returns an empty\n * list rather than an error, which is its own answer and a common one — a\n * key is created and the mailbox is granted separately.\n */\n const addresses = await reachableAddresses({ apiKey, baseUrl, fetch, out });\n if (addresses === null) return { ok: false, addresses: [], wrote: null };\n\n if (addresses.length === 0) {\n out('That key works, and reaches no mailbox yet.');\n out('');\n out('Grant it one at https://pidgeon.ai/app/developers/keys — a key’s reach is');\n out('a snapshot, so an address created after the key is not in it.');\n } else {\n const shown = addresses.slice(0, 5);\n out(`That key reaches ${addresses.length} address${addresses.length === 1 ? '' : 'es'}:`);\n for (const address of shown) out(` ${address}`);\n if (addresses.length > shown.length) out(` … and ${addresses.length - shown.length} more`);\n }\n\n const block = configBlock(baseUrl);\n const path = resolve(cwd, CONFIG_FILE);\n let wrote: string | null = null;\n\n if (write) {\n const result = merge(path, block, force);\n if (!result.ok) {\n out('');\n out(result.message);\n return { ok: false, addresses, wrote: null };\n }\n wrote = path;\n }\n\n out('');\n out(wrote ? `Wrote ${CONFIG_FILE}:` : `Add this to your MCP client’s config:`);\n out('');\n out(JSON.stringify({ mcpServers: { [SERVER_NAME]: block } }, null, 2));\n out('');\n out('The key is read from the environment rather than written into the file,');\n out('so the config can be committed and the credential cannot.');\n\n return { ok: true, addresses, wrote };\n}\n\n/**\n * The addresses this key can reach, or `null` when the key is the problem.\n *\n * Every failure gets a sentence that says what to do, because \"401\" through\n * an MCP client is a model's problem and this is a person's.\n */\nasync function reachableAddresses(context: {\n apiKey: string;\n baseUrl: string;\n fetch: typeof globalThis.fetch;\n out: (line: string) => void;\n}): Promise<string[] | null> {\n const { apiKey, baseUrl, fetch, out } = context;\n\n let response: Response;\n\n try {\n response = await fetch(`${baseUrl}/identities`, {\n headers: { authorization: `Bearer ${apiKey}`, accept: 'application/json' },\n });\n } catch (error) {\n out(`Could not reach ${baseUrl}: ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n\n if (response.status === 401 || response.status === 403) {\n out('That key was refused. It may be revoked, or from another deployment.');\n out('Keys live at https://pidgeon.ai/app/developers/keys.');\n return null;\n }\n\n if (!response.ok) {\n out(`The API answered ${response.status}. Nothing was written.`);\n return null;\n }\n\n const body = (await response.json()) as { data?: { email?: string }[] };\n return (body.data ?? []).map((identity) => identity.email ?? '').filter(Boolean);\n}\n\n/**\n * Add the entry without destroying what is already in the file.\n *\n * A developer running this in a project that already talks to three MCP\n * servers must not lose them, and one who runs it twice must not be told off.\n * An entry that is already ours and already correct is a no-op; one that is\n * ours and different is the only case that needs a decision, and the decision\n * is theirs.\n */\nfunction merge(\n path: string,\n block: Record<string, unknown>,\n force: boolean,\n): { ok: true } | { ok: false; message: string } {\n let existing: Record<string, unknown> = {};\n\n try {\n existing = JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>;\n } catch (error) {\n // A missing file is the normal case. Anything else is a file we must not\n // overwrite, because we could not read what it holds.\n if ((error as { code?: string }).code !== 'ENOENT') {\n return {\n ok: false,\n message: `${path} exists and is not valid JSON, so nothing was written.`,\n };\n }\n }\n\n const servers = (existing.mcpServers ?? {}) as Record<string, unknown>;\n const current = servers[SERVER_NAME];\n\n if (current && !force && JSON.stringify(current) !== JSON.stringify(block)) {\n return {\n ok: false,\n message:\n `${path} already has a different \"${SERVER_NAME}\" server, so nothing was written.\\n` +\n 'Run again with --force to replace it, or edit the file by hand.',\n };\n }\n\n writeFileSync(\n path,\n `${JSON.stringify({ ...existing, mcpServers: { ...servers, [SERVER_NAME]: block } }, null, 2)}\\n`,\n );\n\n return { ok: true };\n}\n","import { z } from 'zod';\n\n/**\n * The tools this server offers, and the endpoint each one is.\n *\n * **This is an adapter, and this file is where that stays true.** Every tool\n * names the `METHOD /path` it calls, and `tests/unit/mcp-adapter.test.ts`\n * asserts that pair exists in `public/openapi.json`. So a tool cannot be\n * added for behaviour the API does not have — if one needs logic that is not\n * an endpoint, **the API is missing it**, and it gets built there.\n *\n * That constraint is the whole reason this package is allowed to exist.\n * `architecture.md` §7 put MCP on the do-not-build list when this product was\n * email hosting, and the premise changed rather than the judgement: what is\n * sold now is a programmable mailbox, and the buyer is somebody building an\n * agent. A protocol adapter over an API already at parity is thin. An agent\n * runtime is not, and this file is what keeps the second from growing out of\n * the first. `decisions.md` §153.\n */\n\nexport interface ToolDefinition {\n name: string;\n title: string;\n description: string;\n /** The endpoint this tool *is*. Checked against the published contract. */\n endpoint: `${'GET' | 'POST' | 'PATCH' | 'DELETE'} ${string}`;\n inputSchema: z.ZodRawShape;\n /** Whether it changes anything. MCP clients surface this before confirming. */\n readOnly: boolean;\n}\n\n/*\n * Deliberately not every endpoint.\n *\n * A tool list is a menu a model reads on every call, so length is a real\n * cost, and the ones left out are left out for reasons rather than by\n * omission: minting API keys and granting mailbox access are credential\n * operations that should be done by a person who can see what they are\n * agreeing to, and the raw attachment and export endpoints move bytes a\n * model has no use for. Anything here is something an agent doing the job\n * this product is for actually needs.\n */\nexport const TOOLS: ToolDefinition[] = [\n {\n name: 'list_addresses',\n title: 'List addresses',\n description:\n 'The addresses this credential can reach. Use `tenant_id` to list the addresses ' +\n 'belonging to one of your own customers.',\n endpoint: 'GET /identities',\n readOnly: true,\n inputSchema: {\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n tenant_id: z.string().optional(),\n },\n },\n {\n name: 'create_address',\n title: 'Create an address',\n description:\n 'Create an address your software owns. `send_policy: \"reply_only\"` makes it unable to ' +\n 'write to anybody who has not written to it first, which is the right default for an ' +\n 'agent. `expires_at` gives it an end date, after which it stops accepting mail.',\n endpoint: 'POST /identities',\n readOnly: false,\n inputSchema: {\n domain_id: z.string(),\n local_part: z.string(),\n display_name: z.string().nullish(),\n type: z.enum(['human', 'team', 'application', 'workflow', 'agent']).optional(),\n send_policy: z.enum(['open', 'reply_only', 'list']).optional(),\n expires_at: z.string().optional(),\n tenant_id: z.string().optional(),\n },\n },\n {\n name: 'get_address',\n title: 'Read one address',\n description:\n 'One address, by id. Answers its type, its capabilities, its send policy and its end ' +\n 'date, which is how to check what an address is allowed to do before using it.',\n endpoint: 'GET /identities/{id}',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n {\n name: 'list_threads',\n title: 'List conversations',\n description:\n 'Conversations in one address, newest first. Filter by `status` for the queue an agent ' +\n 'should be working, or by `assignee_id` for what one person has taken.',\n endpoint: 'GET /threads',\n readOnly: true,\n inputSchema: {\n identity_id: z.string(),\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n },\n },\n {\n name: 'get_thread',\n title: 'Read a conversation',\n description:\n 'One conversation, by id. Every webhook payload carries a `thread_id`, so this is how a ' +\n 'handler turns an event into the conversation it is about.',\n endpoint: 'GET /threads/{id}',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n {\n name: 'list_messages',\n title: 'List messages in a conversation',\n description:\n 'The messages of one conversation, oldest first — the text to read before replying. ' +\n 'Bodies are here; attachments are metadata only.',\n endpoint: 'GET /messages',\n readOnly: true,\n inputSchema: {\n thread_id: z.string(),\n limit: z.number().int().min(1).max(200).optional(),\n cursor: z.string().optional(),\n },\n },\n {\n name: 'search_messages',\n title: 'Search one mailbox',\n description:\n 'Full-text search within a single address, ranked by relevance. One mailbox at a time, ' +\n 'because searching across addresses somebody cannot all read is not a thing to offer.',\n endpoint: 'GET /messages/search',\n readOnly: true,\n inputSchema: {\n identity_id: z.string(),\n q: z.string(),\n limit: z.number().int().min(1).max(200).optional(),\n },\n },\n {\n name: 'send_message',\n title: 'Send a message',\n description:\n 'Send from an address this credential may send as. Refused if the address’s send ' +\n 'policy does not permit the recipient, or if the recipient previously bounced or ' +\n 'reported mail as spam.',\n endpoint: 'POST /messages',\n readOnly: false,\n inputSchema: {\n identity_id: z.string(),\n to: z.union([z.string(), z.array(z.string())]),\n cc: z.union([z.string(), z.array(z.string())]).optional(),\n subject: z.string().optional(),\n text: z.string().optional(),\n html: z.string().optional(),\n thread_id: z.string().optional(),\n in_reply_to: z.string().optional(),\n },\n },\n {\n name: 'list_send_rules',\n title: 'What an address may write to',\n description:\n 'The allow and block list of one address, and the send policy it hangs off. Read this ' +\n 'when a send was refused.',\n endpoint: 'GET /identities/{id}/send-rules',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n /*\n * The inbound mirror, and read-only for the same reason `list_send_rules`\n * is: an agent debugging \"why did nothing arrive\" needs to see the rules,\n * and an agent that can *write* them can quietly stop its own mail. Making\n * a rule is a decision with a person behind it — the dashboard, or an\n * explicit API call somebody wrote.\n */\n {\n name: 'list_receive_rules',\n title: 'Who may write to an address',\n description:\n 'The rules that decide what reaches one address — reject, spam, trash, archive or ' +\n 'inbox, per sender or per domain. Read this when mail you expected did not arrive.',\n endpoint: 'GET /identities/{id}/receive-rules',\n readOnly: true,\n inputSchema: { id: z.string() },\n },\n];\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACyB9B,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,QAAgB,MAAc;AACzD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;AAEA,IAAM,aAAa;AAEnB,eAAsB,aACpB,MACA,OACA,SACkB;AAClB,QAAM,CAAC,QAAQ,QAAQ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