@withpica/mcp-server 2.1.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/README.md +305 -0
  2. package/dist/config.d.ts +34 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +33 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/index.d.ts +7 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +34 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/pica-sdk.d.ts +1162 -0
  11. package/dist/pica-sdk.d.ts.map +1 -0
  12. package/dist/pica-sdk.js +1371 -0
  13. package/dist/pica-sdk.js.map +1 -0
  14. package/dist/prompts/index.d.ts +78 -0
  15. package/dist/prompts/index.d.ts.map +1 -0
  16. package/dist/prompts/index.js +513 -0
  17. package/dist/prompts/index.js.map +1 -0
  18. package/dist/resources/index.d.ts +64 -0
  19. package/dist/resources/index.d.ts.map +1 -0
  20. package/dist/resources/index.js +310 -0
  21. package/dist/resources/index.js.map +1 -0
  22. package/dist/resources/llms-primer.d.ts +2 -0
  23. package/dist/resources/llms-primer.d.ts.map +1 -0
  24. package/dist/resources/llms-primer.js +67 -0
  25. package/dist/resources/llms-primer.js.map +1 -0
  26. package/dist/server.d.ts +27 -0
  27. package/dist/server.d.ts.map +1 -0
  28. package/dist/server.js +140 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/tools/agreement-types.d.ts +37 -0
  31. package/dist/tools/agreement-types.d.ts.map +1 -0
  32. package/dist/tools/agreement-types.js +579 -0
  33. package/dist/tools/agreement-types.js.map +1 -0
  34. package/dist/tools/agreements.d.ts +21 -0
  35. package/dist/tools/agreements.d.ts.map +1 -0
  36. package/dist/tools/agreements.js +328 -0
  37. package/dist/tools/agreements.js.map +1 -0
  38. package/dist/tools/analytics.d.ts +20 -0
  39. package/dist/tools/analytics.d.ts.map +1 -0
  40. package/dist/tools/analytics.js +126 -0
  41. package/dist/tools/analytics.js.map +1 -0
  42. package/dist/tools/assets.d.ts +23 -0
  43. package/dist/tools/assets.d.ts.map +1 -0
  44. package/dist/tools/assets.js +220 -0
  45. package/dist/tools/assets.js.map +1 -0
  46. package/dist/tools/audio-files.d.ts +21 -0
  47. package/dist/tools/audio-files.d.ts.map +1 -0
  48. package/dist/tools/audio-files.js +358 -0
  49. package/dist/tools/audio-files.js.map +1 -0
  50. package/dist/tools/bulk.d.ts +16 -0
  51. package/dist/tools/bulk.d.ts.map +1 -0
  52. package/dist/tools/bulk.js +82 -0
  53. package/dist/tools/bulk.js.map +1 -0
  54. package/dist/tools/calendar.d.ts +15 -0
  55. package/dist/tools/calendar.d.ts.map +1 -0
  56. package/dist/tools/calendar.js +69 -0
  57. package/dist/tools/calendar.js.map +1 -0
  58. package/dist/tools/collaborators.d.ts +17 -0
  59. package/dist/tools/collaborators.d.ts.map +1 -0
  60. package/dist/tools/collaborators.js +133 -0
  61. package/dist/tools/collaborators.js.map +1 -0
  62. package/dist/tools/comparisons.d.ts +22 -0
  63. package/dist/tools/comparisons.d.ts.map +1 -0
  64. package/dist/tools/comparisons.js +86 -0
  65. package/dist/tools/comparisons.js.map +1 -0
  66. package/dist/tools/credits.d.ts +17 -0
  67. package/dist/tools/credits.d.ts.map +1 -0
  68. package/dist/tools/credits.js +136 -0
  69. package/dist/tools/credits.js.map +1 -0
  70. package/dist/tools/dashboard.d.ts +20 -0
  71. package/dist/tools/dashboard.d.ts.map +1 -0
  72. package/dist/tools/dashboard.js +156 -0
  73. package/dist/tools/dashboard.js.map +1 -0
  74. package/dist/tools/directory.d.ts +15 -0
  75. package/dist/tools/directory.d.ts.map +1 -0
  76. package/dist/tools/directory.js +108 -0
  77. package/dist/tools/directory.js.map +1 -0
  78. package/dist/tools/disputes.d.ts +18 -0
  79. package/dist/tools/disputes.d.ts.map +1 -0
  80. package/dist/tools/disputes.js +66 -0
  81. package/dist/tools/disputes.js.map +1 -0
  82. package/dist/tools/documents.d.ts +15 -0
  83. package/dist/tools/documents.d.ts.map +1 -0
  84. package/dist/tools/documents.js +38 -0
  85. package/dist/tools/documents.js.map +1 -0
  86. package/dist/tools/duplicates.d.ts +16 -0
  87. package/dist/tools/duplicates.d.ts.map +1 -0
  88. package/dist/tools/duplicates.js +72 -0
  89. package/dist/tools/duplicates.js.map +1 -0
  90. package/dist/tools/enrichment.d.ts +23 -0
  91. package/dist/tools/enrichment.d.ts.map +1 -0
  92. package/dist/tools/enrichment.js +207 -0
  93. package/dist/tools/enrichment.js.map +1 -0
  94. package/dist/tools/exports.d.ts +19 -0
  95. package/dist/tools/exports.d.ts.map +1 -0
  96. package/dist/tools/exports.js +155 -0
  97. package/dist/tools/exports.js.map +1 -0
  98. package/dist/tools/health.d.ts +17 -0
  99. package/dist/tools/health.d.ts.map +1 -0
  100. package/dist/tools/health.js +69 -0
  101. package/dist/tools/health.js.map +1 -0
  102. package/dist/tools/import-documents.d.ts +21 -0
  103. package/dist/tools/import-documents.d.ts.map +1 -0
  104. package/dist/tools/import-documents.js +191 -0
  105. package/dist/tools/import-documents.js.map +1 -0
  106. package/dist/tools/import.d.ts +29 -0
  107. package/dist/tools/import.d.ts.map +1 -0
  108. package/dist/tools/import.js +404 -0
  109. package/dist/tools/import.js.map +1 -0
  110. package/dist/tools/index.d.ts +48 -0
  111. package/dist/tools/index.d.ts.map +1 -0
  112. package/dist/tools/index.js +394 -0
  113. package/dist/tools/index.js.map +1 -0
  114. package/dist/tools/integrations.d.ts +15 -0
  115. package/dist/tools/integrations.d.ts.map +1 -0
  116. package/dist/tools/integrations.js +102 -0
  117. package/dist/tools/integrations.js.map +1 -0
  118. package/dist/tools/licensing.d.ts +40 -0
  119. package/dist/tools/licensing.d.ts.map +1 -0
  120. package/dist/tools/licensing.js +436 -0
  121. package/dist/tools/licensing.js.map +1 -0
  122. package/dist/tools/memory.d.ts +21 -0
  123. package/dist/tools/memory.d.ts.map +1 -0
  124. package/dist/tools/memory.js +121 -0
  125. package/dist/tools/memory.js.map +1 -0
  126. package/dist/tools/multimedia.d.ts +19 -0
  127. package/dist/tools/multimedia.d.ts.map +1 -0
  128. package/dist/tools/multimedia.js +293 -0
  129. package/dist/tools/multimedia.js.map +1 -0
  130. package/dist/tools/notes.d.ts +21 -0
  131. package/dist/tools/notes.d.ts.map +1 -0
  132. package/dist/tools/notes.js +126 -0
  133. package/dist/tools/notes.js.map +1 -0
  134. package/dist/tools/notifications.d.ts +17 -0
  135. package/dist/tools/notifications.d.ts.map +1 -0
  136. package/dist/tools/notifications.js +117 -0
  137. package/dist/tools/notifications.js.map +1 -0
  138. package/dist/tools/people.d.ts +53 -0
  139. package/dist/tools/people.d.ts.map +1 -0
  140. package/dist/tools/people.js +534 -0
  141. package/dist/tools/people.js.map +1 -0
  142. package/dist/tools/pica-score.d.ts +15 -0
  143. package/dist/tools/pica-score.d.ts.map +1 -0
  144. package/dist/tools/pica-score.js +30 -0
  145. package/dist/tools/pica-score.js.map +1 -0
  146. package/dist/tools/projects.d.ts +19 -0
  147. package/dist/tools/projects.d.ts.map +1 -0
  148. package/dist/tools/projects.js +142 -0
  149. package/dist/tools/projects.js.map +1 -0
  150. package/dist/tools/purchases.d.ts +15 -0
  151. package/dist/tools/purchases.d.ts.map +1 -0
  152. package/dist/tools/purchases.js +65 -0
  153. package/dist/tools/purchases.js.map +1 -0
  154. package/dist/tools/recordings.d.ts +41 -0
  155. package/dist/tools/recordings.d.ts.map +1 -0
  156. package/dist/tools/recordings.js +293 -0
  157. package/dist/tools/recordings.js.map +1 -0
  158. package/dist/tools/registration.d.ts +16 -0
  159. package/dist/tools/registration.d.ts.map +1 -0
  160. package/dist/tools/registration.js +52 -0
  161. package/dist/tools/registration.js.map +1 -0
  162. package/dist/tools/releases.d.ts +18 -0
  163. package/dist/tools/releases.d.ts.map +1 -0
  164. package/dist/tools/releases.js +138 -0
  165. package/dist/tools/releases.js.map +1 -0
  166. package/dist/tools/royalties.d.ts +23 -0
  167. package/dist/tools/royalties.d.ts.map +1 -0
  168. package/dist/tools/royalties.js +263 -0
  169. package/dist/tools/royalties.js.map +1 -0
  170. package/dist/tools/search.d.ts +30 -0
  171. package/dist/tools/search.d.ts.map +1 -0
  172. package/dist/tools/search.js +117 -0
  173. package/dist/tools/search.js.map +1 -0
  174. package/dist/tools/send.d.ts +18 -0
  175. package/dist/tools/send.d.ts.map +1 -0
  176. package/dist/tools/send.js +189 -0
  177. package/dist/tools/send.js.map +1 -0
  178. package/dist/tools/sessions.d.ts +18 -0
  179. package/dist/tools/sessions.d.ts.map +1 -0
  180. package/dist/tools/sessions.js +107 -0
  181. package/dist/tools/sessions.js.map +1 -0
  182. package/dist/tools/settings.d.ts +18 -0
  183. package/dist/tools/settings.d.ts.map +1 -0
  184. package/dist/tools/settings.js +98 -0
  185. package/dist/tools/settings.js.map +1 -0
  186. package/dist/tools/share-links.d.ts +19 -0
  187. package/dist/tools/share-links.d.ts.map +1 -0
  188. package/dist/tools/share-links.js +126 -0
  189. package/dist/tools/share-links.js.map +1 -0
  190. package/dist/tools/split-sheets.d.ts +24 -0
  191. package/dist/tools/split-sheets.d.ts.map +1 -0
  192. package/dist/tools/split-sheets.js +189 -0
  193. package/dist/tools/split-sheets.js.map +1 -0
  194. package/dist/tools/team.d.ts +22 -0
  195. package/dist/tools/team.d.ts.map +1 -0
  196. package/dist/tools/team.js +139 -0
  197. package/dist/tools/team.js.map +1 -0
  198. package/dist/tools/telegram.d.ts +20 -0
  199. package/dist/tools/telegram.d.ts.map +1 -0
  200. package/dist/tools/telegram.js +94 -0
  201. package/dist/tools/telegram.js.map +1 -0
  202. package/dist/tools/uploads.d.ts +17 -0
  203. package/dist/tools/uploads.d.ts.map +1 -0
  204. package/dist/tools/uploads.js +159 -0
  205. package/dist/tools/uploads.js.map +1 -0
  206. package/dist/tools/works.d.ts +53 -0
  207. package/dist/tools/works.d.ts.map +1 -0
  208. package/dist/tools/works.js +517 -0
  209. package/dist/tools/works.js.map +1 -0
  210. package/dist/utils/credit-gate.d.ts +17 -0
  211. package/dist/utils/credit-gate.d.ts.map +1 -0
  212. package/dist/utils/credit-gate.js +111 -0
  213. package/dist/utils/credit-gate.js.map +1 -0
  214. package/dist/utils/errors.d.ts +29 -0
  215. package/dist/utils/errors.d.ts.map +1 -0
  216. package/dist/utils/errors.js +114 -0
  217. package/dist/utils/errors.js.map +1 -0
  218. package/dist/utils/formatting.d.ts +63 -0
  219. package/dist/utils/formatting.d.ts.map +1 -0
  220. package/dist/utils/formatting.js +130 -0
  221. package/dist/utils/formatting.js.map +1 -0
  222. package/dist/utils/mpp.d.ts +78 -0
  223. package/dist/utils/mpp.d.ts.map +1 -0
  224. package/dist/utils/mpp.js +136 -0
  225. package/dist/utils/mpp.js.map +1 -0
  226. package/package.json +44 -0
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Resource Registry for MCP Server
3
+ * Manages read-only data resources that AI assistants can access
4
+ */
5
+ import { ResourceError } from "../utils/errors.js";
6
+ import { readFileSync } from "fs";
7
+ import { join } from "path";
8
+ import { WITHPICA_PRIMER } from "./llms-primer.js";
9
+ export class ResourceRegistry {
10
+ pica;
11
+ constructor(pica) {
12
+ this.pica = pica;
13
+ }
14
+ /**
15
+ * List all available resources
16
+ */
17
+ listResources() {
18
+ return [
19
+ {
20
+ uri: "llms://primer",
21
+ name: "PICA Domain Primer",
22
+ description: "Plain-language description of PICA's domain model, entity relationships, and recommended agent workflows. Read this first.",
23
+ mimeType: "text/markdown",
24
+ },
25
+ {
26
+ uri: "works://list",
27
+ name: "All Works",
28
+ description: "Complete list of musical works in the catalog",
29
+ mimeType: "application/json",
30
+ },
31
+ {
32
+ uri: "people://list",
33
+ name: "All People",
34
+ description: "Complete list of people (artists, composers, etc.)",
35
+ mimeType: "application/json",
36
+ },
37
+ {
38
+ uri: "recordings://list",
39
+ name: "All Recordings",
40
+ description: "Complete list of recordings",
41
+ mimeType: "application/json",
42
+ },
43
+ {
44
+ uri: "catalog://stats",
45
+ name: "Catalog Statistics",
46
+ description: "Statistics and metrics about the catalog",
47
+ mimeType: "application/json",
48
+ },
49
+ {
50
+ uri: "catalog://health",
51
+ name: "Catalog Health (PICA Score)",
52
+ description: "PICA Score — composite legibility index (0-100) with grade, 4-pillar breakdown, and actionable suggestions",
53
+ mimeType: "application/json",
54
+ },
55
+ {
56
+ uri: "workspace://context",
57
+ name: "Workspace Context",
58
+ description: "Aggregated workspace orientation — org info, catalog stats, health score, and top priorities in one call",
59
+ mimeType: "application/json",
60
+ },
61
+ {
62
+ uri: "events://recent",
63
+ name: "Recent Events",
64
+ description: "Recent webhook delivery events — what happened in this workspace recently",
65
+ mimeType: "application/json",
66
+ },
67
+ {
68
+ uri: "api://openapi",
69
+ name: "OpenAPI Specification",
70
+ description: "OpenAPI 3.1 spec for the top 20 PICA API endpoints — works, people, recordings, agreements, credits, search, health",
71
+ mimeType: "text/yaml",
72
+ },
73
+ ];
74
+ }
75
+ /**
76
+ * Read a resource by URI
77
+ */
78
+ async readResource(uri) {
79
+ switch (uri) {
80
+ case "llms://primer":
81
+ return {
82
+ contents: [
83
+ {
84
+ uri: "llms://primer",
85
+ mimeType: "text/markdown",
86
+ text: WITHPICA_PRIMER,
87
+ },
88
+ ],
89
+ };
90
+ case "works://list":
91
+ return await this.getWorksList();
92
+ case "people://list":
93
+ return await this.getPeopleList();
94
+ case "recordings://list":
95
+ return await this.getRecordingsList();
96
+ case "catalog://stats":
97
+ return await this.getCatalogStats();
98
+ case "catalog://health":
99
+ return await this.getCatalogHealth();
100
+ case "workspace://context":
101
+ return await this.getWorkspaceContext();
102
+ case "events://recent":
103
+ return await this.getRecentEvents();
104
+ case "api://openapi":
105
+ return this.getOpenAPISpec();
106
+ default:
107
+ throw new ResourceError(`Resource not found: ${uri}`);
108
+ }
109
+ }
110
+ /**
111
+ * Get OpenAPI specification resource
112
+ */
113
+ getOpenAPISpec() {
114
+ // Try multiple paths to find the spec file
115
+ const possiblePaths = [
116
+ join(process.cwd(), "docs/api/openapi.yaml"),
117
+ join(process.cwd(), "../docs/api/openapi.yaml"),
118
+ ];
119
+ for (const specPath of possiblePaths) {
120
+ try {
121
+ const yamlContent = readFileSync(specPath, "utf-8");
122
+ return {
123
+ contents: [
124
+ {
125
+ uri: "api://openapi",
126
+ mimeType: "text/yaml",
127
+ text: yamlContent,
128
+ },
129
+ ],
130
+ };
131
+ }
132
+ catch {
133
+ // Try next path
134
+ }
135
+ }
136
+ throw new ResourceError("OpenAPI spec not found. Expected at docs/api/openapi.yaml");
137
+ }
138
+ /**
139
+ * Get works list resource
140
+ */
141
+ async getWorksList() {
142
+ const works = await this.pica.works.list({ limit: 1000 });
143
+ return {
144
+ contents: [
145
+ {
146
+ uri: "works://list",
147
+ mimeType: "application/json",
148
+ text: JSON.stringify({
149
+ total: works.length,
150
+ works: works.map((work) => ({
151
+ id: work.id,
152
+ title: work.title,
153
+ work_type: work.work_type,
154
+ iswc: work.iswc,
155
+ is_verified: work.is_verified,
156
+ duration_seconds: work.duration_seconds,
157
+ })),
158
+ }, null, 2),
159
+ },
160
+ ],
161
+ };
162
+ }
163
+ /**
164
+ * Get people list resource
165
+ */
166
+ async getPeopleList() {
167
+ const people = await this.pica.people.list({ limit: 1000 });
168
+ return {
169
+ contents: [
170
+ {
171
+ uri: "people://list",
172
+ mimeType: "application/json",
173
+ text: JSON.stringify({
174
+ total: people.length,
175
+ people: people.map((person) => ({
176
+ id: person.id,
177
+ first_name: person.first_name,
178
+ last_name: person.last_name,
179
+ email: person.email,
180
+ isni: person.isni,
181
+ musicbrainz_id: person.musicbrainz_id,
182
+ })),
183
+ }, null, 2),
184
+ },
185
+ ],
186
+ };
187
+ }
188
+ /**
189
+ * Get recordings list resource
190
+ */
191
+ async getRecordingsList() {
192
+ const recordings = await this.pica.recordings.list({ limit: 1000 });
193
+ return {
194
+ contents: [
195
+ {
196
+ uri: "recordings://list",
197
+ mimeType: "application/json",
198
+ text: JSON.stringify({
199
+ total: recordings.length,
200
+ recordings: recordings.map((recording) => ({
201
+ id: recording.id,
202
+ title: recording.title,
203
+ isrc: recording.isrc,
204
+ duration_seconds: recording.duration_seconds,
205
+ work_id: recording.work_id,
206
+ })),
207
+ }, null, 2),
208
+ },
209
+ ],
210
+ };
211
+ }
212
+ /**
213
+ * Get catalog statistics resource
214
+ */
215
+ async getCatalogStats() {
216
+ const [works, people, recordings] = await Promise.all([
217
+ this.pica.works.list({ limit: 1000 }),
218
+ this.pica.people.list({ limit: 1000 }),
219
+ this.pica.recordings.list({ limit: 1000 }),
220
+ ]);
221
+ const stats = {
222
+ overview: {
223
+ total_works: works.length,
224
+ total_people: people.length,
225
+ total_recordings: recordings.length,
226
+ last_updated: new Date().toISOString(),
227
+ },
228
+ works: {
229
+ total: works.length,
230
+ verified: works.filter((w) => w.is_verified).length,
231
+ unverified: works.filter((w) => !w.is_verified).length,
232
+ with_iswc: works.filter((w) => w.iswc).length,
233
+ by_type: {
234
+ composition: works.filter((w) => w.work_type === "composition")
235
+ .length,
236
+ arrangement: works.filter((w) => w.work_type === "arrangement")
237
+ .length,
238
+ adaptation: works.filter((w) => w.work_type === "adaptation").length,
239
+ translation: works.filter((w) => w.work_type === "translation")
240
+ .length,
241
+ },
242
+ },
243
+ people: {
244
+ total: people.length,
245
+ with_email: people.filter((p) => p.email).length,
246
+ with_isni: people.filter((p) => p.isni).length,
247
+ with_musicbrainz: people.filter((p) => p.musicbrainz_id).length,
248
+ },
249
+ recordings: {
250
+ total: recordings.length,
251
+ with_isrc: recordings.filter((r) => r.isrc).length,
252
+ },
253
+ };
254
+ return {
255
+ contents: [
256
+ {
257
+ uri: "catalog://stats",
258
+ mimeType: "application/json",
259
+ text: JSON.stringify(stats, null, 2),
260
+ },
261
+ ],
262
+ };
263
+ }
264
+ /**
265
+ * Get catalog health (PICA Score) resource
266
+ */
267
+ async getCatalogHealth() {
268
+ const score = await this.pica.picaScore.get();
269
+ return {
270
+ contents: [
271
+ {
272
+ uri: "catalog://health",
273
+ mimeType: "application/json",
274
+ text: JSON.stringify(score, null, 2),
275
+ },
276
+ ],
277
+ };
278
+ }
279
+ /**
280
+ * Get workspace context resource — aggregated orientation for agents
281
+ */
282
+ async getWorkspaceContext() {
283
+ const context = await this.pica.workspace.getContext();
284
+ return {
285
+ contents: [
286
+ {
287
+ uri: "workspace://context",
288
+ mimeType: "application/json",
289
+ text: JSON.stringify(context, null, 2),
290
+ },
291
+ ],
292
+ };
293
+ }
294
+ /**
295
+ * Get recent events resource — webhook deliveries
296
+ */
297
+ async getRecentEvents() {
298
+ const events = await this.pica.workspace.getRecentEvents(20);
299
+ return {
300
+ contents: [
301
+ {
302
+ uri: "events://recent",
303
+ mimeType: "application/json",
304
+ text: JSON.stringify(events, null, 2),
305
+ },
306
+ ],
307
+ };
308
+ }
309
+ }
310
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAW,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAmBnD,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAa;IAEzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO;YACL;gBACE,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,oBAAoB;gBAC1B,WAAW,EACT,4HAA4H;gBAC9H,QAAQ,EAAE,eAAe;aAC1B;YACD;gBACE,GAAG,EAAE,cAAc;gBACnB,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,+CAA+C;gBAC5D,QAAQ,EAAE,kBAAkB;aAC7B;YACD;gBACE,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,oDAAoD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AC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,eAAe;QAC3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAE7D,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,iBAAiB;oBACtB,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACtC;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare const WITHPICA_PRIMER = "# PICA \u2014 Music Catalog Management Platform\n\nPICA helps music creators and publishers manage their catalog metadata,\ntrack royalties, and prepare works for registration with collection societies.\n\n## Core Entities\n\n### Work\nA musical composition (song, piece, library track). The central entity.\n- Has: title, ISWC, work_type (song/library/demo), genre, mood, BPM, key\n- Relationships: has many credits (writers/composers), has many recordings,\n has many agreements, may have audio files, may have multimedia\n- Identifiers: ISWC (global), Tunecode (PRS), CAE/IPI (writer)\n\n### Person\nA human involved in music \u2014 writer, composer, performer, producer, publisher.\n- Has: name, email, IPI number, ISNI, MusicBrainz ID, PRO affiliation\n- Relationships: credited on many works, may have recordings, may have agreements\n- Can be enriched via: ISNI, MusicBrainz, Wikidata\n\n### Recording\nA specific audio capture of a work \u2014 the master/sound recording side.\n- Has: title, ISRC, duration, artist, label\n- Relationships: belongs to one work, has credits (performers/producers)\n- Distinct from the work: a work is the composition, a recording is the performance\n\n### Agreement\nA contract governing rights to works \u2014 publishing, sync, distribution.\n- Has: title, type, parties, dates, territory, terms\n- Relationships: covers many works\n- Types: publishing_admin, co_publishing, master_recording, sub_publishing,\n admin_only, distribution, library_music, production, artist_contract,\n termination, report, other\n\n### Import Document\nA canonical representation of an ingested file (royalty statement, CSV import).\n- Has: source (16 formats \u2014 PROs: PRS, ASCAP, BMI, SESAC, SOCAN, APRA, GEMA, SACEM; NROs: PPL, SoundExchange, GVL; Mechanical: MCPS; Distributors: DistroKid, TuneCore, CD Baby; Revenue: YouTube Content ID), period, line items, field mappings, warnings\n- Immutable snapshot of the import event \u2014 not a live view\n- Use pica_import_documents_list to find them, pica_import_documents_get to read\n\n## First Connection\n\nIf you're connecting to this workspace for the first time or don't know where to start,\ninvoke the **workspace-autopilot** prompt. It reads the workspace state and routes you\nto the most valuable workflow automatically.\n\n## Recommended Workflows\n\n1. **Catalog audit**: pica_catalog_stats \u2192 pica_works_health \u2192 pica_completeness_low\n2. **Enrichment**: pica_enrichment_candidates \u2192 pica_enrich_work/person \u2192 verify\n3. **Statement reconciliation**: pica_import_documents_list \u2192 pica_import_documents_diff\n4. **Duplicate cleanup**: pica_find_duplicates \u2192 review \u2192 pica_merge_duplicates\n5. **Registration readiness**: pica_registration_coverage \u2192 fix gaps \u2192 pica_export_song_registration\n\n## Key Concepts\n\n- **Organisation**: Multi-tenant \u2014 all data scoped to one org. Never cross org boundaries.\n- **PICA Score**: Composite catalog legibility index (0-100, grade A-F). Four pillars:\n identification, documentation, registration, completeness.\n- **Enrichment cascade**: When an identifier is added, external sources\n (MusicBrainz, ISNI, MLC) are queried automatically to fill gaps.\n- **Credits**: Work credits (writers/composers with splits) are distinct from\n recording credits (performers/producers). Different tables, different role enums.\n Work credit roles: writer, composer, arranger, lyricist, producer, performer.\n Recording credit roles: Writer, Composer, Producer, Performer (PascalCase).\n";
2
+ //# sourceMappingURL=llms-primer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llms-primer.d.ts","sourceRoot":"","sources":["../../src/resources/llms-primer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,8+GAiE3B,CAAC"}
@@ -0,0 +1,67 @@
1
+ export const WITHPICA_PRIMER = `# PICA — Music Catalog Management Platform
2
+
3
+ PICA helps music creators and publishers manage their catalog metadata,
4
+ track royalties, and prepare works for registration with collection societies.
5
+
6
+ ## Core Entities
7
+
8
+ ### Work
9
+ A musical composition (song, piece, library track). The central entity.
10
+ - Has: title, ISWC, work_type (song/library/demo), genre, mood, BPM, key
11
+ - Relationships: has many credits (writers/composers), has many recordings,
12
+ has many agreements, may have audio files, may have multimedia
13
+ - Identifiers: ISWC (global), Tunecode (PRS), CAE/IPI (writer)
14
+
15
+ ### Person
16
+ A human involved in music — writer, composer, performer, producer, publisher.
17
+ - Has: name, email, IPI number, ISNI, MusicBrainz ID, PRO affiliation
18
+ - Relationships: credited on many works, may have recordings, may have agreements
19
+ - Can be enriched via: ISNI, MusicBrainz, Wikidata
20
+
21
+ ### Recording
22
+ A specific audio capture of a work — the master/sound recording side.
23
+ - Has: title, ISRC, duration, artist, label
24
+ - Relationships: belongs to one work, has credits (performers/producers)
25
+ - Distinct from the work: a work is the composition, a recording is the performance
26
+
27
+ ### Agreement
28
+ A contract governing rights to works — publishing, sync, distribution.
29
+ - Has: title, type, parties, dates, territory, terms
30
+ - Relationships: covers many works
31
+ - Types: publishing_admin, co_publishing, master_recording, sub_publishing,
32
+ admin_only, distribution, library_music, production, artist_contract,
33
+ termination, report, other
34
+
35
+ ### Import Document
36
+ A canonical representation of an ingested file (royalty statement, CSV import).
37
+ - Has: source (16 formats — PROs: PRS, ASCAP, BMI, SESAC, SOCAN, APRA, GEMA, SACEM; NROs: PPL, SoundExchange, GVL; Mechanical: MCPS; Distributors: DistroKid, TuneCore, CD Baby; Revenue: YouTube Content ID), period, line items, field mappings, warnings
38
+ - Immutable snapshot of the import event — not a live view
39
+ - Use pica_import_documents_list to find them, pica_import_documents_get to read
40
+
41
+ ## First Connection
42
+
43
+ If you're connecting to this workspace for the first time or don't know where to start,
44
+ invoke the **workspace-autopilot** prompt. It reads the workspace state and routes you
45
+ to the most valuable workflow automatically.
46
+
47
+ ## Recommended Workflows
48
+
49
+ 1. **Catalog audit**: pica_catalog_stats → pica_works_health → pica_completeness_low
50
+ 2. **Enrichment**: pica_enrichment_candidates → pica_enrich_work/person → verify
51
+ 3. **Statement reconciliation**: pica_import_documents_list → pica_import_documents_diff
52
+ 4. **Duplicate cleanup**: pica_find_duplicates → review → pica_merge_duplicates
53
+ 5. **Registration readiness**: pica_registration_coverage → fix gaps → pica_export_song_registration
54
+
55
+ ## Key Concepts
56
+
57
+ - **Organisation**: Multi-tenant — all data scoped to one org. Never cross org boundaries.
58
+ - **PICA Score**: Composite catalog legibility index (0-100, grade A-F). Four pillars:
59
+ identification, documentation, registration, completeness.
60
+ - **Enrichment cascade**: When an identifier is added, external sources
61
+ (MusicBrainz, ISNI, MLC) are queried automatically to fill gaps.
62
+ - **Credits**: Work credits (writers/composers with splits) are distinct from
63
+ recording credits (performers/producers). Different tables, different role enums.
64
+ Work credit roles: writer, composer, arranger, lyricist, producer, performer.
65
+ Recording credit roles: Writer, Composer, Producer, Performer (PascalCase).
66
+ `;
67
+ //# sourceMappingURL=llms-primer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llms-primer.js","sourceRoot":"","sources":["../../src/resources/llms-primer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE9B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * MCP Server for PICA Platform
3
+ * Enables AI assistants to interact with PICA via the Model Context Protocol
4
+ */
5
+ import { ServerConfig } from "./config.js";
6
+ export declare class PicaMcpServer {
7
+ private server;
8
+ private pica;
9
+ private toolRegistry;
10
+ private resourceRegistry;
11
+ private promptRegistry;
12
+ private config;
13
+ constructor(config: ServerConfig);
14
+ /**
15
+ * Set up MCP protocol handlers
16
+ */
17
+ private setupHandlers;
18
+ /**
19
+ * Start the MCP server
20
+ */
21
+ start(): Promise<void>;
22
+ /**
23
+ * Stop the MCP server
24
+ */
25
+ stop(): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,YAAY;IAiChC;;OAEG;IACH,OAAO,CAAC,aAAa;IAsFrB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
package/dist/server.js ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * MCP Server for PICA Platform
3
+ * Enables AI assistants to interact with PICA via the Model Context Protocol
4
+ */
5
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
8
+ import { PicaClient } from "./pica-sdk.js";
9
+ import { ToolRegistry } from "./tools/index.js";
10
+ import { ResourceRegistry } from "./resources/index.js";
11
+ import { PromptRegistry } from "./prompts/index.js";
12
+ import { logError } from "./utils/errors.js";
13
+ export class PicaMcpServer {
14
+ server;
15
+ pica;
16
+ toolRegistry;
17
+ resourceRegistry;
18
+ promptRegistry;
19
+ config;
20
+ constructor(config) {
21
+ this.config = config;
22
+ // Initialize PICA SDK client
23
+ this.pica = new PicaClient({
24
+ apiKey: config.picaApiKey,
25
+ baseUrl: config.picaApiUrl,
26
+ debug: config.debug,
27
+ });
28
+ // Initialize MCP server
29
+ this.server = new Server({
30
+ name: config.serverName,
31
+ version: config.version,
32
+ }, {
33
+ capabilities: {
34
+ tools: {},
35
+ resources: {},
36
+ prompts: {},
37
+ },
38
+ });
39
+ // Initialize registries
40
+ this.toolRegistry = new ToolRegistry(this.pica);
41
+ this.resourceRegistry = new ResourceRegistry(this.pica);
42
+ this.promptRegistry = new PromptRegistry();
43
+ this.setupHandlers();
44
+ }
45
+ /**
46
+ * Set up MCP protocol handlers
47
+ */
48
+ setupHandlers() {
49
+ // List available tools
50
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => {
51
+ if (this.config.debug) {
52
+ console.log("[MCP Server] Listing tools");
53
+ }
54
+ return {
55
+ tools: this.toolRegistry.listTools(),
56
+ };
57
+ });
58
+ // Execute tool
59
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
60
+ const { name, arguments: args, _meta } = request.params;
61
+ if (this.config.debug) {
62
+ console.log(`[MCP Server] Executing tool: ${name}`, args);
63
+ }
64
+ // Thread _meta into args for MPP credential passing (credit-gate reads it)
65
+ const toolArgs = _meta ? { ...(args || {}), _meta } : args || {};
66
+ try {
67
+ return await this.toolRegistry.executeTool(name, toolArgs);
68
+ }
69
+ catch (error) {
70
+ logError(`Tool execution: ${name}`, error);
71
+ throw error;
72
+ }
73
+ });
74
+ // List available resources
75
+ this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
76
+ if (this.config.debug) {
77
+ console.log("[MCP Server] Listing resources");
78
+ }
79
+ return {
80
+ resources: this.resourceRegistry.listResources(),
81
+ };
82
+ });
83
+ // Read resource
84
+ this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
85
+ const { uri } = request.params;
86
+ if (this.config.debug) {
87
+ console.log(`[MCP Server] Reading resource: ${uri}`);
88
+ }
89
+ try {
90
+ return await this.resourceRegistry.readResource(uri);
91
+ }
92
+ catch (error) {
93
+ logError(`Resource read: ${uri}`, error);
94
+ throw error;
95
+ }
96
+ });
97
+ // List available prompts
98
+ this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
99
+ if (this.config.debug) {
100
+ console.log("[MCP Server] Listing prompts");
101
+ }
102
+ return {
103
+ prompts: this.promptRegistry.listPrompts(),
104
+ };
105
+ });
106
+ // Get prompt
107
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
108
+ const { name, arguments: args } = request.params;
109
+ if (this.config.debug) {
110
+ console.log(`[MCP Server] Getting prompt: ${name}`, args);
111
+ }
112
+ try {
113
+ return await this.promptRegistry.getPrompt(name, args);
114
+ }
115
+ catch (error) {
116
+ logError(`Prompt get: ${name}`, error);
117
+ throw error;
118
+ }
119
+ });
120
+ }
121
+ /**
122
+ * Start the MCP server
123
+ */
124
+ async start() {
125
+ const transport = new StdioServerTransport();
126
+ await this.server.connect(transport);
127
+ console.error("[MCP Server] PICA MCP Server started");
128
+ console.error(`[MCP Server] Version: ${this.config.version}`);
129
+ console.error(`[MCP Server] API URL: ${this.config.picaApiUrl}`);
130
+ console.error("[MCP Server] Ready to accept connections");
131
+ }
132
+ /**
133
+ * Stop the MCP server
134
+ */
135
+ async stop() {
136
+ await this.server.close();
137
+ console.error("[MCP Server] Server stopped");
138
+ }
139
+ }
140
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,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I,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,QAAQ,CAAC,eAAe,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;gBACvC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAErC,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Agreement Types Tools — templates, producer agreements, and work-for-hire
3
+ *
4
+ * Groups three related agreement sub-types that extend the core agreements system:
5
+ * - Templates: reusable agreement blueprints that can be rendered with real data
6
+ * - Producer agreements: advance + points deals with recoupment tracking
7
+ * - Work-for-hire: flat-fee contracts where all rights are assigned
8
+ */
9
+ import { PicaClient } from "../pica-sdk.js";
10
+ import { ToolDefinition, ToolExecutor } from "./index.js";
11
+ export declare class AgreementTypesTools {
12
+ private pica;
13
+ constructor(pica: PicaClient);
14
+ getTools(): Array<{
15
+ definition: ToolDefinition;
16
+ executor: ToolExecutor;
17
+ }>;
18
+ private listTemplates;
19
+ private getTemplate;
20
+ private createTemplate;
21
+ private updateTemplate;
22
+ private deleteTemplate;
23
+ private renderTemplate;
24
+ private duplicateTemplate;
25
+ private setDefaultTemplate;
26
+ private listProducerAgreements;
27
+ private getProducerAgreement;
28
+ private createProducerAgreement;
29
+ private updateProducerAgreement;
30
+ private deleteProducerAgreement;
31
+ private listWorkForHire;
32
+ private getWorkForHire;
33
+ private createWorkForHire;
34
+ private updateWorkForHire;
35
+ private deleteWorkForHire;
36
+ }
37
+ //# sourceMappingURL=agreement-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agreement-types.d.ts","sourceRoot":"","sources":["../../src/tools/agreement-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAOtE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,IAAI,CAAa;gBAEb,IAAI,EAAE,UAAU;IAI5B,QAAQ,IAAI,KAAK,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAA;KAAE,CAAC;YAigB3D,aAAa;YAKb,WAAW;YAKX,cAAc;YAKd,cAAc;YAMd,cAAc;YAKd,cAAc;YAMd,iBAAiB;YAOjB,kBAAkB;YASlB,sBAAsB;YAKtB,oBAAoB;YAOpB,uBAAuB;YAOvB,uBAAuB;YAQvB,uBAAuB;YASvB,eAAe;YAKf,cAAc;YAKd,iBAAiB;YAOjB,iBAAiB;YAQjB,iBAAiB;CAMhC"}