@paigy/mcp 0.14.2 → 0.16.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/dist/index.js CHANGED
@@ -1,21 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
3
2
  import {
4
- awaitReply,
5
- checkReplies,
6
- scheduleCallback,
7
- setTaskState,
8
- submitNotification
9
- } from "./chunk-OSQ3UXY6.js";
3
+ autoConfigureClients,
4
+ claudeInstallHint
5
+ } from "./chunk-U3WODCOE.js";
6
+ import {
7
+ clearSurface,
8
+ writeSurface
9
+ } from "./chunk-3SVNPJPN.js";
10
10
  import {
11
11
  NotifyRequestSchema,
12
12
  ScheduleCallbackSchema,
13
13
  SetTaskStateSchema,
14
- clearSurface,
14
+ UnpairedError,
15
+ awaitReply,
16
+ checkReplies,
15
17
  deleteKeyFile,
16
18
  deleteToken,
17
19
  fetchCredential,
18
20
  finalizeE2ee,
21
+ lintNotify,
19
22
  pairStep,
20
23
  readKeyFile,
21
24
  readToken,
@@ -23,10 +26,12 @@ import {
23
26
  revokeToken,
24
27
  saveKeyFile,
25
28
  saveToken,
29
+ scheduleCallback,
30
+ setTaskState,
26
31
  sleep,
27
32
  startE2ee,
28
- writeSurface
29
- } from "./chunk-WGOGS2JC.js";
33
+ submitNotification
34
+ } from "./chunk-R3YGSGPX.js";
30
35
 
31
36
  // src/index.ts
32
37
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -36,52 +41,6 @@ import {
36
41
  ListToolsRequestSchema
37
42
  } from "@modelcontextprotocol/sdk/types.js";
38
43
  import { execSync } from "child_process";
39
-
40
- // src/lint.ts
41
- var TITLE_MAX = 90;
42
- var CHUNKS_MAX = 8;
43
- var CHUNK_MAX = 300;
44
- var ASK_MAX = 600;
45
- var OPTION_MAX = 80;
46
- var NEEDS_MAX = 6;
47
- var UNSPEAKABLE = /```|\n/;
48
- function lintNotify(req) {
49
- const problems = [];
50
- if (req.ask !== void 0) {
51
- if (req.ask.length > ASK_MAX)
52
- problems.push(`ask is ${req.ask.length} chars \u2014 state the need and why it matters now in \u2264${ASK_MAX}; move detail into a smaller follow-up`);
53
- if (UNSPEAKABLE.test(req.ask))
54
- problems.push("ask contains code fences or newlines \u2014 write it as plain prose (it may be read aloud on a call)");
55
- for (const n of req.needs ?? []) {
56
- if (n.length > OPTION_MAX) problems.push(`need "${n.slice(0, 40)}\u2026" is too long \u2014 each need is a short phrase (\u2264${OPTION_MAX} chars)`);
57
- }
58
- if ((req.needs?.length ?? 0) > NEEDS_MAX)
59
- problems.push(`${req.needs?.length} needs \u2014 cap at ${NEEDS_MAX}; a call can't cover more in one conversation, split the rest into a second ask`);
60
- return problems;
61
- }
62
- const spoken = req.urgency === "call" || req.urgency === "banner";
63
- if (req.context) {
64
- if (req.context.title.length > TITLE_MAX)
65
- problems.push(`title is ${req.context.title.length} chars \u2014 shorten to \u2264${TITLE_MAX} (it's what shows on the banner / gets spoken on a ring)`);
66
- if (UNSPEAKABLE.test(req.context.title))
67
- problems.push("title contains code fences or newlines \u2014 one plain-prose line");
68
- if (req.context.description.length > CHUNKS_MAX)
69
- problems.push(`${req.context.description.length} description chunks \u2014 cap at ${CHUNKS_MAX}; merge or drop the rest`);
70
- for (const [i, chunk] of req.context.description.entries()) {
71
- if (chunk.length > CHUNK_MAX)
72
- problems.push(`description[${i}] is ${chunk.length} chars \u2014 split it into standalone points of \u2264${CHUNK_MAX}`);
73
- }
74
- if (spoken && UNSPEAKABLE.test(req.context.description.join(" ")))
75
- problems.push("urgency is 'call'/'banner' but the description has code fences/newlines-in-chunk \u2014 rewrite in spoken register (it will be read aloud)");
76
- }
77
- for (const o of req.options ?? []) {
78
- if (o.label.length > OPTION_MAX)
79
- problems.push(`option label "${o.label.slice(0, 40)}\u2026" is ${o.label.length} chars \u2014 labels must read at a glance (\u2264${OPTION_MAX}); move detail into the description`);
80
- }
81
- return problems;
82
- }
83
-
84
- // src/index.ts
85
44
  import { z } from "zod";
86
45
  import qrcode from "qrcode-generator";
87
46
 
@@ -111,6 +70,7 @@ function json(s) {
111
70
  }
112
71
 
113
72
  // src/index.ts
73
+ var ONBOARD_MSG = "Not paired with Paigy yet \u2014 call the `pair` tool to connect this agent (it returns an approval link to show the user), then retry. Manual fallback: `npx -y @paigy/mcp paigy-mcp-onboard`.";
114
74
  var AwaitReplySchema = z.object({
115
75
  notificationId: z.string().describe("The notificationId returned by notify_user \u2014 waits for the user's reply to THIS notification only.")
116
76
  });
@@ -151,6 +111,16 @@ function pairedResult(token, sas, note, e2ee) {
151
111
  base.verify_message = `This pairing is end-to-end encrypted. Ask the user to verify this code matches the one on their phone: ${sas}` + (e2ee ? "" : " (identity key not yet confirmed on the phone).");
152
112
  }
153
113
  if (note) base.note = note;
114
+ try {
115
+ const registered = autoConfigureClients();
116
+ if (registered.length) {
117
+ base.auto_registered = registered;
118
+ base.auto_register_message = `Also registered the Paigy MCP server in: ${registered.join("; ")}. Tell the user \u2014 those tools pick it up on their next restart/reload.`;
119
+ }
120
+ const hint = claudeInstallHint();
121
+ if (hint) base.claude_hint = hint;
122
+ } catch {
123
+ }
154
124
  return { content: [{ type: "text", text: JSON.stringify(base) }] };
155
125
  }
156
126
  function awaitingConfirmResult(sas, device_code) {
@@ -221,6 +191,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
221
191
  ]
222
192
  }));
223
193
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
194
+ try {
195
+ return await handleTool(request);
196
+ } catch (e) {
197
+ if (e instanceof UnpairedError) throw new Error(ONBOARD_MSG);
198
+ throw e;
199
+ }
200
+ });
201
+ async function handleTool(request) {
224
202
  switch (request.params.name) {
225
203
  case "pair": {
226
204
  const { device_code } = PairSchema.parse(request.params.arguments ?? {});
@@ -369,6 +347,6 @@ Enter it in the Paigy app (Inbox \u2192 Add a new agent).`,
369
347
  default:
370
348
  throw new Error(`Unknown tool: ${request.params.name}`);
371
349
  }
372
- });
350
+ }
373
351
  var transport = new StdioServerTransport();
374
352
  await server.connect(transport);