@withpica/mcp-server-directory 1.0.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 (53) hide show
  1. package/dist/client.d.ts +12 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +92 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/config.d.ts +9 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +14 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +27 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/prompts/index.d.ts +32 -0
  14. package/dist/prompts/index.d.ts.map +1 -0
  15. package/dist/prompts/index.js +168 -0
  16. package/dist/prompts/index.js.map +1 -0
  17. package/dist/resources/llms-primer.d.ts +2 -0
  18. package/dist/resources/llms-primer.d.ts.map +1 -0
  19. package/dist/resources/llms-primer.js +34 -0
  20. package/dist/resources/llms-primer.js.map +1 -0
  21. package/dist/server.d.ts +13 -0
  22. package/dist/server.d.ts.map +1 -0
  23. package/dist/server.js +103 -0
  24. package/dist/server.js.map +1 -0
  25. package/dist/tools/index.d.ts +26 -0
  26. package/dist/tools/index.d.ts.map +1 -0
  27. package/dist/tools/index.js +42 -0
  28. package/dist/tools/index.js.map +1 -0
  29. package/dist/tools/people.d.ts +14 -0
  30. package/dist/tools/people.d.ts.map +1 -0
  31. package/dist/tools/people.js +189 -0
  32. package/dist/tools/people.js.map +1 -0
  33. package/dist/tools/recordings.d.ts +12 -0
  34. package/dist/tools/recordings.d.ts.map +1 -0
  35. package/dist/tools/recordings.js +140 -0
  36. package/dist/tools/recordings.js.map +1 -0
  37. package/dist/tools/search.d.ts +12 -0
  38. package/dist/tools/search.d.ts.map +1 -0
  39. package/dist/tools/search.js +52 -0
  40. package/dist/tools/search.js.map +1 -0
  41. package/dist/tools/works.d.ts +15 -0
  42. package/dist/tools/works.d.ts.map +1 -0
  43. package/dist/tools/works.js +248 -0
  44. package/dist/tools/works.js.map +1 -0
  45. package/dist/utils/errors.d.ts +14 -0
  46. package/dist/utils/errors.d.ts.map +1 -0
  47. package/dist/utils/errors.js +47 -0
  48. package/dist/utils/errors.js.map +1 -0
  49. package/dist/utils/formatting.d.ts +10 -0
  50. package/dist/utils/formatting.d.ts.map +1 -0
  51. package/dist/utils/formatting.js +15 -0
  52. package/dist/utils/formatting.js.map +1 -0
  53. package/package.json +34 -0
@@ -0,0 +1,248 @@
1
+ import { formatAsText, formatStructuredList } from "../utils/formatting.js";
2
+ export class DirectoryWorksTools {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ getTools() {
8
+ return [
9
+ {
10
+ definition: {
11
+ name: "directory_list_works",
12
+ description: "Browse and filter verified musical works in the PICA public directory. " +
13
+ "Search by title, ISWC, publisher, or label. Returns paginated results. " +
14
+ "→ then: directory_lookup_work_full (full details with credits and audio)",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ q: {
19
+ type: "string",
20
+ description: "Text search across work titles and identifiers",
21
+ },
22
+ iswc: {
23
+ type: "string",
24
+ description: "Filter by ISWC (e.g. T-123.456.789-0)",
25
+ },
26
+ publisher: {
27
+ type: "string",
28
+ description: "Filter by publisher name (partial match)",
29
+ },
30
+ label: {
31
+ type: "string",
32
+ description: "Filter by record label (partial match)",
33
+ },
34
+ page: {
35
+ type: "number",
36
+ description: "Page number (default: 1, 20 results per page)",
37
+ },
38
+ },
39
+ },
40
+ },
41
+ executor: this.listWorks.bind(this),
42
+ },
43
+ {
44
+ definition: {
45
+ name: "directory_lookup_work",
46
+ description: "Get full details of a single work by ISWC or work ID. " +
47
+ "Returns credits, recordings, attestation status, provenance, DSP links, and carbon badge. " +
48
+ "→ then: directory_lookup_work_full (agent-optimised markdown), directory_lookup_person_full (inspect a credited writer)",
49
+ inputSchema: {
50
+ type: "object",
51
+ properties: {
52
+ identifier: {
53
+ type: "string",
54
+ description: "ISWC (e.g. T-123.456.789-0) or work UUID",
55
+ },
56
+ },
57
+ required: ["identifier"],
58
+ },
59
+ },
60
+ executor: this.lookupWork.bind(this),
61
+ },
62
+ {
63
+ definition: {
64
+ name: "directory_lookup_work_full",
65
+ description: "Get complete details about a work in the public directory — credits with IPI numbers and attestation status, " +
66
+ "recordings with ISRCs, audio analysis (BPM, key, energy), DSP links (Spotify, Apple Music), " +
67
+ "AI provenance, and registration score. Returns a structured markdown summary optimised for agent reasoning. " +
68
+ "→ then: directory_lookup_person_full (research a credited writer), directory_search_recordings (find similar tracks by audio)",
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {
72
+ identifier: {
73
+ type: "string",
74
+ description: "ISWC (e.g. T-123.456.789-0) or work UUID",
75
+ },
76
+ },
77
+ required: ["identifier"],
78
+ },
79
+ },
80
+ executor: this.lookupWorkFull.bind(this),
81
+ },
82
+ {
83
+ definition: {
84
+ name: "directory_lookup_isrc",
85
+ description: "Find musical work(s) associated with an ISRC code. " +
86
+ "ISRC identifies a specific recording; this returns the underlying work(s). " +
87
+ "→ then: directory_lookup_work_full (full details on matched work)",
88
+ inputSchema: {
89
+ type: "object",
90
+ properties: {
91
+ isrc: {
92
+ type: "string",
93
+ description: "ISRC code (e.g. USABC1234567)",
94
+ },
95
+ },
96
+ required: ["isrc"],
97
+ },
98
+ },
99
+ executor: this.lookupIsrc.bind(this),
100
+ },
101
+ ];
102
+ }
103
+ async listWorks(args) {
104
+ const page = Math.max(args.page || 1, 1);
105
+ const limit = 20;
106
+ const offset = (page - 1) * limit;
107
+ const params = {
108
+ limit: String(limit),
109
+ offset: String(offset),
110
+ };
111
+ if (args.q)
112
+ params.q = args.q;
113
+ if (args.iswc)
114
+ params.iswc = args.iswc;
115
+ if (args.publisher)
116
+ params.publisher = args.publisher;
117
+ if (args.label)
118
+ params.label = args.label;
119
+ const response = await this.client.request("/works", params);
120
+ return formatStructuredList(response.data || [], "work", {
121
+ page,
122
+ total: response.pagination?.total || 0,
123
+ total_pages: Math.ceil((response.pagination?.total || 0) / limit),
124
+ });
125
+ }
126
+ async lookupWork(args) {
127
+ const response = await this.client.request(`/works/${encodeURIComponent(args.identifier)}`);
128
+ return formatAsText(response.data);
129
+ }
130
+ async lookupWorkFull(args) {
131
+ const response = await this.client.request(`/works/${encodeURIComponent(args.identifier)}`);
132
+ const data = response.data;
133
+ if (!data) {
134
+ return {
135
+ content: [{ type: "text", text: "Work not found." }],
136
+ structuredContent: {},
137
+ };
138
+ }
139
+ const lines = [];
140
+ // Title + artist
141
+ const artistName = data.artist_name || data.primary_artist || "";
142
+ lines.push(`## ${data.title}${artistName ? ` by ${artistName}` : ""}`);
143
+ lines.push("");
144
+ // Key metadata line
145
+ const metaParts = [];
146
+ if (data.iswc)
147
+ metaParts.push(`**ISWC:** ${data.iswc}`);
148
+ if (data.organisation_name)
149
+ metaParts.push(`**Organisation:** ${data.organisation_name}`);
150
+ if (metaParts.length > 0)
151
+ lines.push(metaParts.join(" | "));
152
+ // Score
153
+ if (data.score !== undefined && data.score !== null) {
154
+ const tier = data.score >= 80
155
+ ? "verified"
156
+ : data.score >= 50
157
+ ? "partial"
158
+ : "incomplete";
159
+ lines.push(`- **Score:** ${data.score}/100 (${tier})`);
160
+ }
161
+ lines.push("");
162
+ // Credits
163
+ const credits = data.credits || [];
164
+ lines.push(`### Credits (${credits.length})`);
165
+ if (credits.length > 0) {
166
+ lines.push("| Role | Name | IPI | Attestation |");
167
+ lines.push("| --- | --- | --- | --- |");
168
+ for (const c of credits) {
169
+ const role = c.role || c.credit_role || "—";
170
+ const name = c.name || c.person_name || "—";
171
+ const ipi = c.ipi || c.ipi_number || "—";
172
+ const attestation = c.attestation_status || c.attestation || "—";
173
+ lines.push(`| ${role} | ${name} | ${ipi} | ${attestation} |`);
174
+ }
175
+ }
176
+ else {
177
+ lines.push("_No credits recorded._");
178
+ }
179
+ lines.push("");
180
+ // Recordings
181
+ const recordings = data.recordings || [];
182
+ lines.push(`### Recordings (${recordings.length})`);
183
+ if (recordings.length > 0) {
184
+ lines.push("| ISRC | Type |");
185
+ lines.push("| --- | --- |");
186
+ for (const r of recordings) {
187
+ const isrc = r.isrc || "—";
188
+ const type = r.recording_type || r.type || "—";
189
+ lines.push(`| ${isrc} | ${type} |`);
190
+ }
191
+ }
192
+ else {
193
+ lines.push("_No recordings linked._");
194
+ }
195
+ lines.push("");
196
+ // Audio analysis
197
+ const audio = data.audio_analysis || data.audio || null;
198
+ if (audio) {
199
+ lines.push("### Audio");
200
+ const audioParts = [];
201
+ if (audio.bpm !== undefined && audio.bpm !== null)
202
+ audioParts.push(`**BPM:** ${audio.bpm}`);
203
+ if (audio.key)
204
+ audioParts.push(`**Key:** ${audio.key}`);
205
+ if (audio.energy !== undefined && audio.energy !== null)
206
+ audioParts.push(`**Energy:** ${audio.energy}`);
207
+ if (audioParts.length > 0) {
208
+ lines.push(`- ${audioParts.join(" | ")}`);
209
+ }
210
+ lines.push("");
211
+ }
212
+ // DSP links
213
+ const dsp = data.dsp_links || data.streaming_links || null;
214
+ if (dsp && typeof dsp === "object" && Object.keys(dsp).length > 0) {
215
+ lines.push("### DSP Links");
216
+ if (dsp.spotify)
217
+ lines.push(`- Spotify: ${dsp.spotify}`);
218
+ if (dsp.apple_music)
219
+ lines.push(`- Apple Music: ${dsp.apple_music}`);
220
+ if (dsp.youtube)
221
+ lines.push(`- YouTube: ${dsp.youtube}`);
222
+ // catch any other keys
223
+ for (const [key, val] of Object.entries(dsp)) {
224
+ if (!["spotify", "apple_music", "youtube"].includes(key) && val) {
225
+ lines.push(`- ${key}: ${val}`);
226
+ }
227
+ }
228
+ lines.push("");
229
+ }
230
+ const markdown = lines.join("\n");
231
+ return {
232
+ content: [{ type: "text", text: markdown }],
233
+ structuredContent: data,
234
+ };
235
+ }
236
+ async lookupIsrc(args) {
237
+ const response = await this.client.request("/works", {
238
+ isrc: args.isrc,
239
+ limit: "100",
240
+ offset: "0",
241
+ });
242
+ return formatStructuredList(response.data || [], "work", {
243
+ isrc: args.isrc,
244
+ total: response.pagination?.total || 0,
245
+ });
246
+ }
247
+ }
248
+ //# sourceMappingURL=works.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"works.js","sourceRoot":"","sources":["../../src/tools/works.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAkB;IAEhC,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,OAAO;YACL;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,sBAAsB;oBAC5B,WAAW,EACT,yEAAyE;wBACzE,yEAAyE;wBACzE,0EAA0E;oBAC5E,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,CAAC,EAAE;gCACD,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,gDAAgD;6BAC9D;4BACD,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,uCAAuC;6BACrD;4BACD,SAAS,EAAE;gCACT,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,0CAA0C;6BACxD;4BACD,KAAK,EAAE;gCACL,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,wCAAwC;6BACtD;4BACD,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,WAAW,EAAE,+CAA+C;6BAC7D;yBACF;qBACF;iBACF;gBACD,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;aACpC;YACD;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,uBAAuB;oBAC7B,WAAW,EACT,wDAAwD;wBACxD,4FAA4F;wBAC5F,yHAAyH;oBAC3H,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,UAAU,EAAE;gCACV,IAAI,E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AC,CAAC;QAElC,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3C,iBAAiB,EAAE,IAA+B;SACnD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,IAAyB;QAChD,MAAM,QAAQ,GAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YACxD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,GAAG;SACZ,CAAC,CAAC;QAEH,OAAO,oBAAoB,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE;YACvD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export declare class McpServerError extends Error {
2
+ code: string;
3
+ details?: any | undefined;
4
+ constructor(message: string, code: string, details?: any | undefined);
5
+ }
6
+ export declare class ToolExecutionError extends McpServerError {
7
+ constructor(message: string, details?: any);
8
+ }
9
+ export declare function formatError(error: any): {
10
+ type: string;
11
+ text: string;
12
+ };
13
+ export declare function logError(context: string, error: any): void;
14
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IAG9B,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,GAAG;gBAFpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,GAAG,YAAA;CAMvB;AAED,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA+BtE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAS1D"}
@@ -0,0 +1,47 @@
1
+ export class McpServerError extends Error {
2
+ code;
3
+ details;
4
+ constructor(message, code, details) {
5
+ super(message);
6
+ this.code = code;
7
+ this.details = details;
8
+ this.name = "McpServerError";
9
+ Object.setPrototypeOf(this, McpServerError.prototype);
10
+ }
11
+ }
12
+ export class ToolExecutionError extends McpServerError {
13
+ constructor(message, details) {
14
+ super(message, "TOOL_EXECUTION_ERROR", details);
15
+ this.name = "ToolExecutionError";
16
+ }
17
+ }
18
+ export function formatError(error) {
19
+ if (error instanceof McpServerError) {
20
+ return {
21
+ type: "text",
22
+ text: JSON.stringify({ error: error.code, message: error.message, details: error.details }, null, 2),
23
+ };
24
+ }
25
+ if (error instanceof Error) {
26
+ return {
27
+ type: "text",
28
+ text: JSON.stringify({ error: "UNKNOWN_ERROR", message: error.message }, null, 2),
29
+ };
30
+ }
31
+ return {
32
+ type: "text",
33
+ text: JSON.stringify({ error: "UNKNOWN_ERROR", message: String(error) }, null, 2),
34
+ };
35
+ }
36
+ export function logError(context, error) {
37
+ const entry = {
38
+ level: "error",
39
+ context,
40
+ message: error instanceof Error ? error.message : String(error),
41
+ timestamp: new Date().toISOString(),
42
+ };
43
+ if (error instanceof Error && error.stack)
44
+ entry.stack = error.stack;
45
+ console.error(JSON.stringify(entry));
46
+ }
47
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAG9B;IACA;IAHT,YACE,OAAe,EACR,IAAY,EACZ,OAAa;QAEpB,KAAK,CAAC,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GAA4B;QACrC,KAAK,EAAE,OAAO;QACd,OAAO;QACP,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IACF,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACrE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface FormattedResult {
2
+ content: Array<{
3
+ type: string;
4
+ text: string;
5
+ }>;
6
+ structuredContent?: Record<string, unknown>;
7
+ }
8
+ export declare function formatAsText(data: any): FormattedResult;
9
+ export declare function formatStructuredList<T>(items: T[], entityName: string, metadata?: Record<string, any>): FormattedResult;
10
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,eAAe,CAKvD;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,EAAE,EACV,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,eAAe,CASjB"}
@@ -0,0 +1,15 @@
1
+ export function formatAsText(data) {
2
+ return {
3
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
4
+ structuredContent: data,
5
+ };
6
+ }
7
+ export function formatStructuredList(items, entityName, metadata) {
8
+ const count = items.length;
9
+ const summary = `Found ${count} ${entityName}${count !== 1 ? "s" : ""}${metadata?.query ? ` matching "${metadata.query}"` : ""}.`;
10
+ return {
11
+ content: [{ type: "text", text: summary }],
12
+ structuredContent: { count, items, ...metadata },
13
+ };
14
+ }
15
+ //# sourceMappingURL=formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAAC,IAAS;IACpC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAChE,iBAAiB,EAAE,IAA+B;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,KAAU,EACV,UAAkB,EAClB,QAA8B;IAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3B,MAAM,OAAO,GAAG,SAAS,KAAK,IAAI,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GACnE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,cAAc,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EACtD,GAAG,CAAC;IACJ,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC1C,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,EAA6B;KAC5E,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@withpica/mcp-server-directory",
3
+ "version": "1.0.0",
4
+ "description": "MCP Server for PICA Public Directory — enables AI assistants to search verified works and creators",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "pica-directory-mcp": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsx src/index.ts",
13
+ "start": "node dist/index.js",
14
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
15
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
16
+ "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage"
17
+ },
18
+ "author": "PICA Platform",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.0.4"
22
+ },
23
+ "devDependencies": {
24
+ "@types/jest": "^29.5.14",
25
+ "@types/node": "^20.10.0",
26
+ "jest": "^29.7.0",
27
+ "ts-jest": "^29.4.5",
28
+ "tsx": "^4.7.0",
29
+ "typescript": "^5.3.3"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ }
34
+ }