@pidgeon-ai/mcp 0.1.0 → 0.2.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 +23 -3
- package/dist/chunk-6R2DWW3P.js +362 -0
- package/dist/chunk-6R2DWW3P.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +5 -223
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -13,11 +13,25 @@ So **give it the narrowest key the agent needs**. A key created with `read`
|
|
|
13
13
|
access can never send, however generously it is granted a mailbox, and an
|
|
14
14
|
agent that only has to triage should have one.
|
|
15
15
|
|
|
16
|
+
## Installing it
|
|
17
|
+
|
|
16
18
|
```sh
|
|
17
|
-
PIDGEON_API_KEY=pgn_live_… npx @pidgeon-ai/mcp
|
|
19
|
+
PIDGEON_API_KEY=pgn_live_… npx -y @pidgeon-ai/mcp init
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
That checks the key against the API and tells you which addresses it reaches
|
|
23
|
+
— the one question a block of JSON cannot answer, and the one that otherwise
|
|
24
|
+
surfaces as a model quietly getting an error you never see. Then it writes
|
|
25
|
+
`.mcp.json` in the current directory and prints what it wrote.
|
|
26
|
+
|
|
27
|
+
`--print` to see the config without writing it, which is what you want if your
|
|
28
|
+
client keeps its own somewhere else. `--force` to replace an entry that is
|
|
29
|
+
already there.
|
|
30
|
+
|
|
31
|
+
The key is referenced from the environment rather than written into the file,
|
|
32
|
+
so the config can be committed and the credential cannot.
|
|
33
|
+
|
|
34
|
+
## Or by hand
|
|
21
35
|
|
|
22
36
|
```json
|
|
23
37
|
{
|
|
@@ -25,12 +39,18 @@ Claude Desktop, or any other MCP client:
|
|
|
25
39
|
"pidgeon": {
|
|
26
40
|
"command": "npx",
|
|
27
41
|
"args": ["-y", "@pidgeon-ai/mcp"],
|
|
28
|
-
"env": { "PIDGEON_API_KEY": "
|
|
42
|
+
"env": { "PIDGEON_API_KEY": "${PIDGEON_API_KEY}" }
|
|
29
43
|
}
|
|
30
44
|
}
|
|
31
45
|
}
|
|
32
46
|
```
|
|
33
47
|
|
|
48
|
+
And to run the server directly, which is mostly useful for seeing it start:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
PIDGEON_API_KEY=pgn_live_… npx -y @pidgeon-ai/mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
34
54
|
`PIDGEON_BASE_URL` points it somewhere else, which is how you run it against a
|
|
35
55
|
local checkout.
|
|
36
56
|
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
|
|
7
|
+
// src/call.ts
|
|
8
|
+
var PidgeonHttpError = class extends Error {
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
constructor(message, status, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "PidgeonHttpError";
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var PATH_PARAM = /\{([^}]+)\}/g;
|
|
19
|
+
async function callEndpoint(tool, input, context) {
|
|
20
|
+
const [method, template] = splitEndpoint(tool.endpoint);
|
|
21
|
+
const remaining = { ...input };
|
|
22
|
+
const path = template.replace(PATH_PARAM, (_match, name) => {
|
|
23
|
+
const value = remaining[name];
|
|
24
|
+
if (value === void 0 || value === null || value === "") {
|
|
25
|
+
throw new PidgeonHttpError(`\`${name}\` is required.`, 400, "validation");
|
|
26
|
+
}
|
|
27
|
+
delete remaining[name];
|
|
28
|
+
return encodeURIComponent(String(value));
|
|
29
|
+
});
|
|
30
|
+
const url = new URL(`${context.baseUrl}${path}`);
|
|
31
|
+
const sendsBody = method === "POST" || method === "PATCH";
|
|
32
|
+
if (!sendsBody) {
|
|
33
|
+
for (const [key, value] of Object.entries(remaining)) {
|
|
34
|
+
if (value !== void 0 && value !== null) url.searchParams.set(key, String(value));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const doFetch = context.fetch ?? globalThis.fetch;
|
|
38
|
+
const response = await doFetch(url, {
|
|
39
|
+
method,
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${context.apiKey}`,
|
|
42
|
+
...sendsBody ? { "Content-Type": "application/json" } : {}
|
|
43
|
+
},
|
|
44
|
+
body: sendsBody ? JSON.stringify(remaining) : void 0
|
|
45
|
+
});
|
|
46
|
+
const payload = await response.json().catch(() => null);
|
|
47
|
+
if (!response.ok || payload?.error) {
|
|
48
|
+
throw new PidgeonHttpError(
|
|
49
|
+
payload?.error?.message ?? `Request failed with ${response.status}.`,
|
|
50
|
+
response.status,
|
|
51
|
+
payload?.error?.code ?? "internal"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return payload?.data ?? payload;
|
|
55
|
+
}
|
|
56
|
+
function splitEndpoint(endpoint) {
|
|
57
|
+
const space = endpoint.indexOf(" ");
|
|
58
|
+
return [endpoint.slice(0, space), endpoint.slice(space + 1)];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/init.ts
|
|
62
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
63
|
+
import { resolve } from "path";
|
|
64
|
+
var SERVER_NAME = "pidgeon";
|
|
65
|
+
var CONFIG_FILE = ".mcp.json";
|
|
66
|
+
var DEFAULT_BASE_URL = "https://pidgeon.ai/api/v1";
|
|
67
|
+
function configBlock(baseUrl) {
|
|
68
|
+
const env = { PIDGEON_API_KEY: "${PIDGEON_API_KEY}" };
|
|
69
|
+
if (baseUrl !== DEFAULT_BASE_URL) env.PIDGEON_BASE_URL = baseUrl;
|
|
70
|
+
return { command: "npx", args: ["-y", "@pidgeon-ai/mcp"], env };
|
|
71
|
+
}
|
|
72
|
+
async function init(options) {
|
|
73
|
+
const { apiKey, baseUrl, cwd, write, force, fetch, out } = options;
|
|
74
|
+
if (!apiKey) {
|
|
75
|
+
out("PIDGEON_API_KEY is not set.");
|
|
76
|
+
out("");
|
|
77
|
+
out("Create one at https://pidgeon.ai/app/developers/keys, then:");
|
|
78
|
+
out(" PIDGEON_API_KEY=pgn_live_\u2026 npx -y @pidgeon-ai/mcp init");
|
|
79
|
+
out("");
|
|
80
|
+
out("Give it the narrowest access the agent needs \u2014 this hands it to a model.");
|
|
81
|
+
return { ok: false, addresses: [], wrote: null };
|
|
82
|
+
}
|
|
83
|
+
const addresses = await reachableAddresses({ apiKey, baseUrl, fetch, out });
|
|
84
|
+
if (addresses === null) return { ok: false, addresses: [], wrote: null };
|
|
85
|
+
if (addresses.length === 0) {
|
|
86
|
+
out("That key works, and reaches no mailbox yet.");
|
|
87
|
+
out("");
|
|
88
|
+
out("Grant it one at https://pidgeon.ai/app/developers/keys \u2014 a key\u2019s reach is");
|
|
89
|
+
out("a snapshot, so an address created after the key is not in it.");
|
|
90
|
+
} else {
|
|
91
|
+
const shown = addresses.slice(0, 5);
|
|
92
|
+
out(`That key reaches ${addresses.length} address${addresses.length === 1 ? "" : "es"}:`);
|
|
93
|
+
for (const address of shown) out(` ${address}`);
|
|
94
|
+
if (addresses.length > shown.length) out(` \u2026 and ${addresses.length - shown.length} more`);
|
|
95
|
+
}
|
|
96
|
+
const block = configBlock(baseUrl);
|
|
97
|
+
const path = resolve(cwd, CONFIG_FILE);
|
|
98
|
+
let wrote = null;
|
|
99
|
+
if (write) {
|
|
100
|
+
const result = merge(path, block, force);
|
|
101
|
+
if (!result.ok) {
|
|
102
|
+
out("");
|
|
103
|
+
out(result.message);
|
|
104
|
+
return { ok: false, addresses, wrote: null };
|
|
105
|
+
}
|
|
106
|
+
wrote = path;
|
|
107
|
+
}
|
|
108
|
+
out("");
|
|
109
|
+
out(wrote ? `Wrote ${CONFIG_FILE}:` : `Add this to your MCP client\u2019s config:`);
|
|
110
|
+
out("");
|
|
111
|
+
out(JSON.stringify({ mcpServers: { [SERVER_NAME]: block } }, null, 2));
|
|
112
|
+
out("");
|
|
113
|
+
out("The key is read from the environment rather than written into the file,");
|
|
114
|
+
out("so the config can be committed and the credential cannot.");
|
|
115
|
+
return { ok: true, addresses, wrote };
|
|
116
|
+
}
|
|
117
|
+
async function reachableAddresses(context) {
|
|
118
|
+
const { apiKey, baseUrl, fetch, out } = context;
|
|
119
|
+
let response;
|
|
120
|
+
try {
|
|
121
|
+
response = await fetch(`${baseUrl}/identities`, {
|
|
122
|
+
headers: { authorization: `Bearer ${apiKey}`, accept: "application/json" }
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
out(`Could not reach ${baseUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (response.status === 401 || response.status === 403) {
|
|
129
|
+
out("That key was refused. It may be revoked, or from another deployment.");
|
|
130
|
+
out("Keys live at https://pidgeon.ai/app/developers/keys.");
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
if (!response.ok) {
|
|
134
|
+
out(`The API answered ${response.status}. Nothing was written.`);
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const body = await response.json();
|
|
138
|
+
return (body.data ?? []).map((identity) => identity.email ?? "").filter(Boolean);
|
|
139
|
+
}
|
|
140
|
+
function merge(path, block, force) {
|
|
141
|
+
let existing = {};
|
|
142
|
+
try {
|
|
143
|
+
existing = JSON.parse(readFileSync(path, "utf8"));
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (error.code !== "ENOENT") {
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
message: `${path} exists and is not valid JSON, so nothing was written.`
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const servers = existing.mcpServers ?? {};
|
|
153
|
+
const current = servers[SERVER_NAME];
|
|
154
|
+
if (current && !force && JSON.stringify(current) !== JSON.stringify(block)) {
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
message: `${path} already has a different "${SERVER_NAME}" server, so nothing was written.
|
|
158
|
+
Run again with --force to replace it, or edit the file by hand.`
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
writeFileSync(
|
|
162
|
+
path,
|
|
163
|
+
`${JSON.stringify({ ...existing, mcpServers: { ...servers, [SERVER_NAME]: block } }, null, 2)}
|
|
164
|
+
`
|
|
165
|
+
);
|
|
166
|
+
return { ok: true };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/tools.ts
|
|
170
|
+
import { z } from "zod";
|
|
171
|
+
var TOOLS = [
|
|
172
|
+
{
|
|
173
|
+
name: "list_addresses",
|
|
174
|
+
title: "List addresses",
|
|
175
|
+
description: "The addresses this credential can reach. Use `tenant_id` to list the addresses belonging to one of your own customers.",
|
|
176
|
+
endpoint: "GET /identities",
|
|
177
|
+
readOnly: true,
|
|
178
|
+
inputSchema: {
|
|
179
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
180
|
+
cursor: z.string().optional(),
|
|
181
|
+
tenant_id: z.string().optional()
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "create_address",
|
|
186
|
+
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.',
|
|
188
|
+
endpoint: "POST /identities",
|
|
189
|
+
readOnly: false,
|
|
190
|
+
inputSchema: {
|
|
191
|
+
domain_id: z.string(),
|
|
192
|
+
local_part: z.string(),
|
|
193
|
+
display_name: z.string().nullish(),
|
|
194
|
+
type: z.enum(["human", "team", "application", "workflow", "agent"]).optional(),
|
|
195
|
+
send_policy: z.enum(["open", "reply_only", "list"]).optional(),
|
|
196
|
+
expires_at: z.string().optional(),
|
|
197
|
+
tenant_id: z.string().optional()
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "get_address",
|
|
202
|
+
title: "Read one address",
|
|
203
|
+
description: "One address, by id. Answers its type, its capabilities, its send policy and its end date, which is how to check what an address is allowed to do before using it.",
|
|
204
|
+
endpoint: "GET /identities/{id}",
|
|
205
|
+
readOnly: true,
|
|
206
|
+
inputSchema: { id: z.string() }
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "list_threads",
|
|
210
|
+
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.",
|
|
212
|
+
endpoint: "GET /threads",
|
|
213
|
+
readOnly: true,
|
|
214
|
+
inputSchema: {
|
|
215
|
+
identity_id: z.string(),
|
|
216
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
217
|
+
cursor: z.string().optional()
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: "get_thread",
|
|
222
|
+
title: "Read a conversation",
|
|
223
|
+
description: "One conversation, by id. Every webhook payload carries a `thread_id`, so this is how a handler turns an event into the conversation it is about.",
|
|
224
|
+
endpoint: "GET /threads/{id}",
|
|
225
|
+
readOnly: true,
|
|
226
|
+
inputSchema: { id: z.string() }
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "list_messages",
|
|
230
|
+
title: "List messages in a conversation",
|
|
231
|
+
description: "The messages of one conversation, oldest first \u2014 the text to read before replying. Bodies are here; attachments are metadata only.",
|
|
232
|
+
endpoint: "GET /messages",
|
|
233
|
+
readOnly: true,
|
|
234
|
+
inputSchema: {
|
|
235
|
+
thread_id: z.string(),
|
|
236
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
237
|
+
cursor: z.string().optional()
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
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.",
|
|
244
|
+
endpoint: "GET /messages/search",
|
|
245
|
+
readOnly: true,
|
|
246
|
+
inputSchema: {
|
|
247
|
+
identity_id: z.string(),
|
|
248
|
+
q: z.string(),
|
|
249
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "send_message",
|
|
254
|
+
title: "Send a message",
|
|
255
|
+
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
|
+
endpoint: "POST /messages",
|
|
257
|
+
readOnly: false,
|
|
258
|
+
inputSchema: {
|
|
259
|
+
identity_id: z.string(),
|
|
260
|
+
to: z.union([z.string(), z.array(z.string())]),
|
|
261
|
+
cc: z.union([z.string(), z.array(z.string())]).optional(),
|
|
262
|
+
subject: z.string().optional(),
|
|
263
|
+
text: z.string().optional(),
|
|
264
|
+
html: z.string().optional(),
|
|
265
|
+
thread_id: z.string().optional(),
|
|
266
|
+
in_reply_to: z.string().optional()
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "list_send_rules",
|
|
271
|
+
title: "What an address may write to",
|
|
272
|
+
description: "The allow and block list of one address, and the send policy it hangs off. Read this when a send was refused.",
|
|
273
|
+
endpoint: "GET /identities/{id}/send-rules",
|
|
274
|
+
readOnly: true,
|
|
275
|
+
inputSchema: { id: z.string() }
|
|
276
|
+
},
|
|
277
|
+
/*
|
|
278
|
+
* The inbound mirror, and read-only for the same reason `list_send_rules`
|
|
279
|
+
* is: an agent debugging "why did nothing arrive" needs to see the rules,
|
|
280
|
+
* and an agent that can *write* them can quietly stop its own mail. Making
|
|
281
|
+
* a rule is a decision with a person behind it — the dashboard, or an
|
|
282
|
+
* explicit API call somebody wrote.
|
|
283
|
+
*/
|
|
284
|
+
{
|
|
285
|
+
name: "list_receive_rules",
|
|
286
|
+
title: "Who may write to an address",
|
|
287
|
+
description: "The rules that decide what reaches one address \u2014 reject, spam, trash, archive or inbox, per sender or per domain. Read this when mail you expected did not arrive.",
|
|
288
|
+
endpoint: "GET /identities/{id}/receive-rules",
|
|
289
|
+
readOnly: true,
|
|
290
|
+
inputSchema: { id: z.string() }
|
|
291
|
+
}
|
|
292
|
+
];
|
|
293
|
+
|
|
294
|
+
// src/index.ts
|
|
295
|
+
var DEFAULT_BASE_URL2 = "https://pidgeon.ai/api/v1";
|
|
296
|
+
function createServer(context) {
|
|
297
|
+
const server = new McpServer({ name: "pidgeon", version: "0.1.0" });
|
|
298
|
+
for (const tool of TOOLS) {
|
|
299
|
+
server.registerTool(
|
|
300
|
+
tool.name,
|
|
301
|
+
{
|
|
302
|
+
title: tool.title,
|
|
303
|
+
description: tool.description,
|
|
304
|
+
inputSchema: tool.inputSchema,
|
|
305
|
+
annotations: {
|
|
306
|
+
readOnlyHint: tool.readOnly,
|
|
307
|
+
/*
|
|
308
|
+
* Sending mail is not undoable and reaches somebody who did not ask
|
|
309
|
+
* to be part of this. A client that asks before a destructive call
|
|
310
|
+
* should be asking before that one.
|
|
311
|
+
*/
|
|
312
|
+
destructiveHint: !tool.readOnly,
|
|
313
|
+
openWorldHint: true
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
async (input) => {
|
|
317
|
+
try {
|
|
318
|
+
const result = await callEndpoint(tool, input, context);
|
|
319
|
+
return {
|
|
320
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
321
|
+
};
|
|
322
|
+
} catch (error) {
|
|
323
|
+
const message = error instanceof PidgeonHttpError ? `${error.code}: ${error.message}` : error instanceof Error ? error.message : "The request failed.";
|
|
324
|
+
return { isError: true, content: [{ type: "text", text: message }] };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return server;
|
|
330
|
+
}
|
|
331
|
+
async function main() {
|
|
332
|
+
const apiKey = process.env.PIDGEON_API_KEY;
|
|
333
|
+
const baseUrl = process.env.PIDGEON_BASE_URL ?? DEFAULT_BASE_URL2;
|
|
334
|
+
if (process.argv[2] === "init") {
|
|
335
|
+
const result = await init({
|
|
336
|
+
apiKey,
|
|
337
|
+
baseUrl,
|
|
338
|
+
cwd: process.cwd(),
|
|
339
|
+
write: !process.argv.includes("--print"),
|
|
340
|
+
force: process.argv.includes("--force"),
|
|
341
|
+
fetch: globalThis.fetch,
|
|
342
|
+
out: (line) => process.stdout.write(`${line}
|
|
343
|
+
`)
|
|
344
|
+
});
|
|
345
|
+
process.exit(result.ok ? 0 : 1);
|
|
346
|
+
}
|
|
347
|
+
if (!apiKey) {
|
|
348
|
+
process.stderr.write(
|
|
349
|
+
"PIDGEON_API_KEY is not set. Create a key at https://pidgeon.ai/app/developers/keys \u2014 and give it the narrowest access the agent needs, because this hands it to a model.\n"
|
|
350
|
+
);
|
|
351
|
+
process.exit(1);
|
|
352
|
+
}
|
|
353
|
+
const server = createServer({ baseUrl, apiKey });
|
|
354
|
+
await server.connect(new StdioServerTransport());
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export {
|
|
358
|
+
TOOLS,
|
|
359
|
+
createServer,
|
|
360
|
+
main
|
|
361
|
+
};
|
|
362
|
+
//# sourceMappingURL=chunk-6R2DWW3P.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\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;AA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ACT;AAEA,eAAsB,OAAsB;AAC1C,QAAM,SAAS,QAAQ,IAAI;AAC3B,QAAM,UAAU,QAAQ,IAAI,oBAAoBA;AAUhD,MAAI,QAAQ,KAAK,CAAC,MAAM,QAAQ;AAC9B,UAAM,SAAS,MAAM,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,KAAK,QAAQ,IAAI;AAAA,MACjB,OAAO,CAAC,QAAQ,KAAK,SAAS,SAAS;AAAA,MACvC,OAAO,QAAQ,KAAK,SAAS,SAAS;AAAA,MACtC,OAAO,WAAW;AAAA,MAClB,KAAK,CAAC,SAAS,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAAA,IACjD,CAAC;AAED,YAAQ,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAChC;AAEA,MAAI,CAAC,QAAQ;AAMX,YAAQ,OAAO;AAAA,MACb;AAAA,IAEF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,SAAS,aAAa,EAAE,SAAS,OAAO,CAAC;AAE/C,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;","names":["DEFAULT_BASE_URL"]}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { main } from './index.js';\n\n/**\n * The binary, and the only thing in this package that runs anything.\n *\n * `index.ts` is a library: it is imported by the tests, and by the hosted\n * server at `src/app/api/mcp/route.ts`, and neither wants a stdio transport\n * opened as a side effect of an import. It used to run `main()` at the\n * bottom of the module behind an environment-variable guard, which killed\n * the web server the first time the route imported it. §345.\n *\n * So the side effect lives here, in the file `bin` points at, which nothing\n * imports.\n */\nvoid main();\n"],"mappings":";;;;;;AAcA,KAAK,KAAK;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,227 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// src/call.ts
|
|
8
|
-
var PidgeonHttpError = class extends Error {
|
|
9
|
-
status;
|
|
10
|
-
code;
|
|
11
|
-
constructor(message, status, code) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = "PidgeonHttpError";
|
|
14
|
-
this.status = status;
|
|
15
|
-
this.code = code;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var PATH_PARAM = /\{([^}]+)\}/g;
|
|
19
|
-
async function callEndpoint(tool, input, context) {
|
|
20
|
-
const [method, template] = splitEndpoint(tool.endpoint);
|
|
21
|
-
const remaining = { ...input };
|
|
22
|
-
const path = template.replace(PATH_PARAM, (_match, name) => {
|
|
23
|
-
const value = remaining[name];
|
|
24
|
-
if (value === void 0 || value === null || value === "") {
|
|
25
|
-
throw new PidgeonHttpError(`\`${name}\` is required.`, 400, "validation");
|
|
26
|
-
}
|
|
27
|
-
delete remaining[name];
|
|
28
|
-
return encodeURIComponent(String(value));
|
|
29
|
-
});
|
|
30
|
-
const url = new URL(`${context.baseUrl}${path}`);
|
|
31
|
-
const sendsBody = method === "POST" || method === "PATCH";
|
|
32
|
-
if (!sendsBody) {
|
|
33
|
-
for (const [key, value] of Object.entries(remaining)) {
|
|
34
|
-
if (value !== void 0 && value !== null) url.searchParams.set(key, String(value));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const doFetch = context.fetch ?? globalThis.fetch;
|
|
38
|
-
const response = await doFetch(url, {
|
|
39
|
-
method,
|
|
40
|
-
headers: {
|
|
41
|
-
Authorization: `Bearer ${context.apiKey}`,
|
|
42
|
-
...sendsBody ? { "Content-Type": "application/json" } : {}
|
|
43
|
-
},
|
|
44
|
-
body: sendsBody ? JSON.stringify(remaining) : void 0
|
|
45
|
-
});
|
|
46
|
-
const payload = await response.json().catch(() => null);
|
|
47
|
-
if (!response.ok || payload?.error) {
|
|
48
|
-
throw new PidgeonHttpError(
|
|
49
|
-
payload?.error?.message ?? `Request failed with ${response.status}.`,
|
|
50
|
-
response.status,
|
|
51
|
-
payload?.error?.code ?? "internal"
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return payload?.data ?? payload;
|
|
55
|
-
}
|
|
56
|
-
function splitEndpoint(endpoint) {
|
|
57
|
-
const space = endpoint.indexOf(" ");
|
|
58
|
-
return [endpoint.slice(0, space), endpoint.slice(space + 1)];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/tools.ts
|
|
62
|
-
import { z } from "zod";
|
|
63
|
-
var TOOLS = [
|
|
64
|
-
{
|
|
65
|
-
name: "list_addresses",
|
|
66
|
-
title: "List addresses",
|
|
67
|
-
description: "The addresses this credential can reach. Use `tenant_id` to list the addresses belonging to one of your own customers.",
|
|
68
|
-
endpoint: "GET /identities",
|
|
69
|
-
readOnly: true,
|
|
70
|
-
inputSchema: {
|
|
71
|
-
limit: z.number().int().min(1).max(200).optional(),
|
|
72
|
-
cursor: z.string().optional(),
|
|
73
|
-
tenant_id: z.string().optional()
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "create_address",
|
|
78
|
-
title: "Create an address",
|
|
79
|
-
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.',
|
|
80
|
-
endpoint: "POST /identities",
|
|
81
|
-
readOnly: false,
|
|
82
|
-
inputSchema: {
|
|
83
|
-
domain_id: z.string(),
|
|
84
|
-
local_part: z.string(),
|
|
85
|
-
display_name: z.string().nullish(),
|
|
86
|
-
type: z.enum(["human", "team", "application", "workflow", "agent"]).optional(),
|
|
87
|
-
send_policy: z.enum(["open", "reply_only", "list"]).optional(),
|
|
88
|
-
expires_at: z.string().optional(),
|
|
89
|
-
tenant_id: z.string().optional()
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "get_address",
|
|
94
|
-
title: "Read one address",
|
|
95
|
-
description: "One address, by id. Answers its type, its capabilities, its send policy and its end date, which is how to check what an address is allowed to do before using it.",
|
|
96
|
-
endpoint: "GET /identities/{id}",
|
|
97
|
-
readOnly: true,
|
|
98
|
-
inputSchema: { id: z.string() }
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: "list_threads",
|
|
102
|
-
title: "List conversations",
|
|
103
|
-
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.",
|
|
104
|
-
endpoint: "GET /threads",
|
|
105
|
-
readOnly: true,
|
|
106
|
-
inputSchema: {
|
|
107
|
-
identity_id: z.string(),
|
|
108
|
-
limit: z.number().int().min(1).max(200).optional(),
|
|
109
|
-
cursor: z.string().optional()
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "get_thread",
|
|
114
|
-
title: "Read a conversation",
|
|
115
|
-
description: "One conversation, by id. Every webhook payload carries a `thread_id`, so this is how a handler turns an event into the conversation it is about.",
|
|
116
|
-
endpoint: "GET /threads/{id}",
|
|
117
|
-
readOnly: true,
|
|
118
|
-
inputSchema: { id: z.string() }
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "list_messages",
|
|
122
|
-
title: "List messages in a conversation",
|
|
123
|
-
description: "The messages of one conversation, oldest first \u2014 the text to read before replying. Bodies are here; attachments are metadata only.",
|
|
124
|
-
endpoint: "GET /messages",
|
|
125
|
-
readOnly: true,
|
|
126
|
-
inputSchema: {
|
|
127
|
-
thread_id: z.string(),
|
|
128
|
-
limit: z.number().int().min(1).max(200).optional(),
|
|
129
|
-
cursor: z.string().optional()
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "search_messages",
|
|
134
|
-
title: "Search one mailbox",
|
|
135
|
-
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.",
|
|
136
|
-
endpoint: "GET /messages/search",
|
|
137
|
-
readOnly: true,
|
|
138
|
-
inputSchema: {
|
|
139
|
-
identity_id: z.string(),
|
|
140
|
-
q: z.string(),
|
|
141
|
-
limit: z.number().int().min(1).max(200).optional()
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "send_message",
|
|
146
|
-
title: "Send a message",
|
|
147
|
-
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.",
|
|
148
|
-
endpoint: "POST /messages",
|
|
149
|
-
readOnly: false,
|
|
150
|
-
inputSchema: {
|
|
151
|
-
identity_id: z.string(),
|
|
152
|
-
to: z.union([z.string(), z.array(z.string())]),
|
|
153
|
-
cc: z.union([z.string(), z.array(z.string())]).optional(),
|
|
154
|
-
subject: z.string().optional(),
|
|
155
|
-
text: z.string().optional(),
|
|
156
|
-
html: z.string().optional(),
|
|
157
|
-
thread_id: z.string().optional(),
|
|
158
|
-
in_reply_to: z.string().optional()
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: "list_send_rules",
|
|
163
|
-
title: "What an address may write to",
|
|
164
|
-
description: "The allow and block list of one address, and the send policy it hangs off. Read this when a send was refused.",
|
|
165
|
-
endpoint: "GET /identities/{id}/send-rules",
|
|
166
|
-
readOnly: true,
|
|
167
|
-
inputSchema: { id: z.string() }
|
|
168
|
-
}
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
// src/index.ts
|
|
172
|
-
var DEFAULT_BASE_URL = "https://pidgeon.ai/api/v1";
|
|
173
|
-
function createServer(context) {
|
|
174
|
-
const server = new McpServer({ name: "pidgeon", version: "0.1.0" });
|
|
175
|
-
for (const tool of TOOLS) {
|
|
176
|
-
server.registerTool(
|
|
177
|
-
tool.name,
|
|
178
|
-
{
|
|
179
|
-
title: tool.title,
|
|
180
|
-
description: tool.description,
|
|
181
|
-
inputSchema: tool.inputSchema,
|
|
182
|
-
annotations: {
|
|
183
|
-
readOnlyHint: tool.readOnly,
|
|
184
|
-
/*
|
|
185
|
-
* Sending mail is not undoable and reaches somebody who did not ask
|
|
186
|
-
* to be part of this. A client that asks before a destructive call
|
|
187
|
-
* should be asking before that one.
|
|
188
|
-
*/
|
|
189
|
-
destructiveHint: !tool.readOnly,
|
|
190
|
-
openWorldHint: true
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
async (input) => {
|
|
194
|
-
try {
|
|
195
|
-
const result = await callEndpoint(tool, input, context);
|
|
196
|
-
return {
|
|
197
|
-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
198
|
-
};
|
|
199
|
-
} catch (error) {
|
|
200
|
-
const message = error instanceof PidgeonHttpError ? `${error.code}: ${error.message}` : error instanceof Error ? error.message : "The request failed.";
|
|
201
|
-
return { isError: true, content: [{ type: "text", text: message }] };
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
return server;
|
|
207
|
-
}
|
|
208
|
-
async function main() {
|
|
209
|
-
const apiKey = process.env.PIDGEON_API_KEY;
|
|
210
|
-
if (!apiKey) {
|
|
211
|
-
process.stderr.write(
|
|
212
|
-
"PIDGEON_API_KEY is not set. Create a key at https://pidgeon.ai/app/developers/keys \u2014 and give it the narrowest access the agent needs, because this hands it to a model.\n"
|
|
213
|
-
);
|
|
214
|
-
process.exit(1);
|
|
215
|
-
}
|
|
216
|
-
const server = createServer({
|
|
217
|
-
baseUrl: process.env.PIDGEON_BASE_URL ?? DEFAULT_BASE_URL,
|
|
218
|
-
apiKey
|
|
219
|
-
});
|
|
220
|
-
await server.connect(new StdioServerTransport());
|
|
221
|
-
}
|
|
222
|
-
if (process.env.PIDGEON_MCP_NO_MAIN !== "1") {
|
|
223
|
-
void main();
|
|
224
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
TOOLS,
|
|
4
|
+
createServer,
|
|
5
|
+
main
|
|
6
|
+
} from "./chunk-6R2DWW3P.js";
|
|
225
7
|
export {
|
|
226
8
|
TOOLS,
|
|
227
9
|
createServer,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/call.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 { 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\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({\n baseUrl: process.env.PIDGEON_BASE_URL ?? DEFAULT_BASE_URL,\n apiKey,\n });\n\n await server.connect(new StdioServerTransport());\n}\n\nexport { TOOLS } from './tools.js';\nexport type { ToolDefinition } from './tools.js';\n\n/*\n * Run when executed, not when imported — the tests import `createServer` and\n * must not open a transport on stdio while doing it.\n */\nif (process.env.PIDGEON_MCP_NO_MAIN !== '1') {\n void main();\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 { 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"],"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,IAAI,cAAc,KAAK,QAAQ;AAEtD,QAAM,YAAY,EAAE,GAAG,MAAM;AAO7B,QAAM,OAAO,SAAS,QAAQ,YAAY,CAAC,QAAQ,SAAiB;AAClE,UAAM,QAAQ,UAAU,IAAI;AAE5B,QAA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AAA,MACb;AAAA,IAEF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,SAAS,aAAa;AAAA,IAC1B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,IACzC;AAAA,EACF,CAAC;AAED,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;AASA,IAAI,QAAQ,IAAI,wBAAwB,KAAK;AAC3C,OAAK,KAAK;AACZ;","names":[]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pidgeon-ai/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"homepage": "https://pidgeon.ai",
|
|
18
18
|
"type": "module",
|
|
19
19
|
"bin": {
|
|
20
|
-
"pidgeon-mcp": "dist/
|
|
20
|
+
"pidgeon-mcp": "dist/cli.js"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
@@ -38,19 +38,18 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsup",
|
|
43
|
-
"typecheck": "tsc --noEmit",
|
|
44
|
-
"prepublishOnly": "pnpm build"
|
|
45
|
-
},
|
|
46
41
|
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
43
|
+
"zod": "^4.6.5",
|
|
44
|
+
"@pidgeon-ai/sdk": "1.0.0"
|
|
50
45
|
},
|
|
51
46
|
"devDependencies": {
|
|
52
47
|
"tsup": "^8.5.0",
|
|
53
48
|
"typescript": "^5",
|
|
54
49
|
"@types/node": "^24"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"typecheck": "tsc --noEmit"
|
|
55
54
|
}
|
|
56
|
-
}
|
|
55
|
+
}
|