@withpica/mcp-server 2.6.2 → 2.7.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 (256) hide show
  1. package/dist/config.d.ts +25 -4
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +12 -36
  4. package/dist/config.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +3 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/pica-sdk.d.ts +1231 -0
  9. package/dist/pica-sdk.d.ts.map +1 -0
  10. package/dist/pica-sdk.js +1403 -0
  11. package/dist/pica-sdk.js.map +1 -0
  12. package/dist/prompts/index.d.ts +64 -64
  13. package/dist/prompts/index.js +24 -24
  14. package/dist/prompts/index.js.map +1 -1
  15. package/dist/resources/index.d.ts +53 -55
  16. package/dist/resources/index.d.ts.map +1 -1
  17. package/dist/resources/index.js +54 -133
  18. package/dist/resources/index.js.map +1 -1
  19. package/dist/server.d.ts +32 -49
  20. package/dist/server.d.ts.map +1 -1
  21. package/dist/server.js +14 -103
  22. package/dist/server.js.map +1 -1
  23. package/dist/tools/index.d.ts +37 -83
  24. package/dist/tools/index.d.ts.map +1 -1
  25. package/dist/tools/index.js +84 -442
  26. package/dist/tools/index.js.map +1 -1
  27. package/dist/tools/people.d.ts +47 -39
  28. package/dist/tools/people.d.ts.map +1 -1
  29. package/dist/tools/people.js +109 -148
  30. package/dist/tools/people.js.map +1 -1
  31. package/dist/tools/recordings.d.ts +9 -9
  32. package/dist/tools/recordings.d.ts.map +1 -1
  33. package/dist/tools/recordings.js +48 -121
  34. package/dist/tools/recordings.js.map +1 -1
  35. package/dist/tools/search.d.ts +21 -21
  36. package/dist/tools/search.d.ts.map +1 -1
  37. package/dist/tools/search.js +3 -3
  38. package/dist/tools/search.js.map +1 -1
  39. package/dist/tools/works.d.ts +47 -39
  40. package/dist/tools/works.d.ts.map +1 -1
  41. package/dist/tools/works.js +116 -201
  42. package/dist/tools/works.js.map +1 -1
  43. package/dist/utils/errors.d.ts +29 -0
  44. package/dist/utils/errors.d.ts.map +1 -0
  45. package/dist/utils/errors.js +115 -0
  46. package/dist/utils/errors.js.map +1 -0
  47. package/dist/utils/formatting.d.ts +82 -0
  48. package/dist/utils/formatting.d.ts.map +1 -0
  49. package/dist/utils/formatting.js +125 -0
  50. package/dist/utils/formatting.js.map +1 -0
  51. package/package.json +1 -1
  52. package/server.json +1 -1
  53. package/dist/__mocks__/mppx-mcp-sdk-server.d.ts +0 -6
  54. package/dist/__mocks__/mppx-mcp-sdk-server.d.ts.map +0 -1
  55. package/dist/__mocks__/mppx-mcp-sdk-server.js +0 -6
  56. package/dist/__mocks__/mppx-mcp-sdk-server.js.map +0 -1
  57. package/dist/__mocks__/mppx-server.d.ts +0 -12
  58. package/dist/__mocks__/mppx-server.d.ts.map +0 -1
  59. package/dist/__mocks__/mppx-server.js +0 -12
  60. package/dist/__mocks__/mppx-server.js.map +0 -1
  61. package/dist/apps/download.d.ts +0 -2
  62. package/dist/apps/download.d.ts.map +0 -1
  63. package/dist/apps/download.js +0 -125
  64. package/dist/apps/download.js.map +0 -1
  65. package/dist/apps/generated/shared-bundle.d.ts +0 -5
  66. package/dist/apps/generated/shared-bundle.d.ts.map +0 -1
  67. package/dist/apps/generated/shared-bundle.js +0 -7
  68. package/dist/apps/generated/shared-bundle.js.map +0 -1
  69. package/dist/apps/shared.d.ts +0 -15
  70. package/dist/apps/shared.d.ts.map +0 -1
  71. package/dist/apps/shared.js +0 -480
  72. package/dist/apps/shared.js.map +0 -1
  73. package/dist/apps/upload.d.ts +0 -2
  74. package/dist/apps/upload.d.ts.map +0 -1
  75. package/dist/apps/upload.js +0 -280
  76. package/dist/apps/upload.js.map +0 -1
  77. package/dist/resources/llms-primer.d.ts +0 -2
  78. package/dist/resources/llms-primer.d.ts.map +0 -1
  79. package/dist/resources/llms-primer.js +0 -68
  80. package/dist/resources/llms-primer.js.map +0 -1
  81. package/dist/server-instructions.d.ts +0 -9
  82. package/dist/server-instructions.d.ts.map +0 -1
  83. package/dist/server-instructions.js +0 -34
  84. package/dist/server-instructions.js.map +0 -1
  85. package/dist/tools/agreement-types.d.ts +0 -27
  86. package/dist/tools/agreement-types.d.ts.map +0 -1
  87. package/dist/tools/agreement-types.js +0 -387
  88. package/dist/tools/agreement-types.js.map +0 -1
  89. package/dist/tools/agreements.d.ts +0 -20
  90. package/dist/tools/agreements.d.ts.map +0 -1
  91. package/dist/tools/agreements.js +0 -363
  92. package/dist/tools/agreements.js.map +0 -1
  93. package/dist/tools/analytics.d.ts +0 -20
  94. package/dist/tools/analytics.d.ts.map +0 -1
  95. package/dist/tools/analytics.js +0 -124
  96. package/dist/tools/analytics.js.map +0 -1
  97. package/dist/tools/app-tools.d.ts +0 -21
  98. package/dist/tools/app-tools.d.ts.map +0 -1
  99. package/dist/tools/app-tools.js +0 -248
  100. package/dist/tools/app-tools.js.map +0 -1
  101. package/dist/tools/assets.d.ts +0 -21
  102. package/dist/tools/assets.d.ts.map +0 -1
  103. package/dist/tools/assets.js +0 -441
  104. package/dist/tools/assets.js.map +0 -1
  105. package/dist/tools/audio-files.d.ts +0 -20
  106. package/dist/tools/audio-files.d.ts.map +0 -1
  107. package/dist/tools/audio-files.js +0 -384
  108. package/dist/tools/audio-files.js.map +0 -1
  109. package/dist/tools/auth.d.ts +0 -22
  110. package/dist/tools/auth.d.ts.map +0 -1
  111. package/dist/tools/auth.js +0 -210
  112. package/dist/tools/auth.js.map +0 -1
  113. package/dist/tools/bulk.d.ts +0 -16
  114. package/dist/tools/bulk.d.ts.map +0 -1
  115. package/dist/tools/bulk.js +0 -85
  116. package/dist/tools/bulk.js.map +0 -1
  117. package/dist/tools/calendar.d.ts +0 -15
  118. package/dist/tools/calendar.d.ts.map +0 -1
  119. package/dist/tools/calendar.js +0 -67
  120. package/dist/tools/calendar.js.map +0 -1
  121. package/dist/tools/collaborators.d.ts +0 -17
  122. package/dist/tools/collaborators.d.ts.map +0 -1
  123. package/dist/tools/collaborators.js +0 -131
  124. package/dist/tools/collaborators.js.map +0 -1
  125. package/dist/tools/comparisons.d.ts +0 -22
  126. package/dist/tools/comparisons.d.ts.map +0 -1
  127. package/dist/tools/comparisons.js +0 -78
  128. package/dist/tools/comparisons.js.map +0 -1
  129. package/dist/tools/credits.d.ts +0 -17
  130. package/dist/tools/credits.d.ts.map +0 -1
  131. package/dist/tools/credits.js +0 -312
  132. package/dist/tools/credits.js.map +0 -1
  133. package/dist/tools/dashboard.d.ts +0 -19
  134. package/dist/tools/dashboard.d.ts.map +0 -1
  135. package/dist/tools/dashboard.js +0 -146
  136. package/dist/tools/dashboard.js.map +0 -1
  137. package/dist/tools/directory.d.ts +0 -15
  138. package/dist/tools/directory.d.ts.map +0 -1
  139. package/dist/tools/directory.js +0 -106
  140. package/dist/tools/directory.js.map +0 -1
  141. package/dist/tools/discovery.d.ts +0 -28
  142. package/dist/tools/discovery.d.ts.map +0 -1
  143. package/dist/tools/discovery.js +0 -560
  144. package/dist/tools/discovery.js.map +0 -1
  145. package/dist/tools/disputes.d.ts +0 -18
  146. package/dist/tools/disputes.d.ts.map +0 -1
  147. package/dist/tools/disputes.js +0 -61
  148. package/dist/tools/disputes.js.map +0 -1
  149. package/dist/tools/documents.d.ts +0 -15
  150. package/dist/tools/documents.d.ts.map +0 -1
  151. package/dist/tools/documents.js +0 -36
  152. package/dist/tools/documents.js.map +0 -1
  153. package/dist/tools/duplicates.d.ts +0 -16
  154. package/dist/tools/duplicates.d.ts.map +0 -1
  155. package/dist/tools/duplicates.js +0 -87
  156. package/dist/tools/duplicates.js.map +0 -1
  157. package/dist/tools/enrichment.d.ts +0 -20
  158. package/dist/tools/enrichment.d.ts.map +0 -1
  159. package/dist/tools/enrichment.js +0 -154
  160. package/dist/tools/enrichment.js.map +0 -1
  161. package/dist/tools/exports.d.ts +0 -19
  162. package/dist/tools/exports.d.ts.map +0 -1
  163. package/dist/tools/exports.js +0 -175
  164. package/dist/tools/exports.js.map +0 -1
  165. package/dist/tools/import-documents.d.ts +0 -21
  166. package/dist/tools/import-documents.d.ts.map +0 -1
  167. package/dist/tools/import-documents.js +0 -203
  168. package/dist/tools/import-documents.js.map +0 -1
  169. package/dist/tools/import.d.ts +0 -30
  170. package/dist/tools/import.d.ts.map +0 -1
  171. package/dist/tools/import.js +0 -455
  172. package/dist/tools/import.js.map +0 -1
  173. package/dist/tools/integrations.d.ts +0 -15
  174. package/dist/tools/integrations.d.ts.map +0 -1
  175. package/dist/tools/integrations.js +0 -100
  176. package/dist/tools/integrations.js.map +0 -1
  177. package/dist/tools/licensing.d.ts +0 -40
  178. package/dist/tools/licensing.d.ts.map +0 -1
  179. package/dist/tools/licensing.js +0 -431
  180. package/dist/tools/licensing.js.map +0 -1
  181. package/dist/tools/memory.d.ts +0 -21
  182. package/dist/tools/memory.d.ts.map +0 -1
  183. package/dist/tools/memory.js +0 -116
  184. package/dist/tools/memory.js.map +0 -1
  185. package/dist/tools/metadata.d.ts +0 -15
  186. package/dist/tools/metadata.d.ts.map +0 -1
  187. package/dist/tools/metadata.js +0 -1069
  188. package/dist/tools/metadata.js.map +0 -1
  189. package/dist/tools/multimedia.d.ts +0 -19
  190. package/dist/tools/multimedia.d.ts.map +0 -1
  191. package/dist/tools/multimedia.js +0 -291
  192. package/dist/tools/multimedia.js.map +0 -1
  193. package/dist/tools/notes.d.ts +0 -21
  194. package/dist/tools/notes.d.ts.map +0 -1
  195. package/dist/tools/notes.js +0 -108
  196. package/dist/tools/notes.js.map +0 -1
  197. package/dist/tools/notifications.d.ts +0 -17
  198. package/dist/tools/notifications.d.ts.map +0 -1
  199. package/dist/tools/notifications.js +0 -117
  200. package/dist/tools/notifications.js.map +0 -1
  201. package/dist/tools/projects.d.ts +0 -19
  202. package/dist/tools/projects.d.ts.map +0 -1
  203. package/dist/tools/projects.js +0 -140
  204. package/dist/tools/projects.js.map +0 -1
  205. package/dist/tools/publishers.d.ts +0 -16
  206. package/dist/tools/publishers.d.ts.map +0 -1
  207. package/dist/tools/publishers.js +0 -69
  208. package/dist/tools/publishers.js.map +0 -1
  209. package/dist/tools/purchases.d.ts +0 -15
  210. package/dist/tools/purchases.d.ts.map +0 -1
  211. package/dist/tools/purchases.js +0 -63
  212. package/dist/tools/purchases.js.map +0 -1
  213. package/dist/tools/recovery-hints.d.ts +0 -14
  214. package/dist/tools/recovery-hints.d.ts.map +0 -1
  215. package/dist/tools/recovery-hints.js +0 -277
  216. package/dist/tools/recovery-hints.js.map +0 -1
  217. package/dist/tools/releases.d.ts +0 -18
  218. package/dist/tools/releases.d.ts.map +0 -1
  219. package/dist/tools/releases.js +0 -128
  220. package/dist/tools/releases.js.map +0 -1
  221. package/dist/tools/royalties.d.ts +0 -23
  222. package/dist/tools/royalties.d.ts.map +0 -1
  223. package/dist/tools/royalties.js +0 -257
  224. package/dist/tools/royalties.js.map +0 -1
  225. package/dist/tools/send.d.ts +0 -17
  226. package/dist/tools/send.d.ts.map +0 -1
  227. package/dist/tools/send.js +0 -185
  228. package/dist/tools/send.js.map +0 -1
  229. package/dist/tools/sessions.d.ts +0 -18
  230. package/dist/tools/sessions.d.ts.map +0 -1
  231. package/dist/tools/sessions.js +0 -115
  232. package/dist/tools/sessions.js.map +0 -1
  233. package/dist/tools/settings.d.ts +0 -18
  234. package/dist/tools/settings.d.ts.map +0 -1
  235. package/dist/tools/settings.js +0 -96
  236. package/dist/tools/settings.js.map +0 -1
  237. package/dist/tools/share-links.d.ts +0 -19
  238. package/dist/tools/share-links.d.ts.map +0 -1
  239. package/dist/tools/share-links.js +0 -121
  240. package/dist/tools/share-links.js.map +0 -1
  241. package/dist/tools/split-sheets.d.ts +0 -25
  242. package/dist/tools/split-sheets.d.ts.map +0 -1
  243. package/dist/tools/split-sheets.js +0 -307
  244. package/dist/tools/split-sheets.js.map +0 -1
  245. package/dist/tools/team.d.ts +0 -22
  246. package/dist/tools/team.d.ts.map +0 -1
  247. package/dist/tools/team.js +0 -134
  248. package/dist/tools/team.js.map +0 -1
  249. package/dist/tools/telegram.d.ts +0 -20
  250. package/dist/tools/telegram.d.ts.map +0 -1
  251. package/dist/tools/telegram.js +0 -88
  252. package/dist/tools/telegram.js.map +0 -1
  253. package/dist/tools/uploads.d.ts +0 -17
  254. package/dist/tools/uploads.d.ts.map +0 -1
  255. package/dist/tools/uploads.js +0 -156
  256. package/dist/tools/uploads.js.map +0 -1
@@ -1,384 +0,0 @@
1
- // Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
2
- import { formatAsText, formatList, formatSuccess, } from "@withpica/mcp-utils";
3
- import { withCreditGate } from "@withpica/mcp-utils";
4
- export class AudioFilesTools {
5
- pica;
6
- constructor(pica) {
7
- this.pica = pica;
8
- }
9
- getTools() {
10
- return [
11
- {
12
- definition: {
13
- name: "pica_audio_query",
14
- description: "Find audio files — filter by work, file type, or analysis status. " +
15
- "→ then: pica_audio_inspect (details for a specific file)",
16
- inputSchema: {
17
- type: "object",
18
- properties: {
19
- work_id: {
20
- type: "string",
21
- description: "Filter by work ID to get all audio files for a specific work",
22
- },
23
- file_type: {
24
- type: "string",
25
- description: "Filter by file type",
26
- enum: ["master", "instrumental", "stem", "demo", "version"],
27
- },
28
- unprocessed: {
29
- type: "boolean",
30
- description: "Set true to get only files without audio analysis (no BPM/key detection yet)",
31
- },
32
- limit: {
33
- type: "number",
34
- description: "Maximum results to return (default: 50)",
35
- },
36
- },
37
- },
38
- },
39
- executor: this.queryAudioFiles.bind(this),
40
- },
41
- {
42
- definition: {
43
- name: "pica_audio_inspect",
44
- description: "Get details for a specific audio file. Omit sections for everything. " +
45
- "→ then: pica_audio_analyze (run analysis), pica_audio_identify (fingerprint match)",
46
- inputSchema: {
47
- type: "object",
48
- properties: {
49
- id: {
50
- type: "string",
51
- description: "Audio file ID",
52
- },
53
- sections: {
54
- type: "array",
55
- items: {
56
- type: "string",
57
- enum: ["basic", "analysis", "status"],
58
- },
59
- description: "Which data sections to include. Omit for all sections.",
60
- },
61
- },
62
- required: ["id"],
63
- },
64
- },
65
- executor: this.inspectAudioFile.bind(this),
66
- },
67
- {
68
- definition: {
69
- name: "pica_audio_analyze",
70
- description: "Trigger audio analysis on an audio file. Two analysis types available (1 credit each):\n" +
71
- "• Audio features (BPM, key, energy, valence, mood, duration) — via Librosa on Railway\n" +
72
- "• Lyrics transcription (speech-to-text + language detection) — via Groq Whisper on Railway\n\n" +
73
- "Both are enabled by default. Analysis runs asynchronously — use pica_audio_inspect with status section to check progress. " +
74
- "Transcribed lyrics are saved to the transcriptions table and can be copied to the work's lyrics field. " +
75
- "→ then: pica_audio_inspect (check progress), pica_search_for_sync (find sync-ready works)",
76
- inputSchema: {
77
- type: "object",
78
- properties: {
79
- id: {
80
- type: "string",
81
- description: "Audio file ID to analyze",
82
- },
83
- force: {
84
- type: "boolean",
85
- description: "Force re-analysis even if the file was already analyzed",
86
- },
87
- enable_audio: {
88
- type: "boolean",
89
- description: "Enable audio feature extraction (BPM, key, energy). Default: true. Costs 1 credit.",
90
- },
91
- enable_lyrics: {
92
- type: "boolean",
93
- description: "Enable lyrics transcription via Whisper. Default: true. Costs 1 credit.",
94
- },
95
- },
96
- required: ["id"],
97
- },
98
- },
99
- executor: withCreditGate(this.pica, "analysis_audio", "audio analysis", this.analyzeAudioFile.bind(this)),
100
- },
101
- {
102
- definition: {
103
- name: "pica_audio_presigned_upload",
104
- description: "Generate a signed URL for uploading an audio file directly to storage. Returns an upload URL and upload ID. After uploading the file via HTTP PUT to the returned URL, call pica_audio_complete_upload to finalize. Supported formats: WAV, MP3, FLAC, AIFF, OGG, WebM. Max size: 800MB. " +
105
- "→ then: pica_audio_complete_upload (finalize upload), pica_audio_analyze (extract BPM, key, mood)",
106
- inputSchema: {
107
- type: "object",
108
- properties: {
109
- filename: {
110
- type: "string",
111
- description: "Original filename with extension (e.g. 'my-song.wav')",
112
- },
113
- content_type: {
114
- type: "string",
115
- description: "MIME type of the audio file (e.g. 'audio/wav', 'audio/mpeg', 'audio/flac')",
116
- enum: [
117
- "audio/wav",
118
- "audio/x-wav",
119
- "audio/mpeg",
120
- "audio/mp3",
121
- "audio/flac",
122
- "audio/x-flac",
123
- "audio/aiff",
124
- "audio/x-aiff",
125
- "audio/ogg",
126
- "audio/webm",
127
- ],
128
- },
129
- file_size: {
130
- type: "number",
131
- description: "File size in bytes",
132
- },
133
- work_id: {
134
- type: "string",
135
- description: "Optional work ID to link the audio file to. If provided, a recording will be auto-created for master files.",
136
- },
137
- title: {
138
- type: "string",
139
- description: "Optional title for the audio file. Defaults to filename without extension.",
140
- },
141
- file_type: {
142
- type: "string",
143
- description: "Type of audio file (default: 'master')",
144
- enum: ["master", "instrumental", "stem", "demo", "version"],
145
- },
146
- },
147
- required: ["filename", "content_type", "file_size"],
148
- },
149
- },
150
- executor: this.presignedUpload.bind(this),
151
- },
152
- {
153
- definition: {
154
- name: "pica_audio_complete_upload",
155
- description: "Finalize an audio file upload after the file has been PUT to the signed URL from pica_audio_presigned_upload. Creates the database record and optionally links to a work/recording. For master files linked to a work, a recording is auto-created if none exists. " +
156
- "→ then: pica_audio_analyze (extract BPM, key, mood), pica_audio_identify (fingerprint match via ACRCloud)",
157
- inputSchema: {
158
- type: "object",
159
- properties: {
160
- upload_id: {
161
- type: "string",
162
- description: "The uploadId returned from pica_audio_presigned_upload",
163
- },
164
- key: {
165
- type: "string",
166
- description: "The storage key returned from pica_audio_presigned_upload",
167
- },
168
- bucket: {
169
- type: "string",
170
- description: "The bucket returned from pica_audio_presigned_upload",
171
- },
172
- filename: {
173
- type: "string",
174
- description: "Original filename",
175
- },
176
- content_type: {
177
- type: "string",
178
- description: "MIME type of the uploaded file",
179
- },
180
- file_size: {
181
- type: "number",
182
- description: "File size in bytes",
183
- },
184
- work_id: {
185
- type: "string",
186
- description: "Optional work ID to link the audio file to",
187
- },
188
- title: {
189
- type: "string",
190
- description: "Optional title for the audio file",
191
- },
192
- file_type: {
193
- type: "string",
194
- description: "Type of audio file (default: 'master')",
195
- enum: ["master", "instrumental", "stem", "demo", "version"],
196
- },
197
- stem_label: {
198
- type: "string",
199
- description: "Label for stem files (e.g. 'vocals', 'drums', 'bass')",
200
- },
201
- version_label: {
202
- type: "string",
203
- description: "Label for version files (e.g. 'radio edit', 'extended mix')",
204
- },
205
- recording_id: {
206
- type: "string",
207
- description: "Link to an existing recording ID instead of auto-creating one",
208
- },
209
- classification: {
210
- type: "string",
211
- description: "Audio classification (e.g. 'original', 'remix', 'cover', 'live')",
212
- },
213
- },
214
- required: [
215
- "upload_id",
216
- "key",
217
- "bucket",
218
- "filename",
219
- "content_type",
220
- "file_size",
221
- ],
222
- },
223
- },
224
- executor: this.completeUpload.bind(this),
225
- },
226
- {
227
- definition: {
228
- name: "pica_audio_identify",
229
- description: "Identify a track using ACRCloud audio fingerprinting. Returns matched metadata (title, artist, album, ISRC, label) with confidence score. If matched, metadata is automatically propagated to the linked work. Costs 3 pica credits on match, 1 on no match. Check pica_credits_balance first.",
230
- inputSchema: {
231
- type: "object",
232
- properties: {
233
- id: {
234
- type: "string",
235
- description: "Audio file ID to identify",
236
- },
237
- force: {
238
- type: "boolean",
239
- description: "Force re-identification even if already matched",
240
- },
241
- },
242
- required: ["id"],
243
- },
244
- },
245
- executor: withCreditGate(this.pica, "analysis_audio_identify", "audio identification", this.identifyAudioFile.bind(this)),
246
- },
247
- ];
248
- }
249
- async queryAudioFiles(args) {
250
- const files = await this.pica.audioFiles.list({
251
- work_id: args.work_id,
252
- file_type: args.file_type,
253
- unprocessed: args.unprocessed,
254
- limit: args.limit,
255
- });
256
- return formatList(files, { total: files.length });
257
- }
258
- async inspectAudioFile(args) {
259
- const sections = args.sections;
260
- const includeAll = !sections || sections.length === 0;
261
- const includeBasic = includeAll || sections.includes("basic");
262
- const includeAnalysis = includeAll || sections.includes("analysis");
263
- const includeStatus = includeAll || sections.includes("status");
264
- const result = {};
265
- // Fetch basic + analysis data from get (they come together)
266
- if (includeBasic || includeAnalysis) {
267
- const file = await this.pica.audioFiles.get(args.id);
268
- if (includeBasic) {
269
- result.basic = {
270
- id: file.id,
271
- work_id: file.work_id,
272
- title: file.title,
273
- filename: file.filename,
274
- file_type: file.file_type,
275
- file_size: file.file_size,
276
- audio_format: file.audio_format,
277
- published: file.published,
278
- created_at: file.created_at,
279
- updated_at: file.updated_at,
280
- };
281
- }
282
- if (includeAnalysis) {
283
- result.analysis = {
284
- duration_seconds: file.duration_seconds,
285
- detected_bpm: file.detected_bpm,
286
- detected_key: file.detected_key,
287
- detected_energy: file.detected_energy,
288
- detected_valence: file.detected_valence,
289
- detected_mood: file.detected_mood,
290
- metadata_extracted: file.metadata_extracted,
291
- };
292
- }
293
- }
294
- // Fetch status separately
295
- if (includeStatus) {
296
- const status = await this.pica.audioFiles.getStatus(args.id);
297
- result.status = status;
298
- }
299
- return formatSuccess("Audio file details", result);
300
- }
301
- async analyzeAudioFile(args) {
302
- const result = await this.pica.audioFiles.analyze(args.id, {
303
- forceReAnalyze: args.force,
304
- enableAudio: args.enable_audio,
305
- enableLyrics: args.enable_lyrics,
306
- });
307
- return formatSuccess(result.message || "Analysis triggered", result.features);
308
- }
309
- async presignedUpload(args) {
310
- const result = await this.pica.audioFiles.presignedUpload({
311
- filename: args.filename,
312
- contentType: args.content_type,
313
- fileSize: args.file_size,
314
- workId: args.work_id,
315
- title: args.title,
316
- fileType: args.file_type,
317
- });
318
- return formatSuccess(`Upload URL generated for "${args.filename}". PUT the file to the uploadUrl, then call pica_audio_complete_upload with the uploadId, key, bucket, and metadata to finalize.`, {
319
- uploadUrl: result.uploadUrl,
320
- uploadId: result.uploadId,
321
- key: result.key,
322
- bucket: result.bucket,
323
- expiresAt: result.expiresAt,
324
- metadata: result.metadata,
325
- });
326
- }
327
- async completeUpload(args) {
328
- const result = await this.pica.audioFiles.completeUpload({
329
- uploadId: args.upload_id,
330
- key: args.key,
331
- bucket: args.bucket,
332
- metadata: {
333
- filename: args.filename,
334
- contentType: args.content_type,
335
- fileSize: args.file_size,
336
- workId: args.work_id,
337
- title: args.title,
338
- fileType: args.file_type,
339
- stemLabel: args.stem_label,
340
- versionLabel: args.version_label,
341
- recordingId: args.recording_id,
342
- classification: args.classification,
343
- },
344
- });
345
- const hints = [
346
- {
347
- gap: "audio_not_analysed",
348
- suggestion: "Run pica_audio_analyze to extract BPM, key, energy, and mood",
349
- severity: "important",
350
- },
351
- {
352
- gap: "audio_not_identified",
353
- suggestion: "Run pica_audio_identify to fingerprint and match against ACRCloud",
354
- severity: "nice_to_have",
355
- },
356
- ];
357
- if (!args.work_id) {
358
- hints.unshift({
359
- gap: "audio_not_linked",
360
- suggestion: "Link this audio file to a work",
361
- severity: "critical",
362
- });
363
- }
364
- return formatSuccess(`Upload finalized. Audio file created with ID: ${result.audioFileId}.`, result, hints);
365
- }
366
- async identifyAudioFile(args) {
367
- const result = await this.pica.audioFiles.identify(args.id, {
368
- force: args.force,
369
- });
370
- if (result.alreadyIdentified) {
371
- return formatSuccess("Already identified — no credits charged. Use force: true to re-identify.", result);
372
- }
373
- else if (result.status === "matched" && result.match) {
374
- return formatSuccess(`Match found: "${result.match.title}" by ${result.match.artist} (confidence: ${Math.round((result.match.confidence || 0) * 100)}%). ISRC: ${result.match.isrc || "unknown"}. If the file is linked to a work, metadata has been propagated.`, result);
375
- }
376
- else if (result.status === "no_match") {
377
- return formatSuccess("No match found in ACRCloud database. This may be an unreleased or very rare track.", result);
378
- }
379
- else {
380
- return formatAsText(result);
381
- }
382
- }
383
- }
384
- //# sourceMappingURL=audio-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audio-files.js","sourceRoot":"","sources":["../../src/tools/audio-files.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAQ7D,OAAO,EACL,YAAY,EACZ,UAAU,EACV,aAAa,GAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,eAAe;IAClB,IAAI,CAAa;IAEzB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAA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,CAAC,KAAK,CAAC,IAAI,IAAI,SAAS,kEAAkE,EAC5O,MAAM,CACP,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACxC,OAAO,aAAa,CAClB,oFAAoF,EACpF,MAAM,CACP,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Auth Tools — pica_sign_in and pica_sign_out
3
- * Available in lobby mode (no API key required).
4
- */
5
- import { ToolDefinition, ToolExecutor } from "./index.js";
6
- import { ServerConfig } from "../config.js";
7
- type ReinitializeCallback = (apiKey: string) => void;
8
- type SignOutCallback = () => void;
9
- export declare class AuthTools {
10
- private config;
11
- private reinitialize;
12
- private signOutCallback;
13
- constructor(config: ServerConfig, reinitialize: ReinitializeCallback, signOutCallback?: SignOutCallback);
14
- getTools(): Array<{
15
- definition: ToolDefinition;
16
- executor: ToolExecutor;
17
- }>;
18
- private signIn;
19
- private signOut;
20
- }
21
- export {};
22
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO5C,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AACrD,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAKlC,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,eAAe,CAAkB;gBAGvC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,oBAAoB,EAClC,eAAe,GAAE,eAA0B;IAO7C,QAAQ,IAAI,KAAK,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAA;KAAE,CAAC;YAmC3D,MAAM;YAyKN,OAAO;CAwBtB"}
@@ -1,210 +0,0 @@
1
- // Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
2
- import { writeCredentials, clearCredentials, } from "@withpica/mcp-utils";
3
- const POLL_INTERVAL_MS = 3000;
4
- const POLL_TIMEOUT_MS = 5 * 60 * 1000;
5
- export class AuthTools {
6
- config;
7
- reinitialize;
8
- signOutCallback;
9
- constructor(config, reinitialize, signOutCallback = () => { }) {
10
- this.config = config;
11
- this.reinitialize = reinitialize;
12
- this.signOutCallback = signOutCallback;
13
- }
14
- getTools() {
15
- return [
16
- {
17
- definition: {
18
- name: "pica_sign_in",
19
- description: "sign in to PICA with your email — sends a magic link to your inbox. " +
20
- "use this to connect your music catalog. no API key needed.",
21
- inputSchema: {
22
- type: "object",
23
- properties: {
24
- email: {
25
- type: "string",
26
- description: "your email address",
27
- },
28
- },
29
- required: ["email"],
30
- },
31
- },
32
- executor: this.signIn.bind(this),
33
- },
34
- {
35
- definition: {
36
- name: "pica_sign_out",
37
- description: "sign out of PICA — clears your saved credentials",
38
- inputSchema: {
39
- type: "object",
40
- properties: {},
41
- },
42
- },
43
- executor: this.signOut.bind(this),
44
- },
45
- ];
46
- }
47
- async signIn(args) {
48
- const email = args.email?.trim()?.toLowerCase();
49
- if (!email || !email.includes("@") || !email.includes(".")) {
50
- return {
51
- content: [
52
- {
53
- type: "text",
54
- text: "that doesn't look like an email address — please try again",
55
- },
56
- ],
57
- isError: true,
58
- };
59
- }
60
- const apiUrl = this.config.picaApiUrl.replace(/\/api$/, "");
61
- const authorizeUrl = `${apiUrl}/api/public/mcp-auth/authorize`;
62
- const tokenUrl = `${apiUrl}/api/public/mcp-auth/token`;
63
- // Step 1: Request magic link
64
- let deviceCode;
65
- let interval;
66
- try {
67
- const res = await fetch(authorizeUrl, {
68
- method: "POST",
69
- headers: { "Content-Type": "application/json" },
70
- body: JSON.stringify({ email }),
71
- });
72
- if (res.status === 429) {
73
- return {
74
- content: [
75
- {
76
- type: "text",
77
- text: "too many sign-in attempts — try again in an hour",
78
- },
79
- ],
80
- isError: true,
81
- };
82
- }
83
- if (!res.ok) {
84
- return {
85
- content: [
86
- {
87
- type: "text",
88
- text: "failed to send magic link — please try again",
89
- },
90
- ],
91
- isError: true,
92
- };
93
- }
94
- const data = (await res.json());
95
- deviceCode = data.device_code;
96
- interval = (data.interval || 3) * 1000;
97
- console.error(`[MCP Auth] Magic link sent to ${email}`);
98
- }
99
- catch {
100
- return {
101
- content: [
102
- {
103
- type: "text",
104
- text: "couldn't reach PICA — check your internet connection and try again",
105
- },
106
- ],
107
- isError: true,
108
- };
109
- }
110
- // Step 2: Poll for token
111
- const startTime = Date.now();
112
- while (Date.now() - startTime < POLL_TIMEOUT_MS) {
113
- await new Promise((resolve) => setTimeout(resolve, interval));
114
- try {
115
- const res = await fetch(tokenUrl, {
116
- method: "POST",
117
- headers: { "Content-Type": "application/json" },
118
- body: JSON.stringify({
119
- device_code: deviceCode,
120
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
121
- }),
122
- });
123
- const data = (await res.json());
124
- if (data.error === "authorization_pending") {
125
- continue;
126
- }
127
- if (data.error === "expired_token") {
128
- return {
129
- content: [
130
- {
131
- type: "text",
132
- text: "magic link expired — say 'sign me in' to try again",
133
- },
134
- ],
135
- isError: true,
136
- };
137
- }
138
- if (data.access_token) {
139
- const credentials = {
140
- api_key: data.access_token,
141
- email,
142
- org_name: data.org_name || "my catalog",
143
- authenticated_at: new Date().toISOString(),
144
- };
145
- writeCredentials(this.config.credentialsPath, credentials);
146
- this.reinitialize(data.access_token);
147
- console.error(`[MCP Auth] Signed in as ${email}`);
148
- if (data.is_new_user) {
149
- return {
150
- content: [
151
- {
152
- type: "text",
153
- text: `welcome to PICA, ${email}. you're all signed in.\n\n` +
154
- `quick first thing — your workspace is currently named "My Organization" (the boring default). want to give it a real name? it'll appear on exports, share links, and anywhere else your catalog shows up. just tell me what to call it, or say "skip" to set it later.\n\n` +
155
- `after that, we can:\n` +
156
- `- add your first song manually\n` +
157
- `- import an existing catalog from a CSV\n` +
158
- `- connect Spotify and pull your discography automatically\n\n` +
159
- `what works for you?`,
160
- },
161
- ],
162
- };
163
- }
164
- return {
165
- content: [
166
- {
167
- type: "text",
168
- text: `signed in as ${email} (${data.org_name || "my catalog"}).\n\n` +
169
- `all tools are now available. try "what needs attention?" to see your catalog status.`,
170
- },
171
- ],
172
- };
173
- }
174
- }
175
- catch {
176
- continue;
177
- }
178
- }
179
- return {
180
- content: [
181
- {
182
- type: "text",
183
- text: "magic link expired — say 'sign me in' to try again",
184
- },
185
- ],
186
- isError: true,
187
- };
188
- }
189
- async signOut(_args) {
190
- clearCredentials(this.config.credentialsPath);
191
- // Reset the server back to lobby mode: clear PicaClient, rebuild
192
- // toolRegistry/resourceRegistry so the next tools/list call returns
193
- // only [pica_sign_in, pica_sign_out]. Without this the client keeps
194
- // seeing the full authenticated tool surface until the process is
195
- // restarted, which would let an "ex-signed-out" client still call
196
- // privileged tools (the calls would fail at the API layer, but the
197
- // surface area itself shouldn't lie about what's available).
198
- this.signOutCallback();
199
- console.error("[MCP Auth] Signed out — credentials cleared, lobby restored");
200
- return {
201
- content: [
202
- {
203
- type: "text",
204
- text: "signed out of PICA. say 'sign me in' to reconnect.",
205
- },
206
- ],
207
- };
208
- }
209
- }
210
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAS7D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAK7B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtC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e,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CACX,6DAA6D,CAC9D,CAAC;QAEF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,oDAAoD;iBAC3D;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Bulk Operations Tools - MCP tools for batch updates
3
- */
4
- import { PicaClient } from "@withpica/mcp-sdk";
5
- import { ToolDefinition, ToolExecutor } from "./index.js";
6
- export declare class BulkTools {
7
- private pica;
8
- constructor(pica: PicaClient);
9
- getTools(): Array<{
10
- definition: ToolDefinition;
11
- executor: ToolExecutor;
12
- }>;
13
- private bulkUpdateWorks;
14
- private bulkUpdatePeopleRoles;
15
- }
16
- //# sourceMappingURL=bulk.d.ts.map