@withpica/mcp-server-directory 1.1.0 → 1.3.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 (76) hide show
  1. package/CHANGELOG.md +43 -26
  2. package/package.json +4 -2
  3. package/scripts/build-skills.ts +192 -0
  4. package/src/__tests__/prompts/index.test.ts +47 -64
  5. package/src/__tests__/prompts/prompt-eval-harness.test.ts +135 -104
  6. package/src/__tests__/skills/skills-registry.test.ts +63 -0
  7. package/src/__tests__/skills/skills-tools.test.ts +74 -0
  8. package/src/__tests__/tools/chain.test.ts +122 -0
  9. package/src/__tests__/tools/composability-chains.test.ts +4 -2
  10. package/src/__tests__/tools/people.test.ts +9 -3
  11. package/src/__tests__/tools/works.test.ts +32 -3
  12. package/src/prompts/index.ts +97 -141
  13. package/src/prompts/public-question-atlas.ts +557 -0
  14. package/src/server.ts +123 -11
  15. package/src/skills/find-music-for-sync-brief/SKILL.md +89 -0
  16. package/src/skills/index.ts +63 -0
  17. package/src/skills/skills.generated.ts +33 -0
  18. package/src/tools/chain.ts +118 -0
  19. package/src/tools/index.ts +15 -0
  20. package/src/tools/people.ts +22 -41
  21. package/src/tools/recordings.ts +7 -3
  22. package/src/tools/search.ts +7 -4
  23. package/src/tools/skills.ts +146 -0
  24. package/src/tools/works.ts +39 -46
  25. package/dist/client.d.ts +0 -12
  26. package/dist/client.d.ts.map +0 -1
  27. package/dist/client.js +0 -93
  28. package/dist/client.js.map +0 -1
  29. package/dist/config.d.ts +0 -9
  30. package/dist/config.d.ts.map +0 -1
  31. package/dist/config.js +0 -15
  32. package/dist/config.js.map +0 -1
  33. package/dist/index.d.ts +0 -3
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/index.js +0 -28
  36. package/dist/index.js.map +0 -1
  37. package/dist/prompts/index.d.ts +0 -33
  38. package/dist/prompts/index.d.ts.map +0 -1
  39. package/dist/prompts/index.js +0 -208
  40. package/dist/prompts/index.js.map +0 -1
  41. package/dist/resources/llms-primer.d.ts +0 -2
  42. package/dist/resources/llms-primer.d.ts.map +0 -1
  43. package/dist/resources/llms-primer.js +0 -35
  44. package/dist/resources/llms-primer.js.map +0 -1
  45. package/dist/server.d.ts +0 -13
  46. package/dist/server.d.ts.map +0 -1
  47. package/dist/server.js +0 -104
  48. package/dist/server.js.map +0 -1
  49. package/dist/tools/index.d.ts +0 -26
  50. package/dist/tools/index.d.ts.map +0 -1
  51. package/dist/tools/index.js +0 -43
  52. package/dist/tools/index.js.map +0 -1
  53. package/dist/tools/people.d.ts +0 -14
  54. package/dist/tools/people.d.ts.map +0 -1
  55. package/dist/tools/people.js +0 -190
  56. package/dist/tools/people.js.map +0 -1
  57. package/dist/tools/recordings.d.ts +0 -12
  58. package/dist/tools/recordings.d.ts.map +0 -1
  59. package/dist/tools/recordings.js +0 -141
  60. package/dist/tools/recordings.js.map +0 -1
  61. package/dist/tools/search.d.ts +0 -12
  62. package/dist/tools/search.d.ts.map +0 -1
  63. package/dist/tools/search.js +0 -53
  64. package/dist/tools/search.js.map +0 -1
  65. package/dist/tools/works.d.ts +0 -15
  66. package/dist/tools/works.d.ts.map +0 -1
  67. package/dist/tools/works.js +0 -249
  68. package/dist/tools/works.js.map +0 -1
  69. package/dist/utils/errors.d.ts +0 -14
  70. package/dist/utils/errors.d.ts.map +0 -1
  71. package/dist/utils/errors.js +0 -48
  72. package/dist/utils/errors.js.map +0 -1
  73. package/dist/utils/formatting.d.ts +0 -10
  74. package/dist/utils/formatting.d.ts.map +0 -1
  75. package/dist/utils/formatting.js +0 -16
  76. package/dist/utils/formatting.js.map +0 -1
package/src/server.ts CHANGED
@@ -16,13 +16,20 @@ 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 { SkillsRegistry } from "./skills/index.js";
19
20
 
20
21
  export class DirectoryMcpServer {
21
22
  private server: Server;
22
23
  private client: DirectoryClient;
23
24
  private toolRegistry: ToolRegistry;
24
25
  private promptRegistry: PromptRegistry;
26
+ private skillsRegistry: SkillsRegistry;
25
27
  private config: ServerConfig;
28
+ // Logged once after the MCP `initialize` handshake completes so each
29
+ // session prints a single client-attribution breadcrumb to stderr
30
+ // (Railway logs / Sentry breadcrumbs). Directory MCP has no DB audit
31
+ // pipeline today; this is provenance-only.
32
+ private clientAttributionLogged = false;
26
33
 
27
34
  constructor(config: ServerConfig) {
28
35
  this.config = config;
@@ -48,6 +55,7 @@ export class DirectoryMcpServer {
48
55
 
49
56
  this.toolRegistry = new ToolRegistry(this.client);
50
57
  this.promptRegistry = new PromptRegistry();
58
+ this.skillsRegistry = new SkillsRegistry();
51
59
  this.setupHandlers();
52
60
  }
53
61
 
@@ -60,17 +68,36 @@ export class DirectoryMcpServer {
60
68
  });
61
69
 
62
70
  this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
63
- return {
64
- resources: [
65
- {
66
- uri: "llms://primer",
67
- name: "PICA Domain Primer",
68
- description:
69
- "Plain-language description of PICA's domain model, entity relationships, and recommended agent workflows. Read this first.",
70
- mimeType: "text/markdown",
71
- },
72
- ],
73
- };
71
+ const resources: Array<{
72
+ uri: string;
73
+ name: string;
74
+ description: string;
75
+ mimeType: string;
76
+ }> = [
77
+ {
78
+ uri: "llms://primer",
79
+ name: "PICA Domain Primer",
80
+ description:
81
+ "Plain-language description of PICA's domain model, entity relationships, and recommended agent workflows. Read this first.",
82
+ mimeType: "text/markdown",
83
+ },
84
+ {
85
+ uri: "skill://withpica/index.json",
86
+ name: "PICA Directory Skills Index",
87
+ description:
88
+ "Enumeration of downloadable directory skill methodologies (SEP-2640 bridge). Each entry maps a kebab-case name to its skill:// URI, description, and trigger phrases.",
89
+ mimeType: "application/json",
90
+ },
91
+ ];
92
+ for (const summary of this.skillsRegistry.listSkills()) {
93
+ resources.push({
94
+ uri: `skill://withpica/${summary.name}/SKILL.md`,
95
+ name: `Skill — ${summary.name}`,
96
+ description: summary.description,
97
+ mimeType: "text/markdown",
98
+ });
99
+ }
100
+ return { resources };
74
101
  });
75
102
 
76
103
  this.server.setRequestHandler(
@@ -88,6 +115,9 @@ export class DirectoryMcpServer {
88
115
  ],
89
116
  };
90
117
  }
118
+ if (uri.startsWith("skill://withpica/")) {
119
+ return this.readSkillResource(uri);
120
+ }
91
121
  throw new Error(`Resource not found: ${uri}`);
92
122
  },
93
123
  );
@@ -104,6 +134,8 @@ export class DirectoryMcpServer {
104
134
  this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
105
135
  const { name, arguments: args } = request.params;
106
136
 
137
+ this.logClientAttributionOnce();
138
+
107
139
  if (this.config.debug) {
108
140
  console.error(`[Directory MCP] Executing tool: ${name}`, args);
109
141
  }
@@ -117,6 +149,86 @@ export class DirectoryMcpServer {
117
149
  });
118
150
  }
119
151
 
152
+ /**
153
+ * Emit a single stderr line per session naming the client that handshook
154
+ * with us — sourced from `clientInfo` on the MCP `initialize` request.
155
+ * Self-declared, NOT authenticated; treat as provenance metadata only.
156
+ *
157
+ * Directory MCP is unauthenticated and writes no audit rows, so this
158
+ * stderr breadcrumb is the only attribution surface today. When/if a
159
+ * directory audit pipeline lands, fold these values into McpAuditEntry
160
+ * (the wire shape already carries optional client_name + client_version).
161
+ */
162
+ private logClientAttributionOnce(): void {
163
+ if (this.clientAttributionLogged) return;
164
+ const info = this.server.getClientVersion?.();
165
+ if (!info) return;
166
+ this.clientAttributionLogged = true;
167
+ console.error(
168
+ `[Directory MCP] client: ${info.name ?? "unknown"} v${info.version ?? "unknown"}`,
169
+ );
170
+ }
171
+
172
+ /**
173
+ * Resolve a skill:// URI. ADR-140 Phase 2b — SEP-2640 bridge pattern.
174
+ * Two URI shapes:
175
+ * - skill://withpica/index.json
176
+ * - skill://withpica/<name>/SKILL.md
177
+ */
178
+ private readSkillResource(uri: string): {
179
+ contents: Array<{ uri: string; mimeType: string; text: string }>;
180
+ } {
181
+ if (uri === "skill://withpica/index.json") {
182
+ const index = this.skillsRegistry.listSkills().map((s) => ({
183
+ name: s.name,
184
+ uri: `skill://withpica/${s.name}/SKILL.md`,
185
+ description: s.description,
186
+ triggers: s.triggers,
187
+ audience: s.audience,
188
+ }));
189
+ return {
190
+ contents: [
191
+ {
192
+ uri,
193
+ mimeType: "application/json",
194
+ text: JSON.stringify({ skills: index }, null, 2),
195
+ },
196
+ ],
197
+ };
198
+ }
199
+ const match = uri.match(/^skill:\/\/withpica\/([a-z0-9-]+)\/SKILL\.md$/);
200
+ if (!match) {
201
+ throw new Error(`Malformed skill URI: ${uri}`);
202
+ }
203
+ const name = match[1];
204
+ if (!this.skillsRegistry.has(name)) {
205
+ throw new Error(`Skill not found: ${name}`);
206
+ }
207
+ const skill = this.skillsRegistry.getSkill(name);
208
+ const frontmatter = [
209
+ "---",
210
+ `name: ${skill.name}`,
211
+ `description: ${skill.description}`,
212
+ "triggers:",
213
+ ...skill.triggers.map((t) => ` - ${t}`),
214
+ `audience: ${skill.audience}`,
215
+ "tools_required:",
216
+ ...skill.tools_required.map((t) => ` - ${t}`),
217
+ `output: ${skill.output}`,
218
+ "---",
219
+ "",
220
+ ].join("\n");
221
+ return {
222
+ contents: [
223
+ {
224
+ uri,
225
+ mimeType: "text/markdown",
226
+ text: frontmatter + skill.body,
227
+ },
228
+ ],
229
+ };
230
+ }
231
+
120
232
  async start(): Promise<void> {
121
233
  const transport = new StdioServerTransport();
122
234
  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,118 @@
1
+ // Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
2
+
3
+ import { DirectoryClient } from "../client.js";
4
+ import { ToolDefinition, ToolExecutor } from "./index.js";
5
+
6
+ export class DirectoryChainTools {
7
+ private client: DirectoryClient;
8
+
9
+ constructor(client: DirectoryClient) {
10
+ this.client = client;
11
+ }
12
+
13
+ getTools(): Array<{ definition: ToolDefinition; executor: ToolExecutor }> {
14
+ return [
15
+ {
16
+ definition: {
17
+ name: "directory_chain",
18
+ tier: "read",
19
+ description:
20
+ "Use when the user asks: 'show me the rights chain for X', " +
21
+ "'give me everything on this song', 'what's the full picture for X?', " +
22
+ "'trace the chain from this writer to that work'. " +
23
+ "Graph lookup — resolves a query, ISWC, or ISRC to its full rights chain in one call. " +
24
+ "Each result bundles the work, its writers and publishers (names + roles, no IPIs or splits), " +
25
+ "the linked recording (ISRC, DSP presence, duration), and audio characteristics (BPM, key, energy). " +
26
+ "Prefer over stitching list_works + lookup_work + lookup_person when you want the whole graph " +
27
+ "around a track in a single round-trip. " +
28
+ "Supports audio-only queries (min_bpm, key, mood, etc.) when you don't have a text query. " +
29
+ "→ then: directory_lookup_work (deeper work detail), directory_lookup_person (research a named writer)",
30
+ inputSchema: {
31
+ type: "object",
32
+ properties: {
33
+ q: {
34
+ type: "string",
35
+ description:
36
+ "Free-text query (work title, creator name, etc.). Minimum 2 characters.",
37
+ },
38
+ identifier: {
39
+ type: "string",
40
+ description: "ISWC or ISRC — direct identifier lookup",
41
+ },
42
+ min_bpm: { type: "number", description: "Minimum BPM" },
43
+ max_bpm: { type: "number", description: "Maximum BPM" },
44
+ key: {
45
+ type: "string",
46
+ description: "Musical key (e.g. 'C', 'F#', 'Bb')",
47
+ },
48
+ key_mode: {
49
+ type: "string",
50
+ enum: ["major", "minor"],
51
+ description: "Key mode",
52
+ },
53
+ min_energy: {
54
+ type: "number",
55
+ description: "Minimum energy (0–1)",
56
+ },
57
+ max_energy: {
58
+ type: "number",
59
+ description: "Maximum energy (0–1)",
60
+ },
61
+ mood: {
62
+ type: "string",
63
+ description: "Mood filter (exact match)",
64
+ },
65
+ limit: {
66
+ type: "number",
67
+ description: "Max results (default 10, max 20)",
68
+ },
69
+ },
70
+ },
71
+ },
72
+ executor: this.chainLookup.bind(this),
73
+ },
74
+ ];
75
+ }
76
+
77
+ private async chainLookup(args: Record<string, any>): Promise<any> {
78
+ const params: Record<string, string> = {};
79
+
80
+ if (args.q) params.q = String(args.q);
81
+ if (args.identifier) params.identifier = String(args.identifier);
82
+
83
+ const numericKeys = [
84
+ "min_bpm",
85
+ "max_bpm",
86
+ "min_energy",
87
+ "max_energy",
88
+ "limit",
89
+ ];
90
+ for (const k of numericKeys) {
91
+ if (args[k] != null) params[k] = String(args[k]);
92
+ }
93
+
94
+ if (args.key) params.key = args.key;
95
+ if (args.key_mode) params.key_mode = args.key_mode;
96
+ if (args.mood) params.mood = args.mood;
97
+
98
+ const response: any = await this.client.request("/chain", params);
99
+
100
+ const results: any[] = response.results || [];
101
+
102
+ return {
103
+ content: [
104
+ {
105
+ type: "text",
106
+ text:
107
+ results.length === 0
108
+ ? "No chain results."
109
+ : `Found ${results.length} chain result(s). See structuredContent for the full graph.`,
110
+ },
111
+ ],
112
+ structuredContent: {
113
+ total: response.total ?? results.length,
114
+ results,
115
+ },
116
+ };
117
+ }
118
+ }
@@ -5,15 +5,28 @@ import { DirectoryWorksTools } from "./works.js";
5
5
  import { DirectoryPeopleTools } from "./people.js";
6
6
  import { DirectorySearchTools } from "./search.js";
7
7
  import { DirectoryRecordingsTools } from "./recordings.js";
8
+ import { DirectoryChainTools } from "./chain.js";
9
+ import { DirectorySkillsTools } from "./skills.js";
8
10
  import { formatError, logError, ToolExecutionError } from "../utils/errors.js";
9
11
 
12
+ /**
13
+ * ADR-230 — authority tier on every directory_* tool. Sister of the
14
+ * creator + team MCP's `Tier` declaration. Every directory tool is
15
+ * `read` (public catalogue lookup with no mutation surface), but the
16
+ * field is required for cross-surface uniformity and lint enforcement.
17
+ */
18
+ export type Tier = "read" | "draft" | "write" | "destructive";
19
+
10
20
  export interface ToolDefinition {
11
21
  name: string;
22
+ /** ADR-230 — see {@link Tier}. Required on every directory tool. */
23
+ tier: Tier;
12
24
  description: string;
13
25
  inputSchema: {
14
26
  type: string;
15
27
  properties: Record<string, any>;
16
28
  required?: string[];
29
+ additionalProperties?: boolean;
17
30
  };
18
31
  }
19
32
 
@@ -39,6 +52,8 @@ export class ToolRegistry {
39
52
  new DirectoryPeopleTools(client),
40
53
  new DirectorySearchTools(client),
41
54
  new DirectoryRecordingsTools(client),
55
+ new DirectoryChainTools(client),
56
+ new DirectorySkillsTools(),
42
57
  ];
43
58
 
44
59
  for (const group of groups) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { DirectoryClient } from "../client.js";
4
4
  import { ToolDefinition, ToolExecutor } from "./index.js";
5
- import { formatAsText, formatStructuredList } from "../utils/formatting.js";
5
+ import { formatStructuredList } from "../utils/formatting.js";
6
6
 
7
7
  export class DirectoryPeopleTools {
8
8
  private client: DirectoryClient;
@@ -16,10 +16,14 @@ export class DirectoryPeopleTools {
16
16
  {
17
17
  definition: {
18
18
  name: "directory_list_people",
19
+ tier: "read",
19
20
  description:
21
+ "Use when the user asks: 'list creators in PICA', 'people starting with B', " +
22
+ "'browse the people directory'. " +
20
23
  "Browse and filter creators in the PICA public directory. " +
21
- "Search by name, ISNI, or IPI number. Returns paginated results. " +
22
- "→ then: directory_lookup_person_full (full profile with works and identifiers)",
24
+ "Filter by free-text (q), ISNI, IPI, or starting letter (A–Z, or '#' for numeric). " +
25
+ "Returns paginated results. " +
26
+ "→ then: directory_lookup_person (full profile with works and identifiers)",
23
27
  inputSchema: {
24
28
  type: "object",
25
29
  properties: {
@@ -35,6 +39,11 @@ export class DirectoryPeopleTools {
35
39
  type: "string",
36
40
  description: "Filter by IPI number",
37
41
  },
42
+ letter: {
43
+ type: "string",
44
+ description:
45
+ "Filter by last name starting letter (A–Z), or '#' for numeric",
46
+ },
38
47
  page: {
39
48
  type: "number",
40
49
  description: "Page number (default: 1, 20 results per page)",
@@ -47,10 +56,16 @@ export class DirectoryPeopleTools {
47
56
  {
48
57
  definition: {
49
58
  name: "directory_lookup_person",
59
+ tier: "read",
50
60
  description:
51
- "Get full details of a single creator by their global creator ID, ISNI, IPI, or MusicBrainz ID. " +
52
- "Returns roles, works, identifiers, and profile information. " +
53
- "→ then: directory_lookup_person_full (agent-optimised markdown), directory_lookup_work_full (inspect a credited work)",
61
+ "Use when the user asks: 'lookup IPI 12345', 'who is creator X?', " +
62
+ "'tell me about creator X', 'lookup ISNI X'. " +
63
+ "Also call this BEFORE directory_list_works when the input person name is ambiguous " +
64
+ "(e.g. 'Bowie', 'Sade', 'Madonna') to surface candidate persons for disambiguation. " +
65
+ "Get full details of a creator by global creator ID (UUID), ISNI, IPI number, or MusicBrainz ID. " +
66
+ "Returns identifiers, credited works with roles, collaborator network, and verification score " +
67
+ "as a structured markdown summary. " +
68
+ "→ then: directory_lookup_work (inspect a credited work), directory_search_recordings (find their recordings by audio)",
54
69
  inputSchema: {
55
70
  type: "object",
56
71
  properties: {
@@ -65,28 +80,6 @@ export class DirectoryPeopleTools {
65
80
  },
66
81
  executor: this.lookupPerson.bind(this),
67
82
  },
68
- {
69
- definition: {
70
- name: "directory_lookup_person_full",
71
- description:
72
- "Get complete details about a person in the public directory — identifiers (IPI, ISNI), " +
73
- "credited works with roles, collaborator network, and verification score. " +
74
- "Returns a structured markdown summary. " +
75
- "→ then: directory_lookup_work_full (inspect a specific work), directory_search_recordings (find their recordings by audio)",
76
- inputSchema: {
77
- type: "object",
78
- properties: {
79
- id: {
80
- type: "string",
81
- description:
82
- "Global creator ID (UUID), ISNI, IPI number, or MusicBrainz ID",
83
- },
84
- },
85
- required: ["id"],
86
- },
87
- },
88
- executor: this.lookupPersonFull.bind(this),
89
- },
90
83
  ];
91
84
  }
92
85
 
@@ -103,6 +96,7 @@ export class DirectoryPeopleTools {
103
96
  if (args.q) params.q = args.q;
104
97
  if (args.isni) params.isni = args.isni;
105
98
  if (args.ipi) params.ipi = args.ipi;
99
+ if (args.letter) params.letter = args.letter;
106
100
 
107
101
  const response: any = await this.client.request("/people", params);
108
102
 
@@ -118,14 +112,6 @@ export class DirectoryPeopleTools {
118
112
  `/people/${encodeURIComponent(args.id)}`,
119
113
  );
120
114
 
121
- return formatAsText(response.data);
122
- }
123
-
124
- private async lookupPersonFull(args: Record<string, any>): Promise<any> {
125
- const response: any = await this.client.request(
126
- `/people/${encodeURIComponent(args.id)}`,
127
- );
128
-
129
115
  const data = response.data;
130
116
  if (!data) {
131
117
  return {
@@ -136,12 +122,10 @@ export class DirectoryPeopleTools {
136
122
 
137
123
  const lines: string[] = [];
138
124
 
139
- // Name heading
140
125
  const name = data.name || data.full_name || data.display_name || "Unknown";
141
126
  lines.push(`## ${name}`);
142
127
  lines.push("");
143
128
 
144
- // Score / verification
145
129
  if (data.score !== undefined && data.score !== null) {
146
130
  const tier =
147
131
  data.score >= 80
@@ -153,7 +137,6 @@ export class DirectoryPeopleTools {
153
137
  lines.push("");
154
138
  }
155
139
 
156
- // Identifiers
157
140
  const identifiers: Array<{ type: string; value: string }> = [];
158
141
  if (data.ipi || data.ipi_number)
159
142
  identifiers.push({ type: "IPI", value: data.ipi || data.ipi_number });
@@ -174,7 +157,6 @@ export class DirectoryPeopleTools {
174
157
  }
175
158
  lines.push("");
176
159
 
177
- // Works
178
160
  const works: any[] = data.works || data.credited_works || [];
179
161
  lines.push(`### Works (${works.length})`);
180
162
  if (works.length > 0) {
@@ -190,7 +172,6 @@ export class DirectoryPeopleTools {
190
172
  }
191
173
  lines.push("");
192
174
 
193
- // Collaborators
194
175
  const collaborators: any[] = data.collaborators || [];
195
176
  lines.push(`### Collaborators (${collaborators.length})`);
196
177
  if (collaborators.length > 0) {