@withpica/mcp-server-directory 1.2.0 → 1.4.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.
- package/CHANGELOG.md +28 -0
- package/dist/lib/changelog.d.ts +16 -0
- package/dist/lib/changelog.d.ts.map +1 -0
- package/dist/lib/changelog.generated.d.ts +4 -0
- package/dist/lib/changelog.generated.d.ts.map +1 -0
- package/dist/lib/changelog.generated.js +6 -0
- package/dist/lib/changelog.generated.js.map +1 -0
- package/dist/lib/changelog.js +84 -0
- package/dist/lib/changelog.js.map +1 -0
- package/dist/prompts/public-question-atlas.d.ts.map +1 -1
- package/dist/prompts/public-question-atlas.js +30 -0
- package/dist/prompts/public-question-atlas.js.map +1 -1
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +129 -10
- package/dist/server.js.map +1 -1
- package/dist/skills/index.d.ts +32 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +50 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skills.generated.d.ts +18 -0
- package/dist/skills/skills.generated.d.ts.map +1 -0
- package/dist/skills/skills.generated.js +14 -0
- package/dist/skills/skills.generated.js.map +1 -0
- package/dist/tools/__tests__/release-notes.test.d.ts +2 -0
- package/dist/tools/__tests__/release-notes.test.d.ts.map +1 -0
- package/dist/tools/__tests__/release-notes.test.js +49 -0
- package/dist/tools/__tests__/release-notes.test.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/release-notes.d.ts +22 -0
- package/dist/tools/release-notes.d.ts.map +1 -0
- package/dist/tools/release-notes.js +102 -0
- package/dist/tools/release-notes.js.map +1 -0
- package/dist/tools/skills.d.ts +19 -0
- package/dist/tools/skills.d.ts.map +1 -0
- package/dist/tools/skills.js +127 -0
- package/dist/tools/skills.js.map +1 -0
- package/package.json +4 -2
- package/scripts/build-changelog.ts +25 -0
- package/scripts/build-skills.ts +192 -0
- package/src/__tests__/skills/skills-registry.test.ts +63 -0
- package/src/__tests__/skills/skills-tools.test.ts +74 -0
- package/src/lib/changelog.ts +119 -0
- package/src/prompts/public-question-atlas.ts +36 -10
- package/src/server.ts +142 -11
- package/src/skills/find-music-for-sync-brief/SKILL.md +89 -0
- package/src/skills/index.ts +63 -0
- package/src/skills/skills.generated.ts +33 -0
- package/src/tools/__tests__/release-notes.test.ts +62 -0
- package/src/tools/index.ts +5 -0
- package/src/tools/release-notes.ts +148 -0
- package/src/tools/skills.ts +146 -0
package/src/server.ts
CHANGED
|
@@ -16,13 +16,21 @@ import { ToolRegistry } from "./tools/index.js";
|
|
|
16
16
|
import { PromptRegistry } from "./prompts/index.js";
|
|
17
17
|
import { logError } from "./utils/errors.js";
|
|
18
18
|
import { DIRECTORY_PRIMER } from "./resources/llms-primer.js";
|
|
19
|
+
import { CHANGELOG_MD } from "./lib/changelog.generated.js";
|
|
20
|
+
import { SkillsRegistry } from "./skills/index.js";
|
|
19
21
|
|
|
20
22
|
export class DirectoryMcpServer {
|
|
21
23
|
private server: Server;
|
|
22
24
|
private client: DirectoryClient;
|
|
23
25
|
private toolRegistry: ToolRegistry;
|
|
24
26
|
private promptRegistry: PromptRegistry;
|
|
27
|
+
private skillsRegistry: SkillsRegistry;
|
|
25
28
|
private config: ServerConfig;
|
|
29
|
+
// Logged once after the MCP `initialize` handshake completes so each
|
|
30
|
+
// session prints a single client-attribution breadcrumb to stderr
|
|
31
|
+
// (Railway logs / Sentry breadcrumbs). Directory MCP has no DB audit
|
|
32
|
+
// pipeline today; this is provenance-only.
|
|
33
|
+
private clientAttributionLogged = false;
|
|
26
34
|
|
|
27
35
|
constructor(config: ServerConfig) {
|
|
28
36
|
this.config = config;
|
|
@@ -48,6 +56,7 @@ export class DirectoryMcpServer {
|
|
|
48
56
|
|
|
49
57
|
this.toolRegistry = new ToolRegistry(this.client);
|
|
50
58
|
this.promptRegistry = new PromptRegistry();
|
|
59
|
+
this.skillsRegistry = new SkillsRegistry();
|
|
51
60
|
this.setupHandlers();
|
|
52
61
|
}
|
|
53
62
|
|
|
@@ -60,17 +69,43 @@ export class DirectoryMcpServer {
|
|
|
60
69
|
});
|
|
61
70
|
|
|
62
71
|
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const resources: Array<{
|
|
73
|
+
uri: string;
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
mimeType: string;
|
|
77
|
+
}> = [
|
|
78
|
+
{
|
|
79
|
+
uri: "llms://primer",
|
|
80
|
+
name: "PICA Domain Primer",
|
|
81
|
+
description:
|
|
82
|
+
"Plain-language description of PICA's domain model, entity relationships, and recommended agent workflows. Read this first.",
|
|
83
|
+
mimeType: "text/markdown",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
uri: "skill://withpica/index.json",
|
|
87
|
+
name: "PICA Directory Skills Index",
|
|
88
|
+
description:
|
|
89
|
+
"Enumeration of downloadable directory skill methodologies (SEP-2640 bridge). Each entry maps a kebab-case name to its skill:// URI, description, and trigger phrases.",
|
|
90
|
+
mimeType: "application/json",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
uri: "release-notes://withpica/mcp-server-directory/latest",
|
|
94
|
+
name: "Release Notes — @withpica/mcp-server-directory",
|
|
95
|
+
description:
|
|
96
|
+
"Full CHANGELOG.md for the PICA directory MCP server. For just the last few releases, agents can call directory_release_notes.",
|
|
97
|
+
mimeType: "text/markdown",
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
for (const summary of this.skillsRegistry.listSkills()) {
|
|
101
|
+
resources.push({
|
|
102
|
+
uri: `skill://withpica/${summary.name}/SKILL.md`,
|
|
103
|
+
name: `Skill — ${summary.name}`,
|
|
104
|
+
description: summary.description,
|
|
105
|
+
mimeType: "text/markdown",
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return { resources };
|
|
74
109
|
});
|
|
75
110
|
|
|
76
111
|
this.server.setRequestHandler(
|
|
@@ -88,6 +123,20 @@ export class DirectoryMcpServer {
|
|
|
88
123
|
],
|
|
89
124
|
};
|
|
90
125
|
}
|
|
126
|
+
if (uri === "release-notes://withpica/mcp-server-directory/latest") {
|
|
127
|
+
return {
|
|
128
|
+
contents: [
|
|
129
|
+
{
|
|
130
|
+
uri,
|
|
131
|
+
mimeType: "text/markdown",
|
|
132
|
+
text: CHANGELOG_MD,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (uri.startsWith("skill://withpica/")) {
|
|
138
|
+
return this.readSkillResource(uri);
|
|
139
|
+
}
|
|
91
140
|
throw new Error(`Resource not found: ${uri}`);
|
|
92
141
|
},
|
|
93
142
|
);
|
|
@@ -104,6 +153,8 @@ export class DirectoryMcpServer {
|
|
|
104
153
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
105
154
|
const { name, arguments: args } = request.params;
|
|
106
155
|
|
|
156
|
+
this.logClientAttributionOnce();
|
|
157
|
+
|
|
107
158
|
if (this.config.debug) {
|
|
108
159
|
console.error(`[Directory MCP] Executing tool: ${name}`, args);
|
|
109
160
|
}
|
|
@@ -117,6 +168,86 @@ export class DirectoryMcpServer {
|
|
|
117
168
|
});
|
|
118
169
|
}
|
|
119
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Emit a single stderr line per session naming the client that handshook
|
|
173
|
+
* with us — sourced from `clientInfo` on the MCP `initialize` request.
|
|
174
|
+
* Self-declared, NOT authenticated; treat as provenance metadata only.
|
|
175
|
+
*
|
|
176
|
+
* Directory MCP is unauthenticated and writes no audit rows, so this
|
|
177
|
+
* stderr breadcrumb is the only attribution surface today. When/if a
|
|
178
|
+
* directory audit pipeline lands, fold these values into McpAuditEntry
|
|
179
|
+
* (the wire shape already carries optional client_name + client_version).
|
|
180
|
+
*/
|
|
181
|
+
private logClientAttributionOnce(): void {
|
|
182
|
+
if (this.clientAttributionLogged) return;
|
|
183
|
+
const info = this.server.getClientVersion?.();
|
|
184
|
+
if (!info) return;
|
|
185
|
+
this.clientAttributionLogged = true;
|
|
186
|
+
console.error(
|
|
187
|
+
`[Directory MCP] client: ${info.name ?? "unknown"} v${info.version ?? "unknown"}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Resolve a skill:// URI. ADR-140 Phase 2b — SEP-2640 bridge pattern.
|
|
193
|
+
* Two URI shapes:
|
|
194
|
+
* - skill://withpica/index.json
|
|
195
|
+
* - skill://withpica/<name>/SKILL.md
|
|
196
|
+
*/
|
|
197
|
+
private readSkillResource(uri: string): {
|
|
198
|
+
contents: Array<{ uri: string; mimeType: string; text: string }>;
|
|
199
|
+
} {
|
|
200
|
+
if (uri === "skill://withpica/index.json") {
|
|
201
|
+
const index = this.skillsRegistry.listSkills().map((s) => ({
|
|
202
|
+
name: s.name,
|
|
203
|
+
uri: `skill://withpica/${s.name}/SKILL.md`,
|
|
204
|
+
description: s.description,
|
|
205
|
+
triggers: s.triggers,
|
|
206
|
+
audience: s.audience,
|
|
207
|
+
}));
|
|
208
|
+
return {
|
|
209
|
+
contents: [
|
|
210
|
+
{
|
|
211
|
+
uri,
|
|
212
|
+
mimeType: "application/json",
|
|
213
|
+
text: JSON.stringify({ skills: index }, null, 2),
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const match = uri.match(/^skill:\/\/withpica\/([a-z0-9-]+)\/SKILL\.md$/);
|
|
219
|
+
if (!match) {
|
|
220
|
+
throw new Error(`Malformed skill URI: ${uri}`);
|
|
221
|
+
}
|
|
222
|
+
const name = match[1];
|
|
223
|
+
if (!this.skillsRegistry.has(name)) {
|
|
224
|
+
throw new Error(`Skill not found: ${name}`);
|
|
225
|
+
}
|
|
226
|
+
const skill = this.skillsRegistry.getSkill(name);
|
|
227
|
+
const frontmatter = [
|
|
228
|
+
"---",
|
|
229
|
+
`name: ${skill.name}`,
|
|
230
|
+
`description: ${skill.description}`,
|
|
231
|
+
"triggers:",
|
|
232
|
+
...skill.triggers.map((t) => ` - ${t}`),
|
|
233
|
+
`audience: ${skill.audience}`,
|
|
234
|
+
"tools_required:",
|
|
235
|
+
...skill.tools_required.map((t) => ` - ${t}`),
|
|
236
|
+
`output: ${skill.output}`,
|
|
237
|
+
"---",
|
|
238
|
+
"",
|
|
239
|
+
].join("\n");
|
|
240
|
+
return {
|
|
241
|
+
contents: [
|
|
242
|
+
{
|
|
243
|
+
uri,
|
|
244
|
+
mimeType: "text/markdown",
|
|
245
|
+
text: frontmatter + skill.body,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
120
251
|
async start(): Promise<void> {
|
|
121
252
|
const transport = new StdioServerTransport();
|
|
122
253
|
await this.server.connect(transport);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- Copyright (c) 2024-2026 Withpica Ltd. All rights reserved. -->
|
|
2
|
+
---
|
|
3
|
+
name: find-music-for-sync-brief
|
|
4
|
+
description: Find music in the PICA public directory for a sync brief — translate a mood/vibe/scene description into audio search parameters, run the search, and return a rights-aware shortlist with credit details for licensing.
|
|
5
|
+
triggers:
|
|
6
|
+
- find music for a sync brief
|
|
7
|
+
- find me a track for a film scene
|
|
8
|
+
- music for this brief
|
|
9
|
+
- find an uplifting indie folk track
|
|
10
|
+
- I need music that sounds like
|
|
11
|
+
audience: sync supervisor / music library / ad agency / film & TV music team
|
|
12
|
+
tools_required:
|
|
13
|
+
- directory_search_recordings
|
|
14
|
+
- directory_lookup_work
|
|
15
|
+
- directory_lookup_person
|
|
16
|
+
output: A rights-aware shortlist — each result with title, artist, audio characteristics (BPM, key, energy), credits summary for licensing contact, and any flags (unattested credits, low registration score, missing ISRC).
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# find-music-for-sync-brief
|
|
20
|
+
|
|
21
|
+
Help the user find music in PICA's public directory for a sync brief. Translate their description (mood, vibe, scene, era, vocal style) into search parameters, run the search, and return a shortlist that includes the information they need to license — not just the track.
|
|
22
|
+
|
|
23
|
+
This is a public skill — any AI agent connected to the directory MCP can use it. The directory only contains works from organisations that have opted in.
|
|
24
|
+
|
|
25
|
+
## Step 1 — Translate the brief
|
|
26
|
+
|
|
27
|
+
Most sync briefs are described in natural language. Translate before searching:
|
|
28
|
+
|
|
29
|
+
| User says | Search parameters |
|
|
30
|
+
|---|---|
|
|
31
|
+
| upbeat / uplifting / driving | `min_energy: 0.6`, `min_danceability: 0.5` |
|
|
32
|
+
| dark / moody / brooding | `max_energy: 0.4`, `key_mode: minor` |
|
|
33
|
+
| chill / ambient / background | `max_energy: 0.4`, `max_bpm: 100` |
|
|
34
|
+
| epic / cinematic | `min_energy: 0.7`, often longer durations |
|
|
35
|
+
| specific BPM ("around 120bpm") | `min_bpm: 115`, `max_bpm: 125` |
|
|
36
|
+
| acoustic / sparse | typically lower `danceability` and `energy` |
|
|
37
|
+
| vocal / instrumental | filter on `has_vocals` if available |
|
|
38
|
+
|
|
39
|
+
If the user gives an artist or song reference ("something like X"), look up that reference first via `directory_lookup_work` or `directory_search_recordings` by title — then mimic its audio profile in the new search.
|
|
40
|
+
|
|
41
|
+
## Step 2 — Search
|
|
42
|
+
|
|
43
|
+
Call `directory_search_recordings` with the parameters from step 1. Default limit is fine for an initial scan.
|
|
44
|
+
|
|
45
|
+
If the brief is vague, do two searches with slightly different parameters and compare. If too many results, narrow on BPM or key. If too few, widen the BPM range first, then drop key_mode.
|
|
46
|
+
|
|
47
|
+
## Step 3 — Lookup full details
|
|
48
|
+
|
|
49
|
+
For the top 5-10 promising results, call `directory_lookup_work` to get:
|
|
50
|
+
|
|
51
|
+
- **Who wrote it** — credits with IPI numbers (essential for the licensing contact path)
|
|
52
|
+
- **Whether credits are attested** — an unattested credit means the ownership claim hasn't been verified; flag this
|
|
53
|
+
- **DSP links** (Spotify, Apple Music) — the user wants to listen before shortlisting
|
|
54
|
+
- **Registration score** — higher score = cleaner rights chain = easier to license
|
|
55
|
+
|
|
56
|
+
For high-value matches where the user wants to know more about the creator, call `directory_lookup_person` with the IPI to see the writer's broader catalog and collaborator network.
|
|
57
|
+
|
|
58
|
+
## Step 4 — Present the shortlist
|
|
59
|
+
|
|
60
|
+
Present each shortlisted track with:
|
|
61
|
+
|
|
62
|
+
- **Title, artist** — what the user listens for
|
|
63
|
+
- **Audio profile** — BPM, key, energy (one line, the supervisor's quick filter)
|
|
64
|
+
- **Credits summary** — writers with IPI, publisher if known (this is the licensing path)
|
|
65
|
+
- **DSP links** — so the user can listen
|
|
66
|
+
- **Flags** — unattested credits, low registration score, missing ISRC, multiple writers (= multi-party clearance needed)
|
|
67
|
+
|
|
68
|
+
If a track has all green flags (attested credits, high registration score, ISRC present, single or low-count writers), call it out as "clean to clear."
|
|
69
|
+
|
|
70
|
+
## Step 5 — If no results
|
|
71
|
+
|
|
72
|
+
If the search returns nothing, walk the user back through the brief:
|
|
73
|
+
- Widen the BPM range first (most supervisors don't actually mind ±10 BPM)
|
|
74
|
+
- Drop the key filter (key matching matters less than mood for most placements)
|
|
75
|
+
- Drop the energy bounds and search by genre/mood text only
|
|
76
|
+
- Suggest the user expand to adjacent moods ("uplifting" → also try "warm" or "hopeful")
|
|
77
|
+
|
|
78
|
+
Be honest if the directory is small for a specific style — PICA's directory grows with org opt-ins; some niches are sparse.
|
|
79
|
+
|
|
80
|
+
## What not to do
|
|
81
|
+
|
|
82
|
+
- Don't claim to license tracks — this skill returns a shortlist, not a license. The user contacts the rights holder via the credits summary.
|
|
83
|
+
- Don't speculate about pricing — sync fees are negotiated per-placement
|
|
84
|
+
- Don't return results from outside the directory (no general web search, no Spotify metadata directly) — the directory is the source of truth for this skill
|
|
85
|
+
- Don't return tracks with no attested credits without flagging them as "rights chain unverified"
|
|
86
|
+
|
|
87
|
+
## Follow-on skills
|
|
88
|
+
|
|
89
|
+
- `due-diligence-on-creator` (Stage 2 candidate) — for deeper research on a specific writer before reaching out
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Skills Registry — directory MCP, ADR-140 Phase 2b
|
|
5
|
+
*
|
|
6
|
+
* Sister of mcp-server/src/skills/index.ts. Same shape, scoped to the public
|
|
7
|
+
* directory MCP. Body bytes are generated at build time by
|
|
8
|
+
* `scripts/build-skills.ts` and inlined into `skills.generated.ts`.
|
|
9
|
+
*
|
|
10
|
+
* Public/anonymous surface — every skill body must clear the IP-protection
|
|
11
|
+
* lint (scripts/lint-mcp-tools.ts Rule 14) before publishing. Directory MCP
|
|
12
|
+
* skills MUST NOT quote from trade-secret directories listed in
|
|
13
|
+
* `.claude/rules/ip-protection.md`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { SKILLS, SKILL_NAMES, type Skill } from "./skills.generated.js";
|
|
17
|
+
|
|
18
|
+
export interface SkillSummary {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
triggers: string[];
|
|
22
|
+
audience: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class SkillsRegistry {
|
|
26
|
+
listNames(): ReadonlyArray<string> {
|
|
27
|
+
return SKILL_NAMES;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
listSkills(): SkillSummary[] {
|
|
31
|
+
return SKILL_NAMES.map((name) => {
|
|
32
|
+
const skill = SKILLS[name];
|
|
33
|
+
return {
|
|
34
|
+
name: skill.name,
|
|
35
|
+
description: skill.description,
|
|
36
|
+
triggers: skill.triggers,
|
|
37
|
+
audience: skill.audience,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getSkill(name: string): Skill {
|
|
43
|
+
const skill = SKILLS[name];
|
|
44
|
+
if (!skill) {
|
|
45
|
+
throw new SkillNotFoundError(name);
|
|
46
|
+
}
|
|
47
|
+
return skill;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
has(name: string): boolean {
|
|
51
|
+
return name in SKILLS;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class SkillNotFoundError extends Error {
|
|
56
|
+
constructor(public readonly skillName: string) {
|
|
57
|
+
super(`Skill not found: ${skillName}`);
|
|
58
|
+
this.name = "SkillNotFoundError";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { SKILLS, SKILL_NAMES };
|
|
63
|
+
export type { Skill };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — DO NOT EDIT BY HAND.
|
|
5
|
+
*
|
|
6
|
+
* Regenerated by `scripts/build-skills.ts` from `src/skills/<name>/SKILL.md`.
|
|
7
|
+
* Runs in `prebuild`. See ADR-140 Phase 2b.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface Skill {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
triggers: string[];
|
|
14
|
+
audience: string;
|
|
15
|
+
tools_required: string[];
|
|
16
|
+
output: string;
|
|
17
|
+
body: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const SKILLS: Record<string, Skill> = {
|
|
22
|
+
"find-music-for-sync-brief": {
|
|
23
|
+
name: "find-music-for-sync-brief",
|
|
24
|
+
description: "Find music in the PICA public directory for a sync brief — translate a mood/vibe/scene description into audio search parameters, run the search, and return a rights-aware shortlist with credit details for licensing.",
|
|
25
|
+
triggers: ["find music for a sync brief","find me a track for a film scene","music for this brief","find an uplifting indie folk track","I need music that sounds like"],
|
|
26
|
+
audience: "sync supervisor / music library / ad agency / film & TV music team",
|
|
27
|
+
tools_required: ["directory_search_recordings","directory_lookup_work","directory_lookup_person"],
|
|
28
|
+
output: "A rights-aware shortlist — each result with title, artist, audio characteristics (BPM, key, energy), credits summary for licensing contact, and any flags (unattested credits, low registration score, missing ISRC).",
|
|
29
|
+
body: "# find-music-for-sync-brief\n\nHelp the user find music in PICA's public directory for a sync brief. Translate their description (mood, vibe, scene, era, vocal style) into search parameters, run the search, and return a shortlist that includes the information they need to license — not just the track.\n\nThis is a public skill — any AI agent connected to the directory MCP can use it. The directory only contains works from organisations that have opted in.\n\n## Step 1 — Translate the brief\n\nMost sync briefs are described in natural language. Translate before searching:\n\n| User says | Search parameters |\n|---|---|\n| upbeat / uplifting / driving | `min_energy: 0.6`, `min_danceability: 0.5` |\n| dark / moody / brooding | `max_energy: 0.4`, `key_mode: minor` |\n| chill / ambient / background | `max_energy: 0.4`, `max_bpm: 100` |\n| epic / cinematic | `min_energy: 0.7`, often longer durations |\n| specific BPM (\"around 120bpm\") | `min_bpm: 115`, `max_bpm: 125` |\n| acoustic / sparse | typically lower `danceability` and `energy` |\n| vocal / instrumental | filter on `has_vocals` if available |\n\nIf the user gives an artist or song reference (\"something like X\"), look up that reference first via `directory_lookup_work` or `directory_search_recordings` by title — then mimic its audio profile in the new search.\n\n## Step 2 — Search\n\nCall `directory_search_recordings` with the parameters from step 1. Default limit is fine for an initial scan.\n\nIf the brief is vague, do two searches with slightly different parameters and compare. If too many results, narrow on BPM or key. If too few, widen the BPM range first, then drop key_mode.\n\n## Step 3 — Lookup full details\n\nFor the top 5-10 promising results, call `directory_lookup_work` to get:\n\n- **Who wrote it** — credits with IPI numbers (essential for the licensing contact path)\n- **Whether credits are attested** — an unattested credit means the ownership claim hasn't been verified; flag this\n- **DSP links** (Spotify, Apple Music) — the user wants to listen before shortlisting\n- **Registration score** — higher score = cleaner rights chain = easier to license\n\nFor high-value matches where the user wants to know more about the creator, call `directory_lookup_person` with the IPI to see the writer's broader catalog and collaborator network.\n\n## Step 4 — Present the shortlist\n\nPresent each shortlisted track with:\n\n- **Title, artist** — what the user listens for\n- **Audio profile** — BPM, key, energy (one line, the supervisor's quick filter)\n- **Credits summary** — writers with IPI, publisher if known (this is the licensing path)\n- **DSP links** — so the user can listen\n- **Flags** — unattested credits, low registration score, missing ISRC, multiple writers (= multi-party clearance needed)\n\nIf a track has all green flags (attested credits, high registration score, ISRC present, single or low-count writers), call it out as \"clean to clear.\"\n\n## Step 5 — If no results\n\nIf the search returns nothing, walk the user back through the brief:\n- Widen the BPM range first (most supervisors don't actually mind ±10 BPM)\n- Drop the key filter (key matching matters less than mood for most placements)\n- Drop the energy bounds and search by genre/mood text only\n- Suggest the user expand to adjacent moods (\"uplifting\" → also try \"warm\" or \"hopeful\")\n\nBe honest if the directory is small for a specific style — PICA's directory grows with org opt-ins; some niches are sparse.\n\n## What not to do\n\n- Don't claim to license tracks — this skill returns a shortlist, not a license. The user contacts the rights holder via the credits summary.\n- Don't speculate about pricing — sync fees are negotiated per-placement\n- Don't return results from outside the directory (no general web search, no Spotify metadata directly) — the directory is the source of truth for this skill\n- Don't return tracks with no attested credits without flagging them as \"rights chain unverified\"\n\n## Follow-on skills\n\n- `due-diligence-on-creator` (Stage 2 candidate) — for deeper research on a specific writer before reaching out\n",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const SKILL_NAMES: ReadonlyArray<string> = ["find-music-for-sync-brief"];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { DirectoryReleaseNotesTools } from "../release-notes.js";
|
|
4
|
+
import type { DirectoryClient } from "../../client.js";
|
|
5
|
+
|
|
6
|
+
describe("DirectoryReleaseNotesTools.directory_release_notes", () => {
|
|
7
|
+
const client = {} as DirectoryClient;
|
|
8
|
+
const tools = new DirectoryReleaseNotesTools(client).getTools();
|
|
9
|
+
const tool = tools.find(
|
|
10
|
+
(t: { definition: { name: string } }) =>
|
|
11
|
+
t.definition.name === "directory_release_notes",
|
|
12
|
+
)!;
|
|
13
|
+
|
|
14
|
+
it("registers as a single tool named directory_release_notes", () => {
|
|
15
|
+
expect(tools).toHaveLength(1);
|
|
16
|
+
expect(tool).toBeDefined();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("returns the last 3 releases by default", async () => {
|
|
20
|
+
const result = await tool.executor({});
|
|
21
|
+
const data = JSON.parse(result.content[0].text);
|
|
22
|
+
expect(data.package).toBe("@withpica/mcp-server-directory");
|
|
23
|
+
expect(data.current_version).toMatch(/^\d+\.\d+\.\d+$/);
|
|
24
|
+
expect(Array.isArray(data.releases)).toBe(true);
|
|
25
|
+
expect(data.releases.length).toBeLessThanOrEqual(3);
|
|
26
|
+
expect(data.releases.length).toBeGreaterThan(0);
|
|
27
|
+
expect(data.resource_uri).toBe(
|
|
28
|
+
"release-notes://withpica/mcp-server-directory/latest",
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("respects since_version (strictly greater)", async () => {
|
|
33
|
+
const result = await tool.executor({ since_version: "0.0.1" });
|
|
34
|
+
const data = JSON.parse(result.content[0].text);
|
|
35
|
+
expect(data.releases.length).toBeGreaterThan(0);
|
|
36
|
+
for (const r of data.releases) {
|
|
37
|
+
expect(r.version).not.toBe("0.0.1");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("filters to specified sections", async () => {
|
|
42
|
+
const result = await tool.executor({ sections: ["Added"] });
|
|
43
|
+
const data = JSON.parse(result.content[0].text);
|
|
44
|
+
for (const r of data.releases) {
|
|
45
|
+
for (const k of Object.keys(r.sections)) {
|
|
46
|
+
expect(k).toBe("Added");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("returns empty releases array when since_version exceeds current_version", async () => {
|
|
52
|
+
const result = await tool.executor({ since_version: "99.0.0" });
|
|
53
|
+
const data = JSON.parse(result.content[0].text);
|
|
54
|
+
expect(data.releases).toEqual([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("clamps limit to max 20", async () => {
|
|
58
|
+
const result = await tool.executor({ limit: 9999 });
|
|
59
|
+
const data = JSON.parse(result.content[0].text);
|
|
60
|
+
expect(data.releases.length).toBeLessThanOrEqual(20);
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/tools/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { DirectoryPeopleTools } from "./people.js";
|
|
|
6
6
|
import { DirectorySearchTools } from "./search.js";
|
|
7
7
|
import { DirectoryRecordingsTools } from "./recordings.js";
|
|
8
8
|
import { DirectoryChainTools } from "./chain.js";
|
|
9
|
+
import { DirectorySkillsTools } from "./skills.js";
|
|
10
|
+
import { DirectoryReleaseNotesTools } from "./release-notes.js";
|
|
9
11
|
import { formatError, logError, ToolExecutionError } from "../utils/errors.js";
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -25,6 +27,7 @@ export interface ToolDefinition {
|
|
|
25
27
|
type: string;
|
|
26
28
|
properties: Record<string, any>;
|
|
27
29
|
required?: string[];
|
|
30
|
+
additionalProperties?: boolean;
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -51,6 +54,8 @@ export class ToolRegistry {
|
|
|
51
54
|
new DirectorySearchTools(client),
|
|
52
55
|
new DirectoryRecordingsTools(client),
|
|
53
56
|
new DirectoryChainTools(client),
|
|
57
|
+
new DirectorySkillsTools(),
|
|
58
|
+
new DirectoryReleaseNotesTools(client),
|
|
54
59
|
];
|
|
55
60
|
|
|
56
61
|
for (const group of groups) {
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any -- ToolExecutor signature uses Record<string, any> */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* directory_release_notes — what shipped in the PICA directory MCP.
|
|
7
|
+
*
|
|
8
|
+
* Reads CHANGELOG.md embedded at build time via scripts/build-changelog.ts.
|
|
9
|
+
* Sister of pica_release_notes (creator MCP) and team_release_notes (team MCP).
|
|
10
|
+
*
|
|
11
|
+
* Public-facing MCP — no trade-secret content in the description (per
|
|
12
|
+
* .claude/rules/ip-protection.md). The CHANGELOG body is the same file
|
|
13
|
+
* shipped in the npm tarball, already vetted as public.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { DirectoryClient } from "../client.js";
|
|
17
|
+
import { ToolDefinition, ToolExecutor, ToolResult } from "./index.js";
|
|
18
|
+
import {
|
|
19
|
+
parseChangelogText,
|
|
20
|
+
type ChangelogSectionName,
|
|
21
|
+
CHANGELOG_SECTION_NAMES,
|
|
22
|
+
} from "../lib/changelog.js";
|
|
23
|
+
import {
|
|
24
|
+
CHANGELOG_MD,
|
|
25
|
+
PACKAGE_NAME,
|
|
26
|
+
PACKAGE_VERSION,
|
|
27
|
+
} from "../lib/changelog.generated.js";
|
|
28
|
+
|
|
29
|
+
const RESOURCE_URI = "release-notes://withpica/mcp-server-directory/latest";
|
|
30
|
+
const DEFAULT_LIMIT = 3;
|
|
31
|
+
const MAX_LIMIT = 20;
|
|
32
|
+
|
|
33
|
+
function compareSemver(a: string, b: string): number {
|
|
34
|
+
const parse = (v: string) => v.split(".").map((n) => parseInt(n, 10) || 0);
|
|
35
|
+
const [a1, a2, a3] = parse(a);
|
|
36
|
+
const [b1, b2, b3] = parse(b);
|
|
37
|
+
if (a1 !== b1) return a1 - b1;
|
|
38
|
+
if (a2 !== b2) return a2 - b2;
|
|
39
|
+
return a3 - b3;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class DirectoryReleaseNotesTools {
|
|
43
|
+
constructor(private client: DirectoryClient) {}
|
|
44
|
+
|
|
45
|
+
getTools(): Array<{ definition: ToolDefinition; executor: ToolExecutor }> {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
definition: {
|
|
49
|
+
name: "directory_release_notes",
|
|
50
|
+
tier: "read",
|
|
51
|
+
description:
|
|
52
|
+
"Use when the user asks: 'what's new in the directory mcp', " +
|
|
53
|
+
"'what changed in the directory', 'directory release notes', " +
|
|
54
|
+
"'what version is the directory on'. " +
|
|
55
|
+
"Returns recent releases of the PICA directory MCP server — " +
|
|
56
|
+
"what shipped in the public catalogue surface itself. " +
|
|
57
|
+
"NOT for catalogue content searches (use directory_search / " +
|
|
58
|
+
"directory_list_works / directory_chain for those). " +
|
|
59
|
+
"Returns { package, current_version, releases: [{ version, date, sections, markdown }], resource_uri }. " +
|
|
60
|
+
"Defaults to the last 3 releases; use `since_version` to bound the output " +
|
|
61
|
+
"or `sections` to filter to Added/Fixed/etc.",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
since_version: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description:
|
|
68
|
+
"If set, returns only releases strictly greater than this version " +
|
|
69
|
+
"(semver-compared). Versions equal to since_version are excluded.",
|
|
70
|
+
},
|
|
71
|
+
limit: {
|
|
72
|
+
type: "number",
|
|
73
|
+
description: `Maximum number of releases to return. Default ${DEFAULT_LIMIT}, max ${MAX_LIMIT}.`,
|
|
74
|
+
},
|
|
75
|
+
sections: {
|
|
76
|
+
type: "array",
|
|
77
|
+
items: { type: "string", enum: [...CHANGELOG_SECTION_NAMES] },
|
|
78
|
+
description:
|
|
79
|
+
"Filter each release's sections to only these names " +
|
|
80
|
+
"(e.g. ['Added', 'Fixed']). Sections not in the list are omitted from output.",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
executor: this.releaseNotes.bind(this),
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private releaseNotes: ToolExecutor = async (
|
|
91
|
+
args: Record<string, any>,
|
|
92
|
+
): Promise<ToolResult> => {
|
|
93
|
+
const sinceVersion =
|
|
94
|
+
typeof args.since_version === "string" ? args.since_version : null;
|
|
95
|
+
const rawLimit =
|
|
96
|
+
typeof args.limit === "number" ? args.limit : DEFAULT_LIMIT;
|
|
97
|
+
const limit = Math.max(1, Math.min(MAX_LIMIT, Math.floor(rawLimit)));
|
|
98
|
+
const sectionFilter: ChangelogSectionName[] | null = Array.isArray(
|
|
99
|
+
args.sections,
|
|
100
|
+
)
|
|
101
|
+
? args.sections.filter((s: unknown): s is ChangelogSectionName =>
|
|
102
|
+
CHANGELOG_SECTION_NAMES.includes(s as ChangelogSectionName),
|
|
103
|
+
)
|
|
104
|
+
: null;
|
|
105
|
+
|
|
106
|
+
const all = parseChangelogText(CHANGELOG_MD);
|
|
107
|
+
|
|
108
|
+
let filtered = all;
|
|
109
|
+
if (sinceVersion) {
|
|
110
|
+
filtered = all.filter((e) => compareSemver(e.version, sinceVersion) > 0);
|
|
111
|
+
}
|
|
112
|
+
filtered = filtered.slice(0, limit);
|
|
113
|
+
|
|
114
|
+
const releases = filtered.map((e) => {
|
|
115
|
+
const sections = sectionFilter
|
|
116
|
+
? Object.fromEntries(
|
|
117
|
+
Object.entries(e.sections).filter(([k]) =>
|
|
118
|
+
sectionFilter.includes(k as ChangelogSectionName),
|
|
119
|
+
),
|
|
120
|
+
)
|
|
121
|
+
: e.sections;
|
|
122
|
+
return {
|
|
123
|
+
version: e.version,
|
|
124
|
+
date: e.date,
|
|
125
|
+
sections,
|
|
126
|
+
markdown: e.markdown,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
content: [
|
|
132
|
+
{
|
|
133
|
+
type: "text",
|
|
134
|
+
text: JSON.stringify(
|
|
135
|
+
{
|
|
136
|
+
package: PACKAGE_NAME,
|
|
137
|
+
current_version: PACKAGE_VERSION,
|
|
138
|
+
releases,
|
|
139
|
+
resource_uri: RESOURCE_URI,
|
|
140
|
+
},
|
|
141
|
+
null,
|
|
142
|
+
2,
|
|
143
|
+
),
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
}
|