@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,191 @@
1
+ /**
2
+ * Import Documents Tools - MCP tools for canonical ingestion documents
3
+ */
4
+ import { formatStructuredList, formatSuccess } from "../utils/formatting.js";
5
+ export class ImportDocumentTools {
6
+ pica;
7
+ constructor(pica) {
8
+ this.pica = pica;
9
+ }
10
+ /**
11
+ * Get all import document tools
12
+ */
13
+ getTools() {
14
+ return [
15
+ {
16
+ definition: {
17
+ name: "pica_import_documents_list",
18
+ description: "List canonical ingestion documents — the readable, diffable record of every statement import. Filter by source (prs, distrokid, ascap, etc.), period (Q1 2024), or document type (statement, csv_import). Returns summaries without full body text. Use pica_import_documents_get for the full document.",
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ source: {
23
+ type: "string",
24
+ description: "Filter by source identifier. PROs: prs, ascap, bmi, sesac, socan, apra, gema, sacem. NROs: ppl, soundexchange, gvl. Mechanical: mcps. Distributors: distrokid, tunecore, cdbaby. Revenue: content_id.",
25
+ },
26
+ period: {
27
+ type: "string",
28
+ description: "Filter by period label (e.g. Q1 2024, 2024-01)",
29
+ },
30
+ document_type: {
31
+ type: "string",
32
+ description: "Filter by document type (e.g. statement, csv_import)",
33
+ },
34
+ limit: {
35
+ type: "number",
36
+ description: "Maximum number of results to return (default: 50)",
37
+ },
38
+ },
39
+ },
40
+ },
41
+ executor: this.listImportDocuments.bind(this),
42
+ },
43
+ {
44
+ definition: {
45
+ name: "pica_import_documents_get",
46
+ description: "Get the full canonical document for a specific import — includes the complete markdown body with summary, identity extractions, line items table, field mapping decisions, and warnings. This is the human-readable, agent-readable record of exactly what was ingested and how it was interpreted.",
47
+ inputSchema: {
48
+ type: "object",
49
+ properties: {
50
+ id: {
51
+ type: "string",
52
+ description: "Import document ID",
53
+ },
54
+ },
55
+ required: ["id"],
56
+ },
57
+ },
58
+ executor: this.getImportDocument.bind(this),
59
+ },
60
+ {
61
+ definition: {
62
+ name: "pica_import_documents_diff",
63
+ description: "Compare two canonical import documents — typically the same source across different periods (e.g. PRS Q1 2024 vs PRS Q2 2024). Returns a structured diff showing: new works, removed works, amount changes, new writers, and summary deltas.",
64
+ inputSchema: {
65
+ type: "object",
66
+ properties: {
67
+ document_id_a: {
68
+ type: "string",
69
+ description: "ID of the first (earlier) import document",
70
+ },
71
+ document_id_b: {
72
+ type: "string",
73
+ description: "ID of the second (later) import document",
74
+ },
75
+ },
76
+ required: ["document_id_a", "document_id_b"],
77
+ },
78
+ },
79
+ executor: this.diffImportDocuments.bind(this),
80
+ },
81
+ {
82
+ definition: {
83
+ name: "pica_ingest_statement",
84
+ description: "Ingest a royalty or distribution statement into PICA. Before calling this tool, convert the raw file contents to canonical Markdown with YAML frontmatter containing: source, period, currency, type. Line items should be structured as a Markdown table. The LLM should perform this conversion from CSV or PDF text before passing to this tool.",
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {
88
+ markdown: {
89
+ type: "string",
90
+ description: "The statement converted to canonical PICA Markdown format with YAML frontmatter and structured body",
91
+ },
92
+ },
93
+ required: ["markdown"],
94
+ },
95
+ },
96
+ executor: this.ingestStatement.bind(this),
97
+ },
98
+ ];
99
+ }
100
+ async listImportDocuments(args) {
101
+ const docs = await this.pica.importDocuments.list(args);
102
+ return formatStructuredList(docs, "import document");
103
+ }
104
+ async getImportDocument(args) {
105
+ if (!args.id) {
106
+ return {
107
+ content: [{ type: "text", text: "id is required" }],
108
+ isError: true,
109
+ };
110
+ }
111
+ const doc = await this.pica.importDocuments.get(args.id);
112
+ return {
113
+ content: [
114
+ { type: "text", text: doc.body ?? JSON.stringify(doc, null, 2) },
115
+ ],
116
+ structuredContent: doc,
117
+ };
118
+ }
119
+ async ingestStatement(args) {
120
+ if (!args.markdown) {
121
+ return {
122
+ content: [{ type: "text", text: "markdown is required" }],
123
+ isError: true,
124
+ };
125
+ }
126
+ const result = await this.pica.importDocuments.ingest(args.markdown);
127
+ return formatSuccess(`Statement ingested successfully. Document ID: ${result.id}`, result);
128
+ }
129
+ async diffImportDocuments(args) {
130
+ if (!args.document_id_a || !args.document_id_b) {
131
+ return {
132
+ content: [
133
+ {
134
+ type: "text",
135
+ text: "document_id_a and document_id_b are required",
136
+ },
137
+ ],
138
+ isError: true,
139
+ };
140
+ }
141
+ const [docA, docB] = await Promise.all([
142
+ this.pica.importDocuments.get(args.document_id_a),
143
+ this.pica.importDocuments.get(args.document_id_b),
144
+ ]);
145
+ const summaryA = docA.summary ?? {};
146
+ const summaryB = docB.summary ?? {};
147
+ const lineItemsDelta = (summaryB.line_count ?? 0) - (summaryA.line_count ?? 0);
148
+ const totalConvertedDelta = (summaryB.total_converted ?? 0) - (summaryA.total_converted ?? 0);
149
+ const matchedWorksDelta = (summaryB.matched_works ?? 0) - (summaryA.matched_works ?? 0);
150
+ const warningsDelta = (summaryB.warning_count ?? 0) - (summaryA.warning_count ?? 0);
151
+ const sign = (n) => (n > 0 ? `+${n}` : String(n));
152
+ const signF = (n) => (n > 0 ? `+${n.toFixed(2)}` : n.toFixed(2));
153
+ const table = [
154
+ `## import document diff`,
155
+ ``,
156
+ `| metric | document a | document b | delta |`,
157
+ `| --- | --- | --- | --- |`,
158
+ `| source | ${docA.source ?? "—"} | ${docB.source ?? "—"} | — |`,
159
+ `| period | ${docA.period ?? "—"} | ${docB.period ?? "—"} | — |`,
160
+ `| line items | ${summaryA.line_count ?? "—"} | ${summaryB.line_count ?? "—"} | ${sign(lineItemsDelta)} |`,
161
+ `| total converted | ${summaryA.total_converted ?? "—"} | ${summaryB.total_converted ?? "—"} | ${signF(totalConvertedDelta)} |`,
162
+ `| matched works | ${summaryA.matched_works ?? "—"} | ${summaryB.matched_works ?? "—"} | ${sign(matchedWorksDelta)} |`,
163
+ `| warnings | ${summaryA.warning_count ?? "—"} | ${summaryB.warning_count ?? "—"} | ${sign(warningsDelta)} |`,
164
+ ].join("\n");
165
+ const deltas = {
166
+ document_a: {
167
+ id: args.document_id_a,
168
+ source: docA.source,
169
+ period: docA.period,
170
+ summary: summaryA,
171
+ },
172
+ document_b: {
173
+ id: args.document_id_b,
174
+ source: docB.source,
175
+ period: docB.period,
176
+ summary: summaryB,
177
+ },
178
+ deltas: {
179
+ line_count: lineItemsDelta,
180
+ total_converted: totalConvertedDelta,
181
+ matched_works: matchedWorksDelta,
182
+ warning_count: warningsDelta,
183
+ },
184
+ };
185
+ return {
186
+ content: [{ type: "text", text: table }],
187
+ structuredContent: deltas,
188
+ };
189
+ }
190
+ }
191
+ //# sourceMappingURL=import-documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-documents.js","sourceRoot":"","sources":["../../src/tools/import-documents.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,OAAO,mBAAmB;IACtB,IAAI,CAAa;IAEzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO;YACL;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,4BAA4B;oBAClC,WAAW,EACT,0SAA0S;oBAC5S,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ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,CAAC,aAAa,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI;SAC9G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,MAAM,MAAM,GAAG;YACb,UAAU,EAAE;gBACV,EAAE,EAAE,IAAI,CAAC,aAAa;gBACtB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,QAAQ;aAClB;YACD,UAAU,EAAE;gBACV,EAAE,EAAE,IAAI,CAAC,aAAa;gBACtB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,QAAQ;aAClB;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,cAAc;gBAC1B,eAAe,EAAE,mBAAmB;gBACpC,aAAa,EAAE,iBAAiB;gBAChC,aAAa,EAAE,aAAa;aAC7B;SACF,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YACxC,iBAAiB,EAAE,MAAM;SAC1B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Import Tools - MCP tools for bulk CSV import of works, people, recordings, etc.
3
+ *
4
+ * Typical agent flow:
5
+ * 1. pica_import_analyze — parse CSV and get AI-suggested mappings
6
+ * 2. pica_import_validate — validate all rows against the mapping
7
+ * 3. pica_import_execute — run the import (with optional dry_run first)
8
+ *
9
+ * Alternative flows:
10
+ * - pica_import_fields — get available target fields for a domain
11
+ * - pica_import_template — get an example CSV template
12
+ */
13
+ import { PicaClient } from "../pica-sdk.js";
14
+ import { ToolDefinition, ToolExecutor } from "./index.js";
15
+ export declare class ImportTools {
16
+ private pica;
17
+ constructor(pica: PicaClient);
18
+ getTools(): Array<{
19
+ definition: ToolDefinition;
20
+ executor: ToolExecutor;
21
+ }>;
22
+ private analyzeImport;
23
+ private validateImport;
24
+ private executeImport;
25
+ private getImportFields;
26
+ private getImportTemplate;
27
+ private importStreamingLink;
28
+ }
29
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/tools/import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAiBtE,qBAAa,WAAW;IACtB,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;YA2N3D,aAAa;YAuBb,cAAc;YAgCd,aAAa;YAkCb,eAAe;YAUf,iBAAiB;YAUjB,mBAAmB;CA+HlC"}
@@ -0,0 +1,404 @@
1
+ /**
2
+ * Import Tools - MCP tools for bulk CSV import of works, people, recordings, etc.
3
+ *
4
+ * Typical agent flow:
5
+ * 1. pica_import_analyze — parse CSV and get AI-suggested mappings
6
+ * 2. pica_import_validate — validate all rows against the mapping
7
+ * 3. pica_import_execute — run the import (with optional dry_run first)
8
+ *
9
+ * Alternative flows:
10
+ * - pica_import_fields — get available target fields for a domain
11
+ * - pica_import_template — get an example CSV template
12
+ */
13
+ import { formatSuccess, formatAsText, mapGapsToHints, } from "../utils/formatting.js";
14
+ const VALID_DOMAINS = [
15
+ "works",
16
+ "people",
17
+ "recordings",
18
+ "documents",
19
+ "enquiries",
20
+ "royalties",
21
+ ];
22
+ export class ImportTools {
23
+ pica;
24
+ constructor(pica) {
25
+ this.pica = pica;
26
+ }
27
+ getTools() {
28
+ return [
29
+ {
30
+ definition: {
31
+ name: "pica_import_analyze",
32
+ description: "Analyze a CSV file and get AI-suggested column mappings. Pass the raw CSV content as a string. " +
33
+ "Returns parsed headers, sample rows, and AI-suggested mappings from CSV columns to PICA fields. " +
34
+ "Use this as the first step before validate and execute. " +
35
+ "→ then: pica_import_validate (check for errors), pica_import_execute (run the import)",
36
+ inputSchema: {
37
+ type: "object",
38
+ properties: {
39
+ file_content: {
40
+ type: "string",
41
+ description: "Raw CSV content as a string (read the CSV file and pass its contents here)",
42
+ },
43
+ domain: {
44
+ type: "string",
45
+ description: "Import domain — what type of records to create",
46
+ enum: VALID_DOMAINS,
47
+ },
48
+ },
49
+ required: ["file_content", "domain"],
50
+ },
51
+ },
52
+ executor: this.analyzeImport.bind(this),
53
+ },
54
+ {
55
+ definition: {
56
+ name: "pica_import_validate",
57
+ description: "Validate all CSV rows against a field mapping before executing import. " +
58
+ "Returns per-row validation errors and a summary of valid/invalid rows. " +
59
+ "Run this after pica_import_analyze to check for issues before importing.",
60
+ inputSchema: {
61
+ type: "object",
62
+ properties: {
63
+ file_content: {
64
+ type: "string",
65
+ description: "Raw CSV content (same as passed to pica_import_analyze)",
66
+ },
67
+ domain: {
68
+ type: "string",
69
+ description: "Import domain",
70
+ enum: VALID_DOMAINS,
71
+ },
72
+ mapping: {
73
+ type: "array",
74
+ description: "Column mappings from pica_import_analyze (or manually adjusted). " +
75
+ "Each entry maps a CSV column to a PICA target field.",
76
+ items: {
77
+ type: "object",
78
+ properties: {
79
+ csvColumn: {
80
+ type: "string",
81
+ description: "CSV column header name",
82
+ },
83
+ targetField: {
84
+ type: "string",
85
+ description: "PICA database field name",
86
+ },
87
+ transformType: {
88
+ type: "string",
89
+ description: "Transform to apply (default: 'text'). Options: text, date, number, boolean, enum",
90
+ },
91
+ },
92
+ required: ["csvColumn", "targetField"],
93
+ },
94
+ },
95
+ },
96
+ required: ["file_content", "domain", "mapping"],
97
+ },
98
+ },
99
+ executor: this.validateImport.bind(this),
100
+ },
101
+ {
102
+ definition: {
103
+ name: "pica_import_execute",
104
+ description: "Execute a bulk import from CSV. Creates records in PICA based on the CSV data and field mapping. " +
105
+ "Always run pica_import_validate first to check for errors. " +
106
+ "Use dry_run: true to preview what would be imported without actually creating records. " +
107
+ "Max 10,000 rows per import.",
108
+ inputSchema: {
109
+ type: "object",
110
+ properties: {
111
+ file_content: {
112
+ type: "string",
113
+ description: "Raw CSV content",
114
+ },
115
+ domain: {
116
+ type: "string",
117
+ description: "Import domain",
118
+ enum: VALID_DOMAINS,
119
+ },
120
+ mapping: {
121
+ type: "array",
122
+ description: "Column mappings (same format as pica_import_validate)",
123
+ items: {
124
+ type: "object",
125
+ properties: {
126
+ csvColumn: { type: "string" },
127
+ targetField: { type: "string" },
128
+ transformType: { type: "string" },
129
+ },
130
+ required: ["csvColumn", "targetField"],
131
+ },
132
+ },
133
+ dry_run: {
134
+ type: "boolean",
135
+ description: "If true, simulates the import without creating records. Recommended before first real import.",
136
+ },
137
+ skip_invalid_rows: {
138
+ type: "boolean",
139
+ description: "If true, skips rows with validation errors instead of failing the entire import.",
140
+ },
141
+ batch_size: {
142
+ type: "number",
143
+ description: "Number of rows to process per batch (default: 50, max: 1000)",
144
+ },
145
+ },
146
+ required: ["file_content", "domain", "mapping"],
147
+ },
148
+ },
149
+ executor: this.executeImport.bind(this),
150
+ },
151
+ {
152
+ definition: {
153
+ name: "pica_import_fields",
154
+ description: "Get the available target fields for an import domain. Returns field names, labels, types, " +
155
+ "and whether they are required. Useful for understanding what columns a CSV should have.",
156
+ inputSchema: {
157
+ type: "object",
158
+ properties: {
159
+ domain: {
160
+ type: "string",
161
+ description: "Import domain to get fields for",
162
+ enum: VALID_DOMAINS,
163
+ },
164
+ },
165
+ required: ["domain"],
166
+ },
167
+ },
168
+ executor: this.getImportFields.bind(this),
169
+ },
170
+ {
171
+ definition: {
172
+ name: "pica_import_template",
173
+ description: "Get an example CSV template for an import domain. Returns a CSV string with headers " +
174
+ "and example rows that can be used as a starting point.",
175
+ inputSchema: {
176
+ type: "object",
177
+ properties: {
178
+ domain: {
179
+ type: "string",
180
+ description: "Import domain to get template for",
181
+ enum: VALID_DOMAINS,
182
+ },
183
+ },
184
+ required: ["domain"],
185
+ },
186
+ },
187
+ executor: this.getImportTemplate.bind(this),
188
+ },
189
+ {
190
+ definition: {
191
+ name: "pica_import_streaming_link",
192
+ description: "Import works from a Spotify or Deezer URL. Paste a track, album, or playlist link " +
193
+ "and PICA will fetch all tracks and create works, recordings, people, and performer credits automatically. " +
194
+ "Two-step flow: first call without confirm to preview tracks, then call with confirm: true to execute.\n\n" +
195
+ "Supported platforms: Spotify (track/album/playlist), Deezer (track/album/playlist).\n" +
196
+ "Apple Music and artist profile URLs are not yet supported.\n\n" +
197
+ "Each imported track creates: a work (with title, ISRC, UPC, label, artwork), " +
198
+ "a recording (with ISRC, linked to work), people records for artists, " +
199
+ "performer credits, and multimedia links. Enrichment cascades fire automatically. " +
200
+ "→ then: pica_credits_update (add songwriting credits), pica_work_completeness (check gaps), pica_enrich_work (fill identifiers)",
201
+ inputSchema: {
202
+ type: "object",
203
+ properties: {
204
+ url: {
205
+ type: "string",
206
+ description: "Spotify or Deezer URL (track, album, or playlist). " +
207
+ "Examples: https://open.spotify.com/album/4aawyAB9vmqN3uQ7FjRGTy, " +
208
+ "https://deezer.com/playlist/1234567",
209
+ },
210
+ confirm: {
211
+ type: "boolean",
212
+ description: "Set to true to execute the import. Omit or set false to preview tracks first.",
213
+ },
214
+ selected_track_ids: {
215
+ type: "array",
216
+ items: { type: "string" },
217
+ description: "Optional: external IDs of specific tracks to import (from the preview). " +
218
+ "If omitted, all non-duplicate tracks are imported.",
219
+ },
220
+ },
221
+ required: ["url"],
222
+ },
223
+ },
224
+ executor: this.importStreamingLink.bind(this),
225
+ },
226
+ ];
227
+ }
228
+ async analyzeImport(args) {
229
+ const result = await this.pica.imports.analyze({
230
+ fileContent: args.file_content,
231
+ domain: args.domain,
232
+ });
233
+ const parsed = result.parsed;
234
+ const mappingCount = Object.keys(result.analysis?.mappings || {}).length;
235
+ return formatSuccess(`CSV analyzed: ${parsed.totalRows} rows, ${parsed.headers.length} columns. ` +
236
+ `${mappingCount} columns auto-mapped. ` +
237
+ `Review the mappings and run pica_import_validate to check for errors.`, {
238
+ headers: parsed.headers,
239
+ totalRows: parsed.totalRows,
240
+ sampleRows: parsed.rows.slice(0, 3),
241
+ mappings: result.analysis?.mappings,
242
+ suggestions: result.analysis?.suggestions,
243
+ });
244
+ }
245
+ async validateImport(args) {
246
+ const result = await this.pica.imports.validate({
247
+ domain: args.domain,
248
+ fileContent: args.file_content,
249
+ mapping: args.mapping,
250
+ });
251
+ if (result.valid) {
252
+ return formatSuccess(`All ${result.totalRowCount} rows are valid. Ready to import with pica_import_execute.`, {
253
+ validRowCount: result.validRowCount,
254
+ totalRowCount: result.totalRowCount,
255
+ });
256
+ }
257
+ return formatSuccess(`Validation: ${result.validRowCount}/${result.totalRowCount} rows valid, ` +
258
+ `${result.invalidRowCount} invalid. ` +
259
+ `Fix the errors or use skip_invalid_rows: true when importing.`, {
260
+ valid: result.valid,
261
+ validRowCount: result.validRowCount,
262
+ invalidRowCount: result.invalidRowCount,
263
+ totalRowCount: result.totalRowCount,
264
+ errorsByType: result.errorsByType,
265
+ errors: result.errors.slice(0, 20),
266
+ });
267
+ }
268
+ async executeImport(args) {
269
+ const result = await this.pica.imports.execute({
270
+ domain: args.domain,
271
+ fileContent: args.file_content,
272
+ mapping: args.mapping,
273
+ options: {
274
+ dryRun: args.dry_run ?? false,
275
+ skipInvalidRows: args.skip_invalid_rows ?? false,
276
+ batchSize: args.batch_size,
277
+ },
278
+ });
279
+ const prefix = result.dryRun ? "[DRY RUN] " : "";
280
+ return formatSuccess(`${prefix}Import complete: ${result.importedCount} created, ` +
281
+ `${result.updatedCount} updated, ${result.skippedCount} skipped. ` +
282
+ `${result.errors.length} errors.`, {
283
+ importedCount: result.importedCount,
284
+ updatedCount: result.updatedCount,
285
+ skippedCount: result.skippedCount,
286
+ dryRun: result.dryRun,
287
+ errors: result.errors.length > 0 ? result.errors.slice(0, 10) : undefined,
288
+ createdRecords: result.createdRecords.length <= 20
289
+ ? result.createdRecords
290
+ : `${result.createdRecords.length} records (showing first 20)`,
291
+ summary: result.summary,
292
+ });
293
+ }
294
+ async getImportFields(args) {
295
+ const fields = await this.pica.imports.getFields(args.domain);
296
+ return formatAsText({
297
+ domain: args.domain,
298
+ fields,
299
+ });
300
+ }
301
+ async getImportTemplate(args) {
302
+ const csvContent = await this.pica.imports.getTemplate(args.domain);
303
+ return formatSuccess(`Template CSV for "${args.domain}" import. Use this as a starting point.`, { csvContent });
304
+ }
305
+ async importStreamingLink(args) {
306
+ const url = args.url;
307
+ if (!url) {
308
+ return {
309
+ content: [{ type: "text", text: "Error: url is required" }],
310
+ isError: true,
311
+ };
312
+ }
313
+ try {
314
+ if (args.confirm) {
315
+ // Execute import
316
+ const result = await this.pica.imports.streamingLinkImport(url, args.selected_track_ids);
317
+ // Generate completion hints by sampling the first created work
318
+ const hints = [];
319
+ if (result.workIds?.length > 0) {
320
+ try {
321
+ const sample = await this.pica.health.getWorkCompleteness(result.workIds[0]);
322
+ hints.push(...mapGapsToHints(sample?.gaps || sample?.missing || []));
323
+ }
324
+ catch {
325
+ // Completeness check is best-effort — don't fail the import
326
+ }
327
+ // Hint about songwriting credits for streaming imports
328
+ // (streaming platforms only provide performer credits, not writers)
329
+ if (!hints.some((h) => h.gap.includes("credit"))) {
330
+ hints.push({
331
+ gap: "no_songwriting_credits",
332
+ suggestion: "Add songwriting credits — streaming imports only include performer credits",
333
+ count: result.worksCreated,
334
+ severity: "critical",
335
+ });
336
+ }
337
+ }
338
+ return formatSuccess(`Streaming import complete: ${result.worksCreated} works, ` +
339
+ `${result.recordingsCreated} recordings, ${result.peopleCreated} people, ` +
340
+ `${result.creditsCreated} credits created. ` +
341
+ `${result.duplicatesSkipped} duplicates skipped.`, {
342
+ worksCreated: result.worksCreated,
343
+ recordingsCreated: result.recordingsCreated,
344
+ peopleCreated: result.peopleCreated,
345
+ creditsCreated: result.creditsCreated,
346
+ multimediaLinked: result.multimediaLinked,
347
+ duplicatesSkipped: result.duplicatesSkipped,
348
+ workIds: result.workIds,
349
+ }, hints);
350
+ }
351
+ // Preview mode
352
+ const preview = await this.pica.imports.streamingLinkPreview(url);
353
+ const trackSummary = preview.newTracks
354
+ .slice(0, 10)
355
+ .map((t) => ` - ${t.title} — ${t.artists.map((a) => a.name).join(", ")}${t.isrc ? ` [${t.isrc}]` : ""}`)
356
+ .join("\n");
357
+ const dupSummary = preview.duplicates.length > 0
358
+ ? `\n\n${preview.duplicates.length} duplicates found (will be skipped):\n` +
359
+ preview.duplicates
360
+ .slice(0, 5)
361
+ .map((d) => ` - "${d.track.title}" matches "${d.existingTitle}" (${d.matchType})`)
362
+ .join("\n")
363
+ : "";
364
+ return formatSuccess(`Found ${preview.tracks.length} tracks from ${preview.source.platform} ${preview.source.type}. ` +
365
+ `${preview.newTracks.length} new, ${preview.duplicates.length} duplicates.\n\n` +
366
+ `New tracks:\n${trackSummary}` +
367
+ (preview.newTracks.length > 10
368
+ ? `\n ... and ${preview.newTracks.length - 10} more`
369
+ : "") +
370
+ dupSummary +
371
+ `\n\nTo import, call again with confirm: true.`, {
372
+ source: preview.source,
373
+ totalTracks: preview.tracks.length,
374
+ newTrackCount: preview.newTracks.length,
375
+ duplicateCount: preview.duplicates.length,
376
+ newTracks: preview.newTracks.map((t) => ({
377
+ title: t.title,
378
+ artists: t.artists.map((a) => a.name),
379
+ isrc: t.isrc,
380
+ externalId: t.externalId,
381
+ })),
382
+ duplicates: preview.duplicates.map((d) => ({
383
+ title: d.track.title,
384
+ existingTitle: d.existingTitle,
385
+ existingWorkId: d.existingWorkId,
386
+ matchType: d.matchType,
387
+ })),
388
+ });
389
+ }
390
+ catch (error) {
391
+ const message = error instanceof Error ? error.message : String(error);
392
+ return {
393
+ content: [
394
+ {
395
+ type: "text",
396
+ text: `Streaming import failed: ${message}`,
397
+ },
398
+ ],
399
+ isError: true,
400
+ };
401
+ }
402
+ }
403
+ }
404
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+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