@withpica/mcp-server 2.50.0 → 2.52.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.
Files changed (226) hide show
  1. package/.claude/settings.local.json +5 -0
  2. package/CHANGELOG.md +0 -25
  3. package/dist/prompts/index.d.ts +0 -32
  4. package/dist/prompts/index.d.ts.map +1 -1
  5. package/dist/prompts/index.js +0 -235
  6. package/dist/prompts/index.js.map +1 -1
  7. package/dist/server.d.ts +0 -26
  8. package/dist/server.d.ts.map +1 -1
  9. package/dist/server.js +10 -108
  10. package/dist/server.js.map +1 -1
  11. package/dist/tools/agent-identity.d.ts.map +1 -1
  12. package/dist/tools/agent-identity.js +0 -15
  13. package/dist/tools/agent-identity.js.map +1 -1
  14. package/dist/tools/agreement-types.d.ts.map +1 -1
  15. package/dist/tools/agreement-types.js +0 -24
  16. package/dist/tools/agreement-types.js.map +1 -1
  17. package/dist/tools/agreements.d.ts.map +1 -1
  18. package/dist/tools/agreements.js +3 -21
  19. package/dist/tools/agreements.js.map +1 -1
  20. package/dist/tools/analytics.d.ts.map +1 -1
  21. package/dist/tools/analytics.js +1 -19
  22. package/dist/tools/analytics.js.map +1 -1
  23. package/dist/tools/app-tools.d.ts.map +1 -1
  24. package/dist/tools/app-tools.js +2 -11
  25. package/dist/tools/app-tools.js.map +1 -1
  26. package/dist/tools/assets.d.ts.map +1 -1
  27. package/dist/tools/assets.js +0 -33
  28. package/dist/tools/assets.js.map +1 -1
  29. package/dist/tools/audio-files.d.ts +0 -5
  30. package/dist/tools/audio-files.d.ts.map +1 -1
  31. package/dist/tools/audio-files.js +0 -91
  32. package/dist/tools/audio-files.js.map +1 -1
  33. package/dist/tools/audit.d.ts.map +1 -1
  34. package/dist/tools/audit.js +2 -11
  35. package/dist/tools/audit.js.map +1 -1
  36. package/dist/tools/auth.d.ts.map +1 -1
  37. package/dist/tools/auth.js +0 -6
  38. package/dist/tools/auth.js.map +1 -1
  39. package/dist/tools/bulk.d.ts.map +1 -1
  40. package/dist/tools/bulk.js +0 -6
  41. package/dist/tools/bulk.js.map +1 -1
  42. package/dist/tools/calendar.d.ts.map +1 -1
  43. package/dist/tools/calendar.js +0 -3
  44. package/dist/tools/calendar.js.map +1 -1
  45. package/dist/tools/collaborators.d.ts.map +1 -1
  46. package/dist/tools/collaborators.js +3 -24
  47. package/dist/tools/collaborators.js.map +1 -1
  48. package/dist/tools/comparisons.d.ts.map +1 -1
  49. package/dist/tools/comparisons.js +0 -6
  50. package/dist/tools/comparisons.js.map +1 -1
  51. package/dist/tools/credits.d.ts +0 -18
  52. package/dist/tools/credits.d.ts.map +1 -1
  53. package/dist/tools/credits.js +4 -344
  54. package/dist/tools/credits.js.map +1 -1
  55. package/dist/tools/custody.d.ts.map +1 -1
  56. package/dist/tools/custody.js +2 -23
  57. package/dist/tools/custody.js.map +1 -1
  58. package/dist/tools/dashboard.d.ts.map +1 -1
  59. package/dist/tools/dashboard.js +7 -43
  60. package/dist/tools/dashboard.js.map +1 -1
  61. package/dist/tools/directory.d.ts.map +1 -1
  62. package/dist/tools/directory.js +0 -3
  63. package/dist/tools/directory.js.map +1 -1
  64. package/dist/tools/discovery.d.ts.map +1 -1
  65. package/dist/tools/discovery.js +7 -86
  66. package/dist/tools/discovery.js.map +1 -1
  67. package/dist/tools/disputes.d.ts.map +1 -1
  68. package/dist/tools/disputes.js +1 -4
  69. package/dist/tools/disputes.js.map +1 -1
  70. package/dist/tools/documents.d.ts.map +1 -1
  71. package/dist/tools/documents.js +0 -3
  72. package/dist/tools/documents.js.map +1 -1
  73. package/dist/tools/duplicates.d.ts.map +1 -1
  74. package/dist/tools/duplicates.js +0 -6
  75. package/dist/tools/duplicates.js.map +1 -1
  76. package/dist/tools/enrichment.d.ts.map +1 -1
  77. package/dist/tools/enrichment.js +0 -33
  78. package/dist/tools/enrichment.js.map +1 -1
  79. package/dist/tools/exports.d.ts.map +1 -1
  80. package/dist/tools/exports.js +3 -18
  81. package/dist/tools/exports.js.map +1 -1
  82. package/dist/tools/feedback.d.ts.map +1 -1
  83. package/dist/tools/feedback.js +0 -3
  84. package/dist/tools/feedback.js.map +1 -1
  85. package/dist/tools/files.d.ts +30 -0
  86. package/dist/tools/files.d.ts.map +1 -0
  87. package/dist/tools/files.js +98 -0
  88. package/dist/tools/files.js.map +1 -0
  89. package/dist/tools/groups.d.ts.map +1 -1
  90. package/dist/tools/groups.js +0 -12
  91. package/dist/tools/groups.js.map +1 -1
  92. package/dist/tools/import-documents.d.ts.map +1 -1
  93. package/dist/tools/import-documents.js +1 -10
  94. package/dist/tools/import-documents.js.map +1 -1
  95. package/dist/tools/import.d.ts.map +1 -1
  96. package/dist/tools/import.js +3 -36
  97. package/dist/tools/import.js.map +1 -1
  98. package/dist/tools/index.d.ts +4 -99
  99. package/dist/tools/index.d.ts.map +1 -1
  100. package/dist/tools/index.js +105 -182
  101. package/dist/tools/index.js.map +1 -1
  102. package/dist/tools/integrations.d.ts.map +1 -1
  103. package/dist/tools/integrations.js +8 -28
  104. package/dist/tools/integrations.js.map +1 -1
  105. package/dist/tools/labels.d.ts.map +1 -1
  106. package/dist/tools/labels.js +0 -3
  107. package/dist/tools/labels.js.map +1 -1
  108. package/dist/tools/licensing.d.ts.map +1 -1
  109. package/dist/tools/licensing.js +0 -15
  110. package/dist/tools/licensing.js.map +1 -1
  111. package/dist/tools/memory.d.ts.map +1 -1
  112. package/dist/tools/memory.js +3 -15
  113. package/dist/tools/memory.js.map +1 -1
  114. package/dist/tools/metadata.d.ts.map +1 -1
  115. package/dist/tools/metadata.js +15 -64
  116. package/dist/tools/metadata.js.map +1 -1
  117. package/dist/tools/multimedia.d.ts.map +1 -1
  118. package/dist/tools/multimedia.js +0 -15
  119. package/dist/tools/multimedia.js.map +1 -1
  120. package/dist/tools/my-reported-issues.d.ts.map +1 -1
  121. package/dist/tools/my-reported-issues.js +0 -3
  122. package/dist/tools/my-reported-issues.js.map +1 -1
  123. package/dist/tools/notes.d.ts.map +1 -1
  124. package/dist/tools/notes.js +0 -12
  125. package/dist/tools/notes.js.map +1 -1
  126. package/dist/tools/notifications.d.ts.map +1 -1
  127. package/dist/tools/notifications.js +1 -25
  128. package/dist/tools/notifications.js.map +1 -1
  129. package/dist/tools/onboarding.d.ts.map +1 -1
  130. package/dist/tools/onboarding.js +0 -3
  131. package/dist/tools/onboarding.js.map +1 -1
  132. package/dist/tools/people.d.ts.map +1 -1
  133. package/dist/tools/people.js +1 -16
  134. package/dist/tools/people.js.map +1 -1
  135. package/dist/tools/projects.d.ts.map +1 -1
  136. package/dist/tools/projects.js +0 -18
  137. package/dist/tools/projects.js.map +1 -1
  138. package/dist/tools/publishers.d.ts.map +1 -1
  139. package/dist/tools/publishers.js +0 -6
  140. package/dist/tools/publishers.js.map +1 -1
  141. package/dist/tools/recordings.d.ts.map +1 -1
  142. package/dist/tools/recordings.js +0 -15
  143. package/dist/tools/recordings.js.map +1 -1
  144. package/dist/tools/recovery-hints.d.ts.map +1 -1
  145. package/dist/tools/recovery-hints.js +2 -28
  146. package/dist/tools/recovery-hints.js.map +1 -1
  147. package/dist/tools/release-rich.d.ts.map +1 -1
  148. package/dist/tools/release-rich.js +2 -4
  149. package/dist/tools/release-rich.js.map +1 -1
  150. package/dist/tools/releases.d.ts.map +1 -1
  151. package/dist/tools/releases.js +0 -55
  152. package/dist/tools/releases.js.map +1 -1
  153. package/dist/tools/report-issue.d.ts.map +1 -1
  154. package/dist/tools/report-issue.js +0 -3
  155. package/dist/tools/report-issue.js.map +1 -1
  156. package/dist/tools/royalties.d.ts.map +1 -1
  157. package/dist/tools/royalties.js +3 -18
  158. package/dist/tools/royalties.js.map +1 -1
  159. package/dist/tools/search.d.ts.map +1 -1
  160. package/dist/tools/search.js +1 -10
  161. package/dist/tools/search.js.map +1 -1
  162. package/dist/tools/send.d.ts.map +1 -1
  163. package/dist/tools/send.js +0 -9
  164. package/dist/tools/send.js.map +1 -1
  165. package/dist/tools/sessions.d.ts.map +1 -1
  166. package/dist/tools/sessions.js +0 -12
  167. package/dist/tools/sessions.js.map +1 -1
  168. package/dist/tools/settings.d.ts.map +1 -1
  169. package/dist/tools/settings.js +3 -30
  170. package/dist/tools/settings.js.map +1 -1
  171. package/dist/tools/share-links.d.ts.map +1 -1
  172. package/dist/tools/share-links.js +0 -15
  173. package/dist/tools/share-links.js.map +1 -1
  174. package/dist/tools/signup.d.ts.map +1 -1
  175. package/dist/tools/signup.js +0 -3
  176. package/dist/tools/signup.js.map +1 -1
  177. package/dist/tools/split-sheets.d.ts.map +1 -1
  178. package/dist/tools/split-sheets.js +1 -22
  179. package/dist/tools/split-sheets.js.map +1 -1
  180. package/dist/tools/storage-config.d.ts.map +1 -1
  181. package/dist/tools/storage-config.js +0 -6
  182. package/dist/tools/storage-config.js.map +1 -1
  183. package/dist/tools/subscription.d.ts.map +1 -1
  184. package/dist/tools/subscription.js +10 -9
  185. package/dist/tools/subscription.js.map +1 -1
  186. package/dist/tools/sync-placements.d.ts.map +1 -1
  187. package/dist/tools/sync-placements.js +2 -20
  188. package/dist/tools/sync-placements.js.map +1 -1
  189. package/dist/tools/team.d.ts.map +1 -1
  190. package/dist/tools/team.js +0 -15
  191. package/dist/tools/team.js.map +1 -1
  192. package/dist/tools/telegram.d.ts.map +1 -1
  193. package/dist/tools/telegram.js +0 -9
  194. package/dist/tools/telegram.js.map +1 -1
  195. package/dist/tools/uploads.d.ts.map +1 -1
  196. package/dist/tools/uploads.js +0 -6
  197. package/dist/tools/uploads.js.map +1 -1
  198. package/dist/tools/works.d.ts.map +1 -1
  199. package/dist/tools/works.js +3 -37
  200. package/dist/tools/works.js.map +1 -1
  201. package/package.json +4 -4
  202. package/server.json +2 -2
  203. package/dist/prompts/creator-question-atlas.d.ts +0 -48
  204. package/dist/prompts/creator-question-atlas.d.ts.map +0 -1
  205. package/dist/prompts/creator-question-atlas.js +0 -601
  206. package/dist/prompts/creator-question-atlas.js.map +0 -1
  207. package/dist/tools/access-simulate.d.ts +0 -23
  208. package/dist/tools/access-simulate.d.ts.map +0 -1
  209. package/dist/tools/access-simulate.js +0 -165
  210. package/dist/tools/access-simulate.js.map +0 -1
  211. package/dist/tools/explainability.d.ts +0 -24
  212. package/dist/tools/explainability.d.ts.map +0 -1
  213. package/dist/tools/explainability.js +0 -137
  214. package/dist/tools/explainability.js.map +0 -1
  215. package/dist/tools/my-recent-questions.d.ts +0 -25
  216. package/dist/tools/my-recent-questions.d.ts.map +0 -1
  217. package/dist/tools/my-recent-questions.js +0 -186
  218. package/dist/tools/my-recent-questions.js.map +0 -1
  219. package/dist/tools/share-send.d.ts +0 -28
  220. package/dist/tools/share-send.d.ts.map +0 -1
  221. package/dist/tools/share-send.js +0 -131
  222. package/dist/tools/share-send.js.map +0 -1
  223. package/dist/tools/sharing.d.ts +0 -29
  224. package/dist/tools/sharing.d.ts.map +0 -1
  225. package/dist/tools/sharing.js +0 -131
  226. package/dist/tools/sharing.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ {
2
+ "disabledMcpjsonServers": [
3
+ "pica-directory"
4
+ ]
5
+ }
package/CHANGELOG.md CHANGED
@@ -11,31 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
- ### Changed
15
-
16
- - **Tool registry catch path now forwards `error_message` to the audit log (PR #308).**
17
- When a tool throws, the registry calls `formatError()` and now passes the
18
- parsed `message` through to `logToolExecution` as `error_message`. Pre-fix,
19
- every error row in `mcp_audit_log` landed with `error_message=null` because
20
- the wire shape stripped the field — even when the wrapper held the
21
- underlying cause. Net effect for diagnostics: rows like the 116 silent
22
- `pica_merge_duplicates` failures on 2026-04-09 (which couldn't be
23
- attributed to any specific cause) will now carry the message going forward.
24
- Sister change in `@withpica/mcp-utils` adds the field to `McpAuditEntry`.
25
-
26
- - **`pica_integrations_status` advertisement updated to current tools (PR #308).**
27
- ADR-179 (commit `dc1bfca72`, 2026-04-21) folded the six per-source
28
- `pica_enrich_*` tools into `pica_resolve_work` / `pica_resolve_person` /
29
- `pica_resolve_recording` with a `sources:[...]` parameter, then removed
30
- them. But `mcp-server/src/tools/integrations.ts` continued to advertise
31
- the removed names in the `platformReads` list, the tool description, and
32
- the summary prose. Agents reading the advertisement called names that no
33
- longer existed → UNKNOWN_ERROR loops on every catalog-enrichment ask
34
- routed through MLC/Spotify/MusicBrainz/YouTube/Discogs/ISNI. Now points
35
- at the surviving tools with the correct source value. Two regression
36
- tests in `integrations.test.ts` lock down that no removed
37
- `pica_enrich_*` tool name appears in the advertised `use_via` strings.
38
-
39
14
  ## [2.48.0] - 2026-05-03
40
15
 
41
16
  ### Changed
@@ -1,12 +1,7 @@
1
1
  /**
2
2
  * Prompt Registry for MCP Server
3
3
  * Manages pre-configured prompts for common workflows
4
- *
5
- * ADR-226 Phase 5: optionally takes a `PicaClient` so dynamic prompts
6
- * (currently `pica_continue`) can read from the Phase 4 substrate at fetch
7
- * time. Other prompts continue to render statically.
8
4
  */
9
- import { PicaClient } from "@withpica/mcp-sdk";
10
5
  export interface PromptDefinition {
11
6
  name: string;
12
7
  description: string;
@@ -27,8 +22,6 @@ export interface PromptResult {
27
22
  messages: PromptMessage[];
28
23
  }
29
24
  export declare class PromptRegistry {
30
- private pica?;
31
- constructor(pica?: PicaClient | undefined);
32
25
  /**
33
26
  * List all available prompts
34
27
  */
@@ -89,30 +82,5 @@ export declare class PromptRegistry {
89
82
  * Set recording splits — guided master ownership split assignment with verify gate
90
83
  */
91
84
  private getSetRecordingSplitsPrompt;
92
- /**
93
- * What's new — Atlas funnel for "what's new?", "any updates?", "catch me up".
94
- */
95
- private getWhatsNewPrompt;
96
- /**
97
- * What's wrong — Atlas funnel for "what's wrong with my songs?", "what
98
- * needs fixing?", "anything urgent?", "what should I do?".
99
- */
100
- private getWhatsWrongPrompt;
101
- /**
102
- * How much has this earned — Atlas-resolved royalties summary with
103
- * fallback nudge when no statements exist for the work.
104
- */
105
- private getHowMuchHasThisEarnedPrompt;
106
- /**
107
- * Who owes me something — multi-tool orchestration aggregating pending
108
- * invites, outstanding signatures, and open disputes into one view.
109
- */
110
- private getWhoOwesMeSomethingPrompt;
111
- /**
112
- * Pica continue — pick-up-where-you-left-off. Reads recent assistant_interactions
113
- * for the calling user, surfaces specific named open loops per ADR Decision 4
114
- * example, falls through to a clean "nothing in flight" message when empty.
115
- */
116
- private getPicaContinuePrompt;
117
85
  }
118
86
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,IAAI,CAAC;gBAAL,IAAI,CAAC,EAAE,UAAU,YAAA;IAErC;;OAEG;IACH,WAAW,IAAI,gBAAgB,EAAE;IAkJjC;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAkEvE;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAgC/B;;OAEG;IACH,OAAO,CAAC,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,cAAc;IACzB;;OAEG;IACH,WAAW,IAAI,gBAAgB,EAAE;IAuGjC;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IA8CvE;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAgC/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA+B/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqC/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAiCpC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoC7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAyChC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0C7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqChC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAiDnC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAuC/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAsC5B;;OAEG;IACH,OAAO,CAAC,2BAA2B;CA6CpC"}
@@ -1,9 +1,5 @@
1
1
  // Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
2
2
  export class PromptRegistry {
3
- pica;
4
- constructor(pica) {
5
- this.pica = pica;
6
- }
7
3
  /**
8
4
  * List all available prompts
9
5
  */
@@ -92,42 +88,6 @@ export class PromptRegistry {
92
88
  },
93
89
  ],
94
90
  },
95
- {
96
- name: "whats-new",
97
- description: "Daily-briefing funnel — surfaces what's changed since the user last looked",
98
- arguments: [],
99
- },
100
- {
101
- name: "whats-wrong",
102
- description: "Attention funnel — surfaces what's broken, blocked, or needs the user's input",
103
- arguments: [],
104
- },
105
- {
106
- name: "how-much-has-this-earned",
107
- description: "Earnings lookup for a specific work — falls back to a statement-import nudge when no royalties have been imported",
108
- arguments: [
109
- {
110
- name: "work_id",
111
- description: "The work to summarise earnings for — required so the prompt can pull statements for the right song",
112
- required: true,
113
- },
114
- ],
115
- },
116
- {
117
- name: "who-owes-me-something",
118
- description: "Aggregates outstanding work owed to the user — pending invites, open disputes, and outstanding signatures — into a single 'what's outstanding' view",
119
- arguments: [],
120
- },
121
- {
122
- name: "am-i-ready-to-register",
123
- description: "Alias of register-my-works — check registration status across PROs and prepare ready works for submission",
124
- arguments: [],
125
- },
126
- {
127
- name: "pica_continue",
128
- description: "Pick up where you left off — surfaces specific open loops from your recent assistant_interactions (unconfirmed writes, mid-flow drop-offs, mutations with no follow-up read)",
129
- arguments: [],
130
- },
131
91
  ];
132
92
  }
133
93
  /**
@@ -161,20 +121,6 @@ export class PromptRegistry {
161
121
  return this.getLogASessionPrompt(args?.work_id);
162
122
  case "set-recording-splits":
163
123
  return this.getSetRecordingSplitsPrompt(args?.recording_id);
164
- case "whats-new":
165
- return this.getWhatsNewPrompt();
166
- case "whats-wrong":
167
- return this.getWhatsWrongPrompt();
168
- case "how-much-has-this-earned":
169
- return this.getHowMuchHasThisEarnedPrompt(args?.work_id);
170
- case "who-owes-me-something":
171
- return this.getWhoOwesMeSomethingPrompt();
172
- case "am-i-ready-to-register":
173
- // Alias — falls through to the same handler so existing
174
- // `register-my-works` callers keep working.
175
- return this.getRegisterMyWorksPrompt();
176
- case "pica_continue":
177
- return this.getPicaContinuePrompt();
178
124
  default:
179
125
  throw new Error(`Prompt not found: ${name}`);
180
126
  }
@@ -695,186 +641,5 @@ If at any point the totals are off or I waver, stop and re-confirm. Splits are n
695
641
  ],
696
642
  };
697
643
  }
698
- /**
699
- * What's new — Atlas funnel for "what's new?", "any updates?", "catch me up".
700
- */
701
- getWhatsNewPrompt() {
702
- return {
703
- messages: [
704
- {
705
- role: "user",
706
- content: {
707
- type: "text",
708
- text: `The user just asked "what's new?" or one of its synonyms (any updates, catch me up, what's been happening).
709
-
710
- Invoke pica_dashboard_briefing and surface the result. The briefing groups recent activity into deltas the user cares about — new credits, registration progress, statements imported, collaborators that joined, etc.
711
-
712
- If the briefing returns no items (empty or "nothing new"), say so explicitly. Don't fabricate updates and don't pad with stale information. A clean "nothing new since you last looked" is the right answer when the substrate is quiet.
713
-
714
- Format the response as a tight summary — group by category, lead with what changed, don't recapitulate the whole catalog. The user asked for the diff, not the snapshot.`,
715
- },
716
- },
717
- ],
718
- };
719
- }
720
- /**
721
- * What's wrong — Atlas funnel for "what's wrong with my songs?", "what
722
- * needs fixing?", "anything urgent?", "what should I do?".
723
- */
724
- getWhatsWrongPrompt() {
725
- return {
726
- messages: [
727
- {
728
- role: "user",
729
- content: {
730
- type: "text",
731
- text: `The user just asked "what's wrong with my songs?" or one of its synonyms (what's broken, what needs fixing, what should I do, anything urgent).
732
-
733
- Invoke pica_dashboard_attention and surface the result. The attention queue lists items that need the user's input or judgement — works missing required fields for registration, splits that don't total 100%, collaborators awaiting confirmation, disputes that have been open too long.
734
-
735
- For each attention item, include a one-line "why it matters" and the canonical next tool to fix it. Don't bury the action — the user asked what's wrong because they want to fix it.
736
-
737
- If the attention queue is empty, say so explicitly: "nothing urgent right now". That is itself a valuable answer — don't pad it.`,
738
- },
739
- },
740
- ],
741
- };
742
- }
743
- /**
744
- * How much has this earned — Atlas-resolved royalties summary with
745
- * fallback nudge when no statements exist for the work.
746
- */
747
- getHowMuchHasThisEarnedPrompt(workId) {
748
- const workInstruction = workId
749
- ? `The work in question is ${workId}.`
750
- : `Ask me which song I'm asking about. Use pica_search_all({ kind: 'work', query: <name> }) to resolve a name to a work_id if I name the song instead of giving you an ID.`;
751
- return {
752
- messages: [
753
- {
754
- role: "user",
755
- content: {
756
- type: "text",
757
- text: `The user wants to know how much a specific song has earned.
758
-
759
- ${workInstruction}
760
-
761
- Step 1 — call pica_royalties_summary({ work_id: <id> }) to pull cumulative earnings broken down by source (PRO, NRO, sync, mechanical, neighbouring rights).
762
-
763
- Step 2 — IF the summary returns zero rows or "no statements found":
764
- - Say so plainly. "I don't see any earnings statements for this song yet."
765
- - Offer the import path: "Would you like to import a recent PRO, NRO, or sync statement?" — this maps to pica_ingest_statement, which accepts CSV / PDF / JSON exports from PRS, BMI, ASCAP, MLC, Songtrust, distributors, and sync agencies.
766
- - Do NOT fabricate earnings. Empty is empty.
767
-
768
- Step 3 — IF the summary returns data:
769
- - Lead with the total figure in the user's preferred currency.
770
- - Break it down by source and by year (most recent year first).
771
- - Surface anomalies: a sudden drop, a missing quarter, a new platform that started paying.
772
- - Offer pica_statements_list as the natural next step if they want to drill into a specific statement.
773
-
774
- Step 4 — close with the right next action:
775
- - If earnings look wrong, suggest pica_disputes_create to flag it.
776
- - If earnings look right, suggest pica_export_industry_ready to generate a registration package that captures the work's earning history.`,
777
- },
778
- },
779
- ],
780
- };
781
- }
782
- /**
783
- * Who owes me something — multi-tool orchestration aggregating pending
784
- * invites, outstanding signatures, and open disputes into one view.
785
- */
786
- getWhoOwesMeSomethingPrompt() {
787
- return {
788
- messages: [
789
- {
790
- role: "user",
791
- content: {
792
- type: "text",
793
- text: `The user just asked "who owes me something?" or one of its synonyms (who hasn't responded, what's outstanding, who owes me a reply).
794
-
795
- This is a multi-tool aggregation — there is no single "outstanding" tool. Pull from three substrates and merge into a single view:
796
-
797
- 1. pica_collaborators_invites_list — collaborators you invited who haven't accepted yet. Include sent_at so the user can see how long each has been outstanding.
798
-
799
- 2. pica_disputes_list — disputes that are open, awaiting the other party's response. Include opened_at and the disputed claim's summary.
800
-
801
- 3. Outstanding signatures — call pica_split_sheets_list (or pica_agreements_query if split sheets aren't applicable) to find documents that have been sent for signature but not all parties have signed. Surface each pending signer with the document title.
802
-
803
- Render the aggregated output grouped by person where possible — if "Alice Smith" appears in two of the three buckets (e.g., invited collaborator AND awaiting signature), collapse them into one entry under her name. Otherwise group by category.
804
-
805
- For each outstanding item, include:
806
- - Who owes the response
807
- - What they owe (accept invite, sign document, respond to dispute)
808
- - How long they've been sitting on it
809
- - The canonical next action: "Want me to nudge them?" → pica_collaborators_remind / pica_split_sheet_send (resend) / pica_disputes_nudge
810
-
811
- If all three buckets are empty: say "nothing outstanding right now — everyone you're waiting on has responded." That is the right answer; don't pad it.`,
812
- },
813
- },
814
- ],
815
- };
816
- }
817
- /**
818
- * Pica continue — pick-up-where-you-left-off. Reads recent assistant_interactions
819
- * for the calling user, surfaces specific named open loops per ADR Decision 4
820
- * example, falls through to a clean "nothing in flight" message when empty.
821
- */
822
- async getPicaContinuePrompt() {
823
- let openLoops = [];
824
- let fetchFailed = false;
825
- if (this.pica) {
826
- try {
827
- openLoops = await this.pica.assistantInteractions.detectOpenLoops();
828
- }
829
- catch {
830
- // Substrate read failed (network blip, RLS rejection, partition
831
- // missing). Render the static fallback so the prompt still works.
832
- fetchFailed = true;
833
- }
834
- }
835
- const intro = `The user wants to pick up where they left off.
836
-
837
- `;
838
- let body;
839
- if (fetchFailed || !this.pica) {
840
- body = `I couldn't read your recent activity right now. Ask the user what they were last working on, or invoke pica_my_recent_questions to refresh and try again.`;
841
- }
842
- else if (openLoops.length === 0) {
843
- body =
844
- `No recent open loops were found in your assistant_interactions history (last 3 days). ` +
845
- `Tell the user "nothing in flight right now — what would you like to start on?" and offer pica_dashboard_briefing as a starting point.`;
846
- }
847
- else {
848
- const offers = openLoops.slice(0, 5).map(formatOpenLoopOffer).join("\n");
849
- const more = openLoops.length > 5
850
- ? `\n\n_+${openLoops.length - 5} more open loops — ask the user if they want the full list._`
851
- : "";
852
- body =
853
- `Here are the user's open loops from the last 3 days. Render each as a concrete continuation offer — name the entity, name the partial action, end with "Continue?".\n\n` +
854
- `${offers}${more}\n\n` +
855
- `Pick the most recent or highest-priority offer and lead with it. Do NOT dump all five at once — work one at a time. After the user picks one, invoke the canonical follow-up tool for that intent (e.g. pica_works_inspect to re-orient on a half-imported work, pica_credits_list to resume a credits sweep, pica_ingest_statement to resume a statement import).`;
856
- }
857
- return {
858
- messages: [
859
- {
860
- role: "user",
861
- content: {
862
- type: "text",
863
- text: intro + body,
864
- },
865
- },
866
- ],
867
- };
868
- }
869
- }
870
- function formatOpenLoopOffer(loop) {
871
- const reasonLabel = loop.reason === "unconfirmed_write"
872
- ? "awaiting your confirmation"
873
- : "stopped mid-flow";
874
- const summary = loop.result_summary || loop.intent;
875
- const entity = loop.entity_type && loop.entity_ids && loop.entity_ids.length > 0
876
- ? ` on ${loop.entity_type} ${loop.entity_ids[0]}`
877
- : "";
878
- return `▎ "${summary}"${entity} — ${reasonLabel} (session ${loop.session_id.slice(0, 8)}, ${new Date(loop.created_at).toISOString().slice(0, 16)}). Continue?`;
879
644
  }
880
645
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAmC7D,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAEzC;;OAEG;IACH,WAAW;QACT,OAAO;YACL;gBACE,IAAI,EAAE,iBAAiB;gBACvB,WAAW,EACT,+FAA+F;gBACjG,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,iBAAiB;gBACvB,WAAW,EACT,kEAAkE;gBACpE,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,iBAAiB;gBACvB,WAAW,EACT,2FAA2F;gBAC7F,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,cAAc;gBACpB,WAAW,EACT,2EAA2E;gBAC7E,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,uBAAuB;gBAC7B,WAAW,EACT,6GAA6G;gBAC/G,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,WAAW,EACT,+EAA+E;gBACjF,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,mBAAmB;gBACzB,WAAW,EACT,iIAAiI;gBACnI,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,WAAW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E,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;;;EAIhB,eAAe;;;;;;;;;;;;;;;;6HAgB4G;qBAClH;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,2BAA2B,CAAC,WAAoB;QACtD,MAAM,oBAAoB,GAAG,WAAW;YACtC,CAAC,CAAC,qBAAqB,WAAW,GAAG;YACrC,CAAC,CAAC,oIAAoI,CAAC;QAEzI,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;;;EAIhB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;0IAwBoH;qBAC/H;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
package/dist/server.d.ts CHANGED
@@ -7,25 +7,7 @@ export declare class PicaMcpServer {
7
7
  private promptRegistry;
8
8
  private config;
9
9
  private httpServer?;
10
- private readonly sessionId;
11
10
  constructor(config: ServerConfig);
12
- /**
13
- * Construct the dual-relay McpAuditLogger.
14
- *
15
- * One callback, two policies:
16
- * - mcp_audit_log (via /api/mcp/audit): write-tool only — preserves
17
- * ADR-154 F5's audit-log shape unchanged.
18
- * - assistant_interactions + mcp_sessions (via
19
- * /api/mcp/internal/log-interaction): EVERY tool call —
20
- * ADR-226 Decision 8.
21
- *
22
- * `logReads: true` is mandatory: the McpAuditLogger short-circuits on
23
- * `risk_level === "safe"` by default, which would block read-tool
24
- * calls from reaching the substrate relay. The mcp_audit_log endpoint
25
- * itself stays write-tool-only via a `risk_level !== "safe"` gate
26
- * inside the callback.
27
- */
28
- private buildAuditLogger;
29
11
  /**
30
12
  * Reinitialize server with new credentials (called after successful auth)
31
13
  */
@@ -55,14 +37,6 @@ export declare class PicaMcpServer {
55
37
  * - Otherwise → stdio (default, for Claude Code / Cursor / VS Code)
56
38
  */
57
39
  start(): Promise<void>;
58
- /**
59
- * ADR-226 Phase 6 — fetch the user's vocabulary and append it to the
60
- * SDK Server's static instructions string. Bails silently on lobby
61
- * mode (no apiKey-to-user mapping yet) or any fetch failure (the base
62
- * instructions are still valid; vocabulary is a layer on top, not a
63
- * gate). Runs at most once per server instance.
64
- */
65
- private injectVocabularyInstructions;
66
40
  private startStdio;
67
41
  private startHttp;
68
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiB3C,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAoB;IAChC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAkC;IAKrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;gBAEtC,MAAM,EAAE,YAAY;IAmEhC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,gBAAgB;IAsCxB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IA8ClC;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,IAAI;IAmCf;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;;;OAMG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwC5B;;;;;;OAMG;YACW,4BAA4B;YAuB5B,UAAU;YAKV,SAAS;IA6HvB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkDxB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAS5B"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAe3C,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAoB;IAChC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAkC;gBAEzC,MAAM,EAAE,YAAY;IAqEhC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAgDlC;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,IAAI;IAqCf;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;;;OAMG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAqBd,UAAU;YAKV,SAAS;IA6HvB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkDxB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAS5B"}
package/dist/server.js CHANGED
@@ -8,13 +8,13 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
8
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
9
9
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
10
10
  import { createServer } from "node:http";
11
- import { timingSafeEqual, randomUUID } from "node:crypto";
11
+ import { timingSafeEqual } from "node:crypto";
12
12
  import { PicaClient } from "@withpica/mcp-sdk";
13
13
  import { ToolRegistry } from "./tools/index.js";
14
14
  import { ResourceRegistry } from "./resources/index.js";
15
15
  import { PromptRegistry } from "./prompts/index.js";
16
16
  import { logError } from "@withpica/mcp-utils";
17
- import { makeStdioCallerContext, makeHttpAuditFn, makeHttpInteractionFn, McpAuditLogger, } from "@withpica/mcp-utils";
17
+ import { makeStdioCallerContext, makeHttpAuditFn, McpAuditLogger, } from "@withpica/mcp-utils";
18
18
  import { SERVER_INSTRUCTIONS_AUTHENTICATED, SERVER_INSTRUCTIONS_UNAUTHENTICATED, } from "./server-instructions.js";
19
19
  export class PicaMcpServer {
20
20
  server;
@@ -24,11 +24,6 @@ export class PicaMcpServer {
24
24
  promptRegistry;
25
25
  config;
26
26
  httpServer;
27
- // ADR-226 Phase 4 PR-B.5 — session UUID generated at process start and
28
- // carried through every tool call's interaction relay. Decision 8 source
29
- // rule for stdio: UUID generated at server initialize for the process
30
- // lifetime.
31
- sessionId = randomUUID();
32
27
  constructor(config) {
33
28
  this.config = config;
34
29
  // Initialize PICA SDK client (null in lobby mode)
@@ -72,62 +67,14 @@ export class PicaMcpServer {
72
67
  // Initialize registries with stdio caller context (api key hash)
73
68
  this.toolRegistry = new ToolRegistry(this.pica, config, (apiKey) => this.reinitialize(apiKey), makeStdioCallerContext(config.picaApiKey), () => this.signOut());
74
69
  this.resourceRegistry = new ResourceRegistry(this.pica, config);
75
- this.promptRegistry = new PromptRegistry(this.pica ?? undefined);
76
- // Wire audit logger — fire-and-forget POST to /api/mcp/audit AND
77
- // /api/mcp/internal/log-interaction. ADR-226 Phase 4 PR-B.5: every
78
- // tool call (read + write) writes one assistant_interactions row +
79
- // bumps mcp_sessions; the original audit endpoint stays write-tool-only.
80
- this.toolRegistry.setAuditLogger(this.buildAuditLogger(config.picaApiKey, config.picaApiUrl));
70
+ this.promptRegistry = new PromptRegistry();
71
+ // Wire audit logger — fire-and-forget POST to /api/mcp/audit
72
+ this.toolRegistry.setAuditLogger(new McpAuditLogger(makeHttpAuditFn({
73
+ baseUrl: config.picaApiUrl,
74
+ apiKey: config.picaApiKey,
75
+ })));
81
76
  this.setupHandlers();
82
77
  }
83
- /**
84
- * Construct the dual-relay McpAuditLogger.
85
- *
86
- * One callback, two policies:
87
- * - mcp_audit_log (via /api/mcp/audit): write-tool only — preserves
88
- * ADR-154 F5's audit-log shape unchanged.
89
- * - assistant_interactions + mcp_sessions (via
90
- * /api/mcp/internal/log-interaction): EVERY tool call —
91
- * ADR-226 Decision 8.
92
- *
93
- * `logReads: true` is mandatory: the McpAuditLogger short-circuits on
94
- * `risk_level === "safe"` by default, which would block read-tool
95
- * calls from reaching the substrate relay. The mcp_audit_log endpoint
96
- * itself stays write-tool-only via a `risk_level !== "safe"` gate
97
- * inside the callback.
98
- */
99
- buildAuditLogger(apiKey, baseUrl) {
100
- const interactionCtx = {
101
- sessionId: this.sessionId,
102
- // Stdio doesn't have access to clientInfo at construction time —
103
- // the SDK's `getClientVersion()` only returns after `initialize`
104
- // has been received. For now we send nulls; the relay endpoint
105
- // upserts mcp_sessions with NULL agent identity, and an enrichment
106
- // pass after `oninitialized` could update later.
107
- clientName: null,
108
- clientVersion: null,
109
- // user_agent on stdio is "stdio:<pid>" — distinct from HTTP's
110
- // browser-style UA but useful for grouping per-process activity.
111
- userAgent: `stdio:${process.pid}`,
112
- };
113
- const auditFn = makeHttpAuditFn({ baseUrl, apiKey });
114
- const interactionFn = makeHttpInteractionFn({
115
- baseUrl,
116
- apiKey,
117
- context: interactionCtx,
118
- });
119
- return new McpAuditLogger(async (entry) => {
120
- // Both fire-and-forget; failures swallowed by Promise.allSettled +
121
- // McpAuditLogger's own try/catch wrapper. Telemetry must not break
122
- // tool execution.
123
- await Promise.allSettled([
124
- // mcp_audit_log: write tools only (preserves ADR-154 F5 behaviour).
125
- entry.risk_level !== "safe" ? auditFn(entry) : Promise.resolve(),
126
- // assistant_interactions: EVERY tool call (ADR-226 Decision 8).
127
- interactionFn(entry),
128
- ]);
129
- }, /* logReads */ true);
130
- }
131
78
  /**
132
79
  * Reinitialize server with new credentials (called after successful auth)
133
80
  */
@@ -139,7 +86,7 @@ export class PicaMcpServer {
139
86
  });
140
87
  this.config = { ...this.config, picaApiKey: apiKey, lobbyMode: false };
141
88
  this.toolRegistry = new ToolRegistry(this.pica, this.config, (key) => this.reinitialize(key), makeStdioCallerContext(apiKey), () => this.signOut());
142
- this.toolRegistry.setAuditLogger(this.buildAuditLogger(apiKey, this.config.picaApiUrl));
89
+ this.toolRegistry.setAuditLogger(new McpAuditLogger(makeHttpAuditFn({ baseUrl: this.config.picaApiUrl, apiKey })));
143
90
  this.resourceRegistry = new ResourceRegistry(this.pica, this.config);
144
91
  console.error("[MCP Server] Reinitialized with new credentials");
145
92
  // Tell the client the tool + resource lists have changed so it
@@ -177,7 +124,7 @@ export class PicaMcpServer {
177
124
  this.pica = null;
178
125
  this.config = { ...this.config, picaApiKey: "", lobbyMode: true };
179
126
  this.toolRegistry = new ToolRegistry(this.pica, this.config, (key) => this.reinitialize(key), makeStdioCallerContext(""), () => this.signOut());
180
- this.toolRegistry.setAuditLogger(this.buildAuditLogger("", this.config.picaApiUrl));
127
+ this.toolRegistry.setAuditLogger(new McpAuditLogger(makeHttpAuditFn({ baseUrl: this.config.picaApiUrl, apiKey: "" })));
181
128
  this.resourceRegistry = new ResourceRegistry(this.pica, this.config);
182
129
  console.error("[MCP Server] Reset to lobby mode after sign_out");
183
130
  // Same listChanged story as reinitialize() — without these the
@@ -206,24 +153,6 @@ export class PicaMcpServer {
206
153
  * - Otherwise → stdio (default, for Claude Code / Cursor / VS Code)
207
154
  */
208
155
  async start() {
209
- // ADR-226 Phase 6 — vocabulary context-prepend at handshake.
210
- // Mutate the SDK's `_instructions` field BEFORE `connect(transport)`
211
- // so the InitializeResult sent to the client includes the user's
212
- // vocabulary preferences appended to the base ADR-208 instructions.
213
- //
214
- // This is a controlled coupling to the SDK's private `_instructions`
215
- // field declared in
216
- // node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts:78
217
- // The field has been stable since SDK 1.0; the SDK is pinned in
218
- // package.json so a future minor bump won't silently break this.
219
- // A unit test at __tests__/server-vocabulary-injection.test.ts
220
- // catches a rename within one CI cycle.
221
- //
222
- // Gated on `this.pica && !lobbyMode` because vocabulary is per-user
223
- // and only stdio (one process = one user) maps cleanly to a single
224
- // static instructions string. HTTP / lobby skip the mutation; their
225
- // initialize-time instructions stay as the static catalog version.
226
- await this.injectVocabularyInstructions();
227
156
  const mode = process.env.MCP_TRANSPORT;
228
157
  if (mode === "http") {
229
158
  await this.startHttp();
@@ -238,33 +167,6 @@ export class PicaMcpServer {
238
167
  console.error(`[MCP Server] API URL: ${this.config.picaApiUrl}`);
239
168
  console.error("[MCP Server] Ready to accept connections");
240
169
  }
241
- /**
242
- * ADR-226 Phase 6 — fetch the user's vocabulary and append it to the
243
- * SDK Server's static instructions string. Bails silently on lobby
244
- * mode (no apiKey-to-user mapping yet) or any fetch failure (the base
245
- * instructions are still valid; vocabulary is a layer on top, not a
246
- * gate). Runs at most once per server instance.
247
- */
248
- async injectVocabularyInstructions() {
249
- if (!this.pica || this.config.lobbyMode)
250
- return;
251
- try {
252
- const result = await this.pica.assistantInteractions.getVocabularyContext();
253
- const vocab = result?.instructions;
254
- if (!vocab)
255
- return;
256
- const server = this.server;
257
- const base = server._instructions ?? "";
258
- server._instructions = base ? `${base}\n\n${vocab}` : vocab;
259
- }
260
- catch (err) {
261
- // Vocabulary injection is best-effort — never block boot on it.
262
- // Logged at warn so a transient network blip doesn't generate a
263
- // Sentry error event per feedback_auth_handler_log_level.md.
264
- const cause = err instanceof Error ? err.message : String(err);
265
- console.error(`[MCP Server] Vocabulary injection failed (continuing with base instructions): ${cause}`);
266
- }
267
- }
268
170
  async startStdio() {
269
171
  const transport = new StdioServerTransport();
270
172
  await this.server.connect(transport);