@dudamel/mcp-agents 2026.1104.1 → 2026.1106.2

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/dist/index.js CHANGED
@@ -34,6 +34,10 @@ var DudamelApiError = class extends Error {
34
34
  if (apiError?.context?.["inputsSchema"] !== void 0) {
35
35
  lines.push(`Expected inputs schema: ${JSON.stringify(apiError.context["inputsSchema"])}`);
36
36
  }
37
+ const rest = Object.entries(apiError?.context ?? {}).filter(([key]) => key !== "inputsSchema");
38
+ if (rest.length > 0) {
39
+ lines.push(`Context: ${JSON.stringify(Object.fromEntries(rest))}`);
40
+ }
37
41
  super(lines.join("\n"));
38
42
  this.status = status;
39
43
  this.statusText = statusText;
@@ -152,10 +156,42 @@ function jsonResult(data) {
152
156
  };
153
157
  }
154
158
 
159
+ // ../common/dist/owner-tools.js
160
+ import { z } from "zod";
161
+ function registerOwnerTools(kinds) {
162
+ return (server, client, ctx) => {
163
+ if (ctx.role !== "admin")
164
+ return;
165
+ const what = kinds.join(", ");
166
+ const inputSchema = {
167
+ kind: z.enum(kinds).describe("What is handed over"),
168
+ id: z.string().describe(`The ${what} ID (UUID)`),
169
+ ownerRoleId: z.string().describe("The new owner role ID (UUID)")
170
+ };
171
+ const path = (kind, id) => `/api/${kind}s/${id}`;
172
+ server.registerTool("get-owner-impact", {
173
+ description: `Admin. What breaks if a ${what} is handed to another role \u2014 nothing is changed. Lists the integrations it uses that the new role does not (they fail visibly until an admin adds the role to them, with set-integration-roles), the agent \u2194 workflow links that end up crossing roles (an agent only fires workflows of its own role), the workflows that run the agent and are not of the new role (it runs there as a guest) and, for a skill, the agents it is assigned to (they block the move: change the agent's owner instead, it takes its skills along). Show it to the person before set-owner.`,
174
+ inputSchema,
175
+ annotations: { readOnlyHint: true }
176
+ }, async ({ kind, id, ownerRoleId }) => {
177
+ const impact = await client.get(`${path(kind, id)}/owner-impact`, { ownerRoleId });
178
+ return jsonResult(impact);
179
+ });
180
+ server.registerTool("set-owner", {
181
+ description: `Admin. Hand a ${what} to another role (its owner role): that role's members edit it and it runs with that role's permissions. ALWAYS call get-owner-impact first with the same arguments, show the person what breaks and call this only once they confirm with that list in front of them. Adding the new role to the integrations it lacks is a separate decision (set-integration-roles), never implied by this. An agent takes its sub-agents and skills along (a skill other agents of the old role also use is copied); a sub-agent carries its parent's role, so move the parent. System resources have no owner role.`,
182
+ inputSchema,
183
+ annotations: { readOnlyHint: false, destructiveHint: false }
184
+ }, async ({ kind, id, ownerRoleId }) => {
185
+ const result = await client.put(`${path(kind, id)}/owner`, { ownerRoleId });
186
+ return jsonResult(result);
187
+ });
188
+ };
189
+ }
190
+
155
191
  // src/tools/agents.ts
156
192
  import { readFile, stat } from "node:fs/promises";
157
193
  import { extname, resolve } from "node:path";
158
- import { z } from "zod";
194
+ import { z as z2 } from "zod";
159
195
  function registerAgentTools(server, client, ctx) {
160
196
  server.registerTool(
161
197
  "list-agents",
@@ -173,7 +209,7 @@ function registerAgentTools(server, client, ctx) {
173
209
  {
174
210
  description: "Get detailed information about a specific agent, including prompt sections, system prompt, and config.",
175
211
  inputSchema: {
176
- id: z.string().describe("Agent ID (UUID)")
212
+ id: z2.string().describe("Agent ID (UUID)")
177
213
  },
178
214
  annotations: { readOnlyHint: true }
179
215
  },
@@ -187,7 +223,7 @@ function registerAgentTools(server, client, ctx) {
187
223
  {
188
224
  description: "List the sub-agents assigned to a specific (parent) agent.",
189
225
  inputSchema: {
190
- id: z.string().describe("Parent agent ID (UUID)")
226
+ id: z2.string().describe("Parent agent ID (UUID)")
191
227
  },
192
228
  annotations: { readOnlyHint: true }
193
229
  },
@@ -201,8 +237,8 @@ function registerAgentTools(server, client, ctx) {
201
237
  {
202
238
  description: "Download an agent definition (persona + skills) as files in the target tool's on-disk layout (e.g. .claude/agents/<name>.md + .claude/skills/ for Claude Code). Returns {agentName, files: [{path, content, skipIfExists?}]} \u2014 write each file at its path relative to the current working directory; do NOT overwrite existing files marked skipIfExists. Iterate locally, then push changes back with update-agent/update-skill.",
203
239
  inputSchema: {
204
- id: z.string().describe("Agent ID (UUID)"),
205
- format: z.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
240
+ id: z2.string().describe("Agent ID (UUID)"),
241
+ format: z2.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
206
242
  "Target tool layout \u2014 defaults to 'claude-code'; 'raw' is a dudamel-native <name>/AGENT.md layout"
207
243
  )
208
244
  },
@@ -218,18 +254,18 @@ function registerAgentTools(server, client, ctx) {
218
254
  {
219
255
  description: "Update an agent definition. Requires edit permission on the agent (business-role permission or admin).",
220
256
  inputSchema: {
221
- id: z.string().describe("Agent ID (UUID)"),
222
- name: z.string().optional().describe("New name"),
223
- displayName: z.string().optional().describe("New display name"),
224
- description: z.string().optional().describe("New description"),
225
- identity: z.string().optional().describe("New identity"),
226
- instructions: z.string().optional().describe("New instructions"),
227
- systemPrompt: z.string().optional().describe("New system prompt"),
228
- model: z.string().optional().describe("New model identifier"),
229
- skipPermissions: z.boolean().optional().describe("Skip permission prompts"),
230
- driverProvider: z.string().optional().describe("New AI provider instance name"),
231
- driverMode: z.enum(["api", "cli"]).optional().describe("New driver mode"),
232
- kind: z.enum(["system", "user"]).optional().describe(
257
+ id: z2.string().describe("Agent ID (UUID)"),
258
+ name: z2.string().optional().describe("New name"),
259
+ displayName: z2.string().optional().describe("New display name"),
260
+ description: z2.string().optional().describe("New description"),
261
+ identity: z2.string().optional().describe("New identity"),
262
+ instructions: z2.string().optional().describe("New instructions"),
263
+ systemPrompt: z2.string().optional().describe("New system prompt"),
264
+ model: z2.string().optional().describe("New model identifier"),
265
+ skipPermissions: z2.boolean().optional().describe("Skip permission prompts"),
266
+ driverProvider: z2.string().optional().describe("New AI provider instance name"),
267
+ driverMode: z2.enum(["api", "cli"]).optional().describe("New driver mode"),
268
+ kind: z2.enum(["system", "user"]).optional().describe(
233
269
  "Agent kind \u2014 set to 'user' to convert a disk-seeded 'system' agent into a normal editable user agent"
234
270
  )
235
271
  },
@@ -245,8 +281,8 @@ function registerAgentTools(server, client, ctx) {
245
281
  {
246
282
  description: "Set the sub-agent assignments for a (parent) agent. Replaces existing assignments. Each sub-agent id must be an agent created with isSubAgent=true. Requires edit permission on the parent agent.",
247
283
  inputSchema: {
248
- id: z.string().describe("Parent agent ID (UUID)"),
249
- subAgentIds: z.array(z.string()).describe("Sub-agent IDs (UUIDs) to assign")
284
+ id: z2.string().describe("Parent agent ID (UUID)"),
285
+ subAgentIds: z2.array(z2.string()).describe("Sub-agent IDs (UUIDs) to assign")
250
286
  },
251
287
  annotations: { readOnlyHint: false, destructiveHint: false }
252
288
  },
@@ -262,7 +298,7 @@ function registerAgentTools(server, client, ctx) {
262
298
  {
263
299
  description: "Activate an agent so it starts receiving and answering messages.",
264
300
  inputSchema: {
265
- id: z.string().describe("Agent ID (UUID)")
301
+ id: z2.string().describe("Agent ID (UUID)")
266
302
  },
267
303
  annotations: { readOnlyHint: false, destructiveHint: false }
268
304
  },
@@ -276,7 +312,7 @@ function registerAgentTools(server, client, ctx) {
276
312
  {
277
313
  description: "Deactivate an agent \u2014 it stops receiving messages (Slack, dashboard chat) until reactivated. The definition is kept; this is the way to silence an agent without deleting it.",
278
314
  inputSchema: {
279
- id: z.string().describe("Agent ID (UUID)")
315
+ id: z2.string().describe("Agent ID (UUID)")
280
316
  },
281
317
  annotations: { readOnlyHint: false, destructiveHint: false }
282
318
  },
@@ -290,8 +326,8 @@ function registerAgentTools(server, client, ctx) {
290
326
  {
291
327
  description: "Set an agent's avatar (its picture in the Dashboard, chat and lists) from an image file on disk \u2014 typically one the user attached to the conversation, which you find under `.attachments/` in your workspace. PNG, JPEG, WebP or GIF, under 2 MB. Replaces the current avatar. Needs edit permission on the agent.",
292
328
  inputSchema: {
293
- id: z.string().describe("Agent ID (UUID)"),
294
- imagePath: z.string().describe("Path to the image file, e.g. .attachments/selfie.png (relative to your cwd)")
329
+ id: z2.string().describe("Agent ID (UUID)"),
330
+ imagePath: z2.string().describe("Path to the image file, e.g. .attachments/selfie.png (relative to your cwd)")
295
331
  },
296
332
  annotations: { readOnlyHint: false, destructiveHint: false }
297
333
  },
@@ -301,16 +337,42 @@ function registerAgentTools(server, client, ctx) {
301
337
  return jsonResult({ id, avatar: { mimeType, bytes } });
302
338
  }
303
339
  );
340
+ server.registerTool(
341
+ "create-agent",
342
+ {
343
+ description: "Create a new agent definition. It belongs to one role (its owner role): the members of that role configure it and talk to it with the full profile; anyone else is a guest. If the person has several roles, ask them which one and pass ownerRoleId. A sub-agent (parentAgentId) takes its parent's role instead.",
344
+ inputSchema: {
345
+ name: z2.string().describe("Agent name (unique, kebab-case)"),
346
+ displayName: z2.string().optional().describe("Display name shown in the UI"),
347
+ description: z2.string().optional().describe("Agent description"),
348
+ identity: z2.string().optional().describe('Agent identity (e.g. "senior backend developer")'),
349
+ instructions: z2.string().optional().describe("Agent instructions (appended to system prompt)"),
350
+ systemPrompt: z2.string().optional().describe("System prompt for the agent"),
351
+ model: z2.string().optional().describe('Model identifier (e.g. "claude-sonnet-4-6")'),
352
+ skipPermissions: z2.boolean().optional().describe("Skip permission prompts in coding agents"),
353
+ driverProvider: z2.string().optional().describe("AI provider instance name for the driver"),
354
+ driverMode: z2.enum(["api", "cli"]).optional().describe("Driver mode: api (conversational) or cli (coding)"),
355
+ isSubAgent: z2.boolean().optional().describe("Mark as a sub-agent (not shown in top-level lists)"),
356
+ ownerRoleId: z2.string().optional().describe("Owner role id \u2014 required when the person has several roles"),
357
+ parentAgentId: z2.string().optional().describe("Create it as a sub-agent of this agent (it takes the parent's role)")
358
+ },
359
+ annotations: { readOnlyHint: false, destructiveHint: false }
360
+ },
361
+ async ({ name, ...rest }) => {
362
+ const result = await client.post("/api/agents", { name, ...rest });
363
+ return jsonResult(result);
364
+ }
365
+ );
304
366
  if (ctx.role !== "admin") return;
305
367
  server.registerTool(
306
368
  "get-agent-logs",
307
369
  {
308
370
  description: "Get the agent's recent conversational turns, newest first \u2014 status, duration, model, tokens, the MCP servers the turn brought up, and the failure reason when it failed. This is the way to debug an agent that is not answering: a `failed` turn carries the error code and the CLI stderr tail. Returns metadata only, never the conversation text.",
309
371
  inputSchema: {
310
- id: z.string().describe("Agent ID (UUID)"),
311
- status: z.enum(["completed", "failed"]).optional().describe("Only return turns with this outcome"),
312
- limit: z.number().int().min(1).max(200).optional().describe("Number of turns to return (default: 50)"),
313
- offset: z.number().int().min(0).optional().describe("Pagination offset")
372
+ id: z2.string().describe("Agent ID (UUID)"),
373
+ status: z2.enum(["completed", "failed"]).optional().describe("Only return turns with this outcome"),
374
+ limit: z2.number().int().min(1).max(200).optional().describe("Number of turns to return (default: 50)"),
375
+ offset: z2.number().int().min(0).optional().describe("Pagination offset")
314
376
  },
315
377
  annotations: { readOnlyHint: true }
316
378
  },
@@ -337,7 +399,7 @@ function registerAgentTools(server, client, ctx) {
337
399
  {
338
400
  description: "Get token usage statistics per agent over a time window. Useful for monitoring costs.",
339
401
  inputSchema: {
340
- windowHours: z.number().int().min(1).optional().describe("Time window in hours (default: 24)")
402
+ windowHours: z2.number().int().min(1).optional().describe("Time window in hours (default: 24)")
341
403
  },
342
404
  annotations: { readOnlyHint: true }
343
405
  },
@@ -348,30 +410,6 @@ function registerAgentTools(server, client, ctx) {
348
410
  return jsonResult({ items: page.items, total: page.total });
349
411
  }
350
412
  );
351
- server.registerTool(
352
- "create-agent",
353
- {
354
- description: "Create a new agent definition.",
355
- inputSchema: {
356
- name: z.string().describe("Agent name (unique, kebab-case)"),
357
- displayName: z.string().optional().describe("Display name shown in the UI"),
358
- description: z.string().optional().describe("Agent description"),
359
- identity: z.string().optional().describe('Agent identity (e.g. "senior backend developer")'),
360
- instructions: z.string().optional().describe("Agent instructions (appended to system prompt)"),
361
- systemPrompt: z.string().optional().describe("System prompt for the agent"),
362
- model: z.string().optional().describe('Model identifier (e.g. "claude-sonnet-4-6")'),
363
- skipPermissions: z.boolean().optional().describe("Skip permission prompts in coding agents"),
364
- driverProvider: z.string().optional().describe("AI provider instance name for the driver"),
365
- driverMode: z.enum(["api", "cli"]).optional().describe("Driver mode: api (conversational) or cli (coding)"),
366
- isSubAgent: z.boolean().optional().describe("Mark as a sub-agent (not shown in top-level lists)")
367
- },
368
- annotations: { readOnlyHint: false, destructiveHint: false }
369
- },
370
- async ({ name, ...rest }) => {
371
- const result = await client.post("/api/agents", { name, ...rest });
372
- return jsonResult(result);
373
- }
374
- );
375
413
  }
376
414
  var AVATAR_MIME_BY_EXT = {
377
415
  ".png": "image/png",
@@ -401,7 +439,7 @@ async function readAvatarFile(imagePath) {
401
439
  }
402
440
 
403
441
  // src/tools/skills.ts
404
- import { z as z2 } from "zod";
442
+ import { z as z3 } from "zod";
405
443
 
406
444
  // src/skill-bundle.ts
407
445
  import { createHash } from "node:crypto";
@@ -597,8 +635,8 @@ function registerSkillTools(server, client, ctx) {
597
635
  {
598
636
  description: "List skill definitions (active by default). Metadata only \u2014 id, name, description, status, origin, version, file count and timestamps. Use get-skill or download-skill to read a specific skill.",
599
637
  inputSchema: {
600
- status: z2.enum(["active", "archived"]).optional().describe("Lifecycle filter \u2014 defaults to 'active'; pass 'archived' for archived skills"),
601
- query: z2.string().optional().describe("Case-insensitive substring match against the name and description")
638
+ status: z3.enum(["active", "archived"]).optional().describe("Lifecycle filter \u2014 defaults to 'active'; pass 'archived' for archived skills"),
639
+ query: z3.string().optional().describe("Case-insensitive substring match against the name and description")
602
640
  },
603
641
  annotations: { readOnlyHint: true }
604
642
  },
@@ -617,8 +655,8 @@ function registerSkillTools(server, client, ctx) {
617
655
  {
618
656
  description: "Get detailed information about a specific skill, including content, allowed tools, files, and version info. For a large skill prefer download-skill with outDir, which puts the files on disk instead of in the conversation.",
619
657
  inputSchema: {
620
- id: z2.string().describe("Skill ID (UUID)"),
621
- includeContent: z2.boolean().optional().describe(
658
+ id: z3.string().describe("Skill ID (UUID)"),
659
+ includeContent: z3.boolean().optional().describe(
622
660
  "Defaults to true. With false, returns metadata plus a size and sha256 per file \u2014 enough to check what is stored without pulling the content in."
623
661
  )
624
662
  },
@@ -643,7 +681,7 @@ function registerSkillTools(server, client, ctx) {
643
681
  {
644
682
  description: "List version history for a skill. Returns version numbers, change summaries, and creation dates.",
645
683
  inputSchema: {
646
- id: z2.string().describe("Skill ID (UUID)")
684
+ id: z3.string().describe("Skill ID (UUID)")
647
685
  },
648
686
  annotations: { readOnlyHint: true }
649
687
  },
@@ -657,14 +695,14 @@ function registerSkillTools(server, client, ctx) {
657
695
  {
658
696
  description: "Download a skill as files in the target tool's on-disk layout (e.g. .claude/skills/<name>/SKILL.md for Claude Code). With `outDir` the files are written to disk and only their paths, sizes and hashes come back \u2014 the way to handle a skill of any size. Without it, the content is returned inline. Then edit the folder and push it back with update-skill + skillDir.",
659
697
  inputSchema: {
660
- id: z2.string().describe("Skill ID (UUID)"),
661
- format: z2.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
698
+ id: z3.string().describe("Skill ID (UUID)"),
699
+ format: z3.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
662
700
  "Target tool layout \u2014 defaults to 'claude-code'; 'raw' is the dudamel-native <name>/SKILL.md layout"
663
701
  ),
664
- outDir: z2.string().optional().describe(
702
+ outDir: z3.string().optional().describe(
665
703
  "Directory to write the files into (created if missing). Paths from the chosen format are kept, so outDir is the root the layout hangs from."
666
704
  ),
667
- overwrite: z2.boolean().optional().describe(
705
+ overwrite: z3.boolean().optional().describe(
668
706
  "Defaults to false: if a file already exists with different content the call is rejected and nothing is written, so a re-download cannot erase edits in flight."
669
707
  )
670
708
  },
@@ -686,7 +724,7 @@ function registerSkillTools(server, client, ctx) {
686
724
  {
687
725
  description: "Get the skill definitions assigned to a specific agent.",
688
726
  inputSchema: {
689
- agentId: z2.string().describe("Agent ID (UUID)")
727
+ agentId: z3.string().describe("Agent ID (UUID)")
690
728
  },
691
729
  annotations: { readOnlyHint: true }
692
730
  },
@@ -699,25 +737,28 @@ function registerSkillTools(server, client, ctx) {
699
737
  server.registerTool(
700
738
  "create-skill",
701
739
  {
702
- description: "Create a new skill definition. The creator becomes the owner and can edit it and share edition with business roles via set-skill-roles. Pass `skillDir` to upload a directory from disk instead of inlining every file. Returns the new version plus a size and sha256 per stored file. " + FILES_SEMANTICS,
740
+ description: "Create a new skill definition. It belongs to one role (its owner role): the members of that role edit it and assign it to the role's agents; another role that needs it makes its own copy. Pass `skillDir` to upload a directory from disk instead of inlining every file. Returns the new version plus a size and sha256 per stored file. " + FILES_SEMANTICS,
703
741
  inputSchema: {
704
- name: z2.string().describe("Skill name (unique, kebab-case)"),
705
- content: z2.string().optional().describe(
742
+ name: z3.string().describe("Skill name (unique within the role, kebab-case)"),
743
+ content: z3.string().optional().describe(
706
744
  "Skill content \u2014 the full SKILL.md is fine: its frontmatter (description, version, allowed-tools, model) is honored, and an argument passed explicitly here wins over it. Required unless skillDir is given."
707
745
  ),
708
- skillDir: z2.string().optional().describe(SKILL_DIR_HELP),
709
- description: z2.string().optional().describe("Skill description"),
710
- disableModelInvocation: z2.boolean().optional().describe("Disable model-triggered invocation"),
711
- userInvocable: z2.boolean().optional().describe("Allow user to invoke via slash command"),
712
- model: z2.string().optional().describe("Model identifier or tier"),
713
- allowedTools: z2.array(z2.string()).optional().describe("List of allowed tool names"),
714
- currentVersion: z2.string().optional().describe("Initial version string"),
715
- files: z2.array(
716
- z2.object({
717
- path: z2.string().describe("Relative file path within the skill"),
718
- content: z2.string().describe("File content")
746
+ skillDir: z3.string().optional().describe(SKILL_DIR_HELP),
747
+ description: z3.string().optional().describe("Skill description"),
748
+ disableModelInvocation: z3.boolean().optional().describe("Disable model-triggered invocation"),
749
+ userInvocable: z3.boolean().optional().describe("Allow user to invoke via slash command"),
750
+ model: z3.string().optional().describe("Model identifier or tier"),
751
+ allowedTools: z3.array(z3.string()).optional().describe("List of allowed tool names"),
752
+ currentVersion: z3.string().optional().describe("Initial version string"),
753
+ files: z3.array(
754
+ z3.object({
755
+ path: z3.string().describe("Relative file path within the skill"),
756
+ content: z3.string().describe("File content")
719
757
  })
720
- ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`)
758
+ ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`),
759
+ ownerRoleId: z3.string().optional().describe(
760
+ "Role the skill belongs to (its agents are that role's) \u2014 required when the person has several roles. A name is unique per role."
761
+ )
721
762
  },
722
763
  annotations: { readOnlyHint: false, destructiveHint: false }
723
764
  },
@@ -731,7 +772,8 @@ function registerSkillTools(server, client, ctx) {
731
772
  model,
732
773
  allowedTools,
733
774
  currentVersion,
734
- files
775
+ files,
776
+ ownerRoleId
735
777
  }) => {
736
778
  const bundle = await resolveBundle({ content, files, skillDir });
737
779
  if (bundle.content === void 0) {
@@ -746,7 +788,8 @@ function registerSkillTools(server, client, ctx) {
746
788
  model,
747
789
  allowedTools,
748
790
  currentVersion,
749
- files: bundle.files
791
+ files: bundle.files,
792
+ ownerRoleId
750
793
  });
751
794
  return jsonResult(writeReceipt(result));
752
795
  }
@@ -756,25 +799,25 @@ function registerSkillTools(server, client, ctx) {
756
799
  {
757
800
  description: "Update a skill definition. Creates a new version entry. Pass `skillDir` to upload an edited directory from disk in one call instead of retyping every file. Returns the new version plus a size and sha256 per stored file, so the upload can be verified without downloading it back. " + FILES_SEMANTICS,
758
801
  inputSchema: {
759
- id: z2.string().describe("Skill ID (UUID)"),
760
- name: z2.string().optional().describe(
802
+ id: z3.string().describe("Skill ID (UUID)"),
803
+ name: z3.string().optional().describe(
761
804
  "New skill name (unique, kebab-case) \u2014 rename the skill; agent assignments are by id and survive the rename"
762
805
  ),
763
- content: z2.string().optional().describe(
806
+ content: z3.string().optional().describe(
764
807
  "New skill content \u2014 the full SKILL.md is fine: its frontmatter (description, version, allowed-tools, model) is honored, and an argument passed explicitly here wins over it."
765
808
  ),
766
- skillDir: z2.string().optional().describe(SKILL_DIR_HELP),
767
- description: z2.string().optional().describe("New description"),
768
- disableModelInvocation: z2.boolean().optional().describe("Disable model-triggered invocation"),
769
- userInvocable: z2.boolean().optional().describe("Allow user to invoke via slash command"),
770
- model: z2.string().optional().describe("Model identifier or tier"),
771
- allowedTools: z2.array(z2.string()).optional().describe("List of allowed tool names"),
772
- currentVersion: z2.string().optional().describe("Version string for this update"),
773
- changeSummary: z2.string().optional().describe("Summary of what changed in this version"),
774
- files: z2.array(
775
- z2.object({
776
- path: z2.string().describe("Relative file path within the skill"),
777
- content: z2.string().describe("File content")
809
+ skillDir: z3.string().optional().describe(SKILL_DIR_HELP),
810
+ description: z3.string().optional().describe("New description"),
811
+ disableModelInvocation: z3.boolean().optional().describe("Disable model-triggered invocation"),
812
+ userInvocable: z3.boolean().optional().describe("Allow user to invoke via slash command"),
813
+ model: z3.string().optional().describe("Model identifier or tier"),
814
+ allowedTools: z3.array(z3.string()).optional().describe("List of allowed tool names"),
815
+ currentVersion: z3.string().optional().describe("Version string for this update"),
816
+ changeSummary: z3.string().optional().describe("Summary of what changed in this version"),
817
+ files: z3.array(
818
+ z3.object({
819
+ path: z3.string().describe("Relative file path within the skill"),
820
+ content: z3.string().describe("File content")
778
821
  })
779
822
  ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`)
780
823
  },
@@ -799,7 +842,7 @@ function registerSkillTools(server, client, ctx) {
799
842
  {
800
843
  description: "Archive a skill (logical delete \u2014 versions and files are kept; it disappears from default listings and cannot be assigned). Fails with SKILL_IN_USE while assigned to agents: unassign it first.",
801
844
  inputSchema: {
802
- id: z2.string().describe("Skill ID (UUID)")
845
+ id: z3.string().describe("Skill ID (UUID)")
803
846
  },
804
847
  annotations: { readOnlyHint: false, destructiveHint: false }
805
848
  },
@@ -813,7 +856,7 @@ function registerSkillTools(server, client, ctx) {
813
856
  {
814
857
  description: "Restore an archived skill to active, making it assignable again.",
815
858
  inputSchema: {
816
- id: z2.string().describe("Skill ID (UUID)")
859
+ id: z3.string().describe("Skill ID (UUID)")
817
860
  },
818
861
  annotations: { readOnlyHint: false, destructiveHint: false }
819
862
  },
@@ -822,46 +865,15 @@ function registerSkillTools(server, client, ctx) {
822
865
  return jsonResult(result);
823
866
  }
824
867
  );
825
- server.registerTool(
826
- "get-skill-roles",
827
- {
828
- description: "List the business roles that can edit a skill. Requires edit permission on the skill (owner, permitted role, or admin).",
829
- inputSchema: {
830
- id: z2.string().describe("Skill ID (UUID)")
831
- },
832
- annotations: { readOnlyHint: true }
833
- },
834
- async ({ id }) => {
835
- const page = await client.get(`/api/skills/${id}/permissions`);
836
- return jsonResult({ items: page.items, total: page.total });
837
- }
838
- );
839
- server.registerTool(
840
- "set-skill-roles",
841
- {
842
- description: "Replace the set of business roles that can edit a skill. The owner uses this to share (or revoke) edition with team roles. Requires edit permission on the skill.",
843
- inputSchema: {
844
- id: z2.string().describe("Skill ID (UUID)"),
845
- roleIds: z2.array(z2.string()).describe("Business role IDs that may edit the skill")
846
- },
847
- annotations: { readOnlyHint: false, destructiveHint: false }
848
- },
849
- async ({ id, roleIds }) => {
850
- const page = await client.put(`/api/skills/${id}/permissions`, {
851
- roleIds
852
- });
853
- return jsonResult({ items: page.items });
854
- }
855
- );
856
868
  server.registerTool(
857
869
  "set-agent-skills",
858
870
  {
859
871
  description: "Set the skill assignments for an agent. Replaces existing assignments.",
860
872
  inputSchema: {
861
- agentId: z2.string().describe("Agent ID (UUID)"),
862
- skills: z2.array(
863
- z2.object({
864
- skillName: z2.string().describe("Skill name to assign")
873
+ agentId: z3.string().describe("Agent ID (UUID)"),
874
+ skills: z3.array(
875
+ z3.object({
876
+ skillName: z3.string().describe("Skill name to assign")
865
877
  })
866
878
  ).describe("List of skills to assign")
867
879
  },
@@ -877,14 +889,14 @@ function registerSkillTools(server, client, ctx) {
877
889
  }
878
890
 
879
891
  // src/tools/agent-mcp.ts
880
- import { z as z3 } from "zod";
892
+ import { z as z4 } from "zod";
881
893
  function registerAgentMcpTools(server, client, ctx) {
882
894
  server.registerTool(
883
895
  "get-agent-mcp-servers",
884
896
  {
885
- description: "List MCP servers assigned to a specific agent.",
897
+ description: "List MCP servers assigned to a specific agent, each with its `mode` (what the owner role gets) and its `guestMode` (what anyone else talking to the agent gets; null = not in the guest profile).",
886
898
  inputSchema: {
887
- agentId: z3.string().describe("Agent ID (UUID)")
899
+ agentId: z4.string().describe("Agent ID (UUID)")
888
900
  },
889
901
  annotations: { readOnlyHint: true }
890
902
  },
@@ -897,20 +909,24 @@ function registerAgentMcpTools(server, client, ctx) {
897
909
  server.registerTool(
898
910
  "set-agent-mcp-servers",
899
911
  {
900
- description: "Set the MCP server assignments for an agent. Replaces existing assignments. Optionally set per-server access mode via `modes` (keyed by MCP server id); ids omitted from `modes` default to 'write' (read-write).",
912
+ description: "Set the MCP server assignments for an agent. Replaces existing assignments. Optionally set per-server access mode via `modes` (keyed by MCP server id); ids omitted from `modes` default to 'write' (read-write). `guestModes` is the guest profile \u2014 what someone outside the agent's owner role gets on each server: omit it to leave the guest profile as it is (a newly assigned server starts out of it); pass it and the ids it omits leave the guest profile. A server whose integration the owner role does not use is refused (INTEGRATION_NOT_GRANTED); list-mcp-servers with ownerRoleId says which ones it may have.",
901
913
  inputSchema: {
902
- agentId: z3.string().describe("Agent ID (UUID)"),
903
- mcpServerIds: z3.array(z3.string()).describe("List of MCP Server IDs (UUIDs) to assign"),
904
- modes: z3.record(z3.enum(["read", "write"])).optional().describe(
914
+ agentId: z4.string().describe("Agent ID (UUID)"),
915
+ mcpServerIds: z4.array(z4.string()).describe("List of MCP Server IDs (UUIDs) to assign"),
916
+ modes: z4.record(z4.enum(["read", "write"])).optional().describe(
905
917
  "Per-server access mode keyed by MCP server id: 'read' (read-only tools) or 'write' (all tools). Omitted ids default to 'write'."
918
+ ),
919
+ guestModes: z4.record(z4.enum(["read", "write"])).optional().describe(
920
+ "Guest profile keyed by MCP server id, same values as `modes`. Absent = unchanged; present = only these ids are offered to guests."
906
921
  )
907
922
  },
908
923
  annotations: { readOnlyHint: false, destructiveHint: false }
909
924
  },
910
- async ({ agentId, mcpServerIds, modes }) => {
925
+ async ({ agentId, mcpServerIds, modes, guestModes }) => {
911
926
  const page = await client.put(`/api/agents/${agentId}/mcp-servers`, {
912
927
  mcpServerIds,
913
- modes
928
+ modes,
929
+ guestModes
914
930
  });
915
931
  return jsonResult({ mcpServerIds: page.items });
916
932
  }
@@ -922,7 +938,12 @@ function createServer(config) {
922
938
  return createSurfaceServer({
923
939
  name: "dudamel-agents",
924
940
  instructions: `Dudamel Agents MCP \u2014 manage agents, skills, and their skill/MCP/sub-agent assignments. Running as role=${config.role}, readOnly=${config.readOnly ?? false}.`,
925
- registrars: [registerAgentTools, registerSkillTools, registerAgentMcpTools],
941
+ registrars: [
942
+ registerAgentTools,
943
+ registerSkillTools,
944
+ registerAgentMcpTools,
945
+ registerOwnerTools(["agent", "skill"])
946
+ ],
926
947
  config
927
948
  });
928
949
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,4DAUnD"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,4DAenD"}
@@ -39,6 +39,10 @@ var DudamelApiError = class extends Error {
39
39
  if (apiError?.context?.["inputsSchema"] !== void 0) {
40
40
  lines.push(`Expected inputs schema: ${JSON.stringify(apiError.context["inputsSchema"])}`);
41
41
  }
42
+ const rest = Object.entries(apiError?.context ?? {}).filter(([key]) => key !== "inputsSchema");
43
+ if (rest.length > 0) {
44
+ lines.push(`Context: ${JSON.stringify(Object.fromEntries(rest))}`);
45
+ }
42
46
  super(lines.join("\n"));
43
47
  this.status = status;
44
48
  this.statusText = statusText;
@@ -195,10 +199,42 @@ function jsonResult(data) {
195
199
  };
196
200
  }
197
201
 
202
+ // ../common/dist/owner-tools.js
203
+ import { z } from "zod";
204
+ function registerOwnerTools(kinds) {
205
+ return (server2, client, ctx2) => {
206
+ if (ctx2.role !== "admin")
207
+ return;
208
+ const what = kinds.join(", ");
209
+ const inputSchema = {
210
+ kind: z.enum(kinds).describe("What is handed over"),
211
+ id: z.string().describe(`The ${what} ID (UUID)`),
212
+ ownerRoleId: z.string().describe("The new owner role ID (UUID)")
213
+ };
214
+ const path = (kind, id) => `/api/${kind}s/${id}`;
215
+ server2.registerTool("get-owner-impact", {
216
+ description: `Admin. What breaks if a ${what} is handed to another role \u2014 nothing is changed. Lists the integrations it uses that the new role does not (they fail visibly until an admin adds the role to them, with set-integration-roles), the agent \u2194 workflow links that end up crossing roles (an agent only fires workflows of its own role), the workflows that run the agent and are not of the new role (it runs there as a guest) and, for a skill, the agents it is assigned to (they block the move: change the agent's owner instead, it takes its skills along). Show it to the person before set-owner.`,
217
+ inputSchema,
218
+ annotations: { readOnlyHint: true }
219
+ }, async ({ kind, id, ownerRoleId }) => {
220
+ const impact = await client.get(`${path(kind, id)}/owner-impact`, { ownerRoleId });
221
+ return jsonResult(impact);
222
+ });
223
+ server2.registerTool("set-owner", {
224
+ description: `Admin. Hand a ${what} to another role (its owner role): that role's members edit it and it runs with that role's permissions. ALWAYS call get-owner-impact first with the same arguments, show the person what breaks and call this only once they confirm with that list in front of them. Adding the new role to the integrations it lacks is a separate decision (set-integration-roles), never implied by this. An agent takes its sub-agents and skills along (a skill other agents of the old role also use is copied); a sub-agent carries its parent's role, so move the parent. System resources have no owner role.`,
225
+ inputSchema,
226
+ annotations: { readOnlyHint: false, destructiveHint: false }
227
+ }, async ({ kind, id, ownerRoleId }) => {
228
+ const result = await client.put(`${path(kind, id)}/owner`, { ownerRoleId });
229
+ return jsonResult(result);
230
+ });
231
+ };
232
+ }
233
+
198
234
  // src/tools/agents.ts
199
235
  import { readFile, stat } from "node:fs/promises";
200
236
  import { extname, resolve } from "node:path";
201
- import { z } from "zod";
237
+ import { z as z2 } from "zod";
202
238
  function registerAgentTools(server2, client, ctx2) {
203
239
  server2.registerTool(
204
240
  "list-agents",
@@ -216,7 +252,7 @@ function registerAgentTools(server2, client, ctx2) {
216
252
  {
217
253
  description: "Get detailed information about a specific agent, including prompt sections, system prompt, and config.",
218
254
  inputSchema: {
219
- id: z.string().describe("Agent ID (UUID)")
255
+ id: z2.string().describe("Agent ID (UUID)")
220
256
  },
221
257
  annotations: { readOnlyHint: true }
222
258
  },
@@ -230,7 +266,7 @@ function registerAgentTools(server2, client, ctx2) {
230
266
  {
231
267
  description: "List the sub-agents assigned to a specific (parent) agent.",
232
268
  inputSchema: {
233
- id: z.string().describe("Parent agent ID (UUID)")
269
+ id: z2.string().describe("Parent agent ID (UUID)")
234
270
  },
235
271
  annotations: { readOnlyHint: true }
236
272
  },
@@ -244,8 +280,8 @@ function registerAgentTools(server2, client, ctx2) {
244
280
  {
245
281
  description: "Download an agent definition (persona + skills) as files in the target tool's on-disk layout (e.g. .claude/agents/<name>.md + .claude/skills/ for Claude Code). Returns {agentName, files: [{path, content, skipIfExists?}]} \u2014 write each file at its path relative to the current working directory; do NOT overwrite existing files marked skipIfExists. Iterate locally, then push changes back with update-agent/update-skill.",
246
282
  inputSchema: {
247
- id: z.string().describe("Agent ID (UUID)"),
248
- format: z.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
283
+ id: z2.string().describe("Agent ID (UUID)"),
284
+ format: z2.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
249
285
  "Target tool layout \u2014 defaults to 'claude-code'; 'raw' is a dudamel-native <name>/AGENT.md layout"
250
286
  )
251
287
  },
@@ -261,18 +297,18 @@ function registerAgentTools(server2, client, ctx2) {
261
297
  {
262
298
  description: "Update an agent definition. Requires edit permission on the agent (business-role permission or admin).",
263
299
  inputSchema: {
264
- id: z.string().describe("Agent ID (UUID)"),
265
- name: z.string().optional().describe("New name"),
266
- displayName: z.string().optional().describe("New display name"),
267
- description: z.string().optional().describe("New description"),
268
- identity: z.string().optional().describe("New identity"),
269
- instructions: z.string().optional().describe("New instructions"),
270
- systemPrompt: z.string().optional().describe("New system prompt"),
271
- model: z.string().optional().describe("New model identifier"),
272
- skipPermissions: z.boolean().optional().describe("Skip permission prompts"),
273
- driverProvider: z.string().optional().describe("New AI provider instance name"),
274
- driverMode: z.enum(["api", "cli"]).optional().describe("New driver mode"),
275
- kind: z.enum(["system", "user"]).optional().describe(
300
+ id: z2.string().describe("Agent ID (UUID)"),
301
+ name: z2.string().optional().describe("New name"),
302
+ displayName: z2.string().optional().describe("New display name"),
303
+ description: z2.string().optional().describe("New description"),
304
+ identity: z2.string().optional().describe("New identity"),
305
+ instructions: z2.string().optional().describe("New instructions"),
306
+ systemPrompt: z2.string().optional().describe("New system prompt"),
307
+ model: z2.string().optional().describe("New model identifier"),
308
+ skipPermissions: z2.boolean().optional().describe("Skip permission prompts"),
309
+ driverProvider: z2.string().optional().describe("New AI provider instance name"),
310
+ driverMode: z2.enum(["api", "cli"]).optional().describe("New driver mode"),
311
+ kind: z2.enum(["system", "user"]).optional().describe(
276
312
  "Agent kind \u2014 set to 'user' to convert a disk-seeded 'system' agent into a normal editable user agent"
277
313
  )
278
314
  },
@@ -288,8 +324,8 @@ function registerAgentTools(server2, client, ctx2) {
288
324
  {
289
325
  description: "Set the sub-agent assignments for a (parent) agent. Replaces existing assignments. Each sub-agent id must be an agent created with isSubAgent=true. Requires edit permission on the parent agent.",
290
326
  inputSchema: {
291
- id: z.string().describe("Parent agent ID (UUID)"),
292
- subAgentIds: z.array(z.string()).describe("Sub-agent IDs (UUIDs) to assign")
327
+ id: z2.string().describe("Parent agent ID (UUID)"),
328
+ subAgentIds: z2.array(z2.string()).describe("Sub-agent IDs (UUIDs) to assign")
293
329
  },
294
330
  annotations: { readOnlyHint: false, destructiveHint: false }
295
331
  },
@@ -305,7 +341,7 @@ function registerAgentTools(server2, client, ctx2) {
305
341
  {
306
342
  description: "Activate an agent so it starts receiving and answering messages.",
307
343
  inputSchema: {
308
- id: z.string().describe("Agent ID (UUID)")
344
+ id: z2.string().describe("Agent ID (UUID)")
309
345
  },
310
346
  annotations: { readOnlyHint: false, destructiveHint: false }
311
347
  },
@@ -319,7 +355,7 @@ function registerAgentTools(server2, client, ctx2) {
319
355
  {
320
356
  description: "Deactivate an agent \u2014 it stops receiving messages (Slack, dashboard chat) until reactivated. The definition is kept; this is the way to silence an agent without deleting it.",
321
357
  inputSchema: {
322
- id: z.string().describe("Agent ID (UUID)")
358
+ id: z2.string().describe("Agent ID (UUID)")
323
359
  },
324
360
  annotations: { readOnlyHint: false, destructiveHint: false }
325
361
  },
@@ -333,8 +369,8 @@ function registerAgentTools(server2, client, ctx2) {
333
369
  {
334
370
  description: "Set an agent's avatar (its picture in the Dashboard, chat and lists) from an image file on disk \u2014 typically one the user attached to the conversation, which you find under `.attachments/` in your workspace. PNG, JPEG, WebP or GIF, under 2 MB. Replaces the current avatar. Needs edit permission on the agent.",
335
371
  inputSchema: {
336
- id: z.string().describe("Agent ID (UUID)"),
337
- imagePath: z.string().describe("Path to the image file, e.g. .attachments/selfie.png (relative to your cwd)")
372
+ id: z2.string().describe("Agent ID (UUID)"),
373
+ imagePath: z2.string().describe("Path to the image file, e.g. .attachments/selfie.png (relative to your cwd)")
338
374
  },
339
375
  annotations: { readOnlyHint: false, destructiveHint: false }
340
376
  },
@@ -344,16 +380,42 @@ function registerAgentTools(server2, client, ctx2) {
344
380
  return jsonResult({ id, avatar: { mimeType, bytes } });
345
381
  }
346
382
  );
383
+ server2.registerTool(
384
+ "create-agent",
385
+ {
386
+ description: "Create a new agent definition. It belongs to one role (its owner role): the members of that role configure it and talk to it with the full profile; anyone else is a guest. If the person has several roles, ask them which one and pass ownerRoleId. A sub-agent (parentAgentId) takes its parent's role instead.",
387
+ inputSchema: {
388
+ name: z2.string().describe("Agent name (unique, kebab-case)"),
389
+ displayName: z2.string().optional().describe("Display name shown in the UI"),
390
+ description: z2.string().optional().describe("Agent description"),
391
+ identity: z2.string().optional().describe('Agent identity (e.g. "senior backend developer")'),
392
+ instructions: z2.string().optional().describe("Agent instructions (appended to system prompt)"),
393
+ systemPrompt: z2.string().optional().describe("System prompt for the agent"),
394
+ model: z2.string().optional().describe('Model identifier (e.g. "claude-sonnet-4-6")'),
395
+ skipPermissions: z2.boolean().optional().describe("Skip permission prompts in coding agents"),
396
+ driverProvider: z2.string().optional().describe("AI provider instance name for the driver"),
397
+ driverMode: z2.enum(["api", "cli"]).optional().describe("Driver mode: api (conversational) or cli (coding)"),
398
+ isSubAgent: z2.boolean().optional().describe("Mark as a sub-agent (not shown in top-level lists)"),
399
+ ownerRoleId: z2.string().optional().describe("Owner role id \u2014 required when the person has several roles"),
400
+ parentAgentId: z2.string().optional().describe("Create it as a sub-agent of this agent (it takes the parent's role)")
401
+ },
402
+ annotations: { readOnlyHint: false, destructiveHint: false }
403
+ },
404
+ async ({ name, ...rest }) => {
405
+ const result = await client.post("/api/agents", { name, ...rest });
406
+ return jsonResult(result);
407
+ }
408
+ );
347
409
  if (ctx2.role !== "admin") return;
348
410
  server2.registerTool(
349
411
  "get-agent-logs",
350
412
  {
351
413
  description: "Get the agent's recent conversational turns, newest first \u2014 status, duration, model, tokens, the MCP servers the turn brought up, and the failure reason when it failed. This is the way to debug an agent that is not answering: a `failed` turn carries the error code and the CLI stderr tail. Returns metadata only, never the conversation text.",
352
414
  inputSchema: {
353
- id: z.string().describe("Agent ID (UUID)"),
354
- status: z.enum(["completed", "failed"]).optional().describe("Only return turns with this outcome"),
355
- limit: z.number().int().min(1).max(200).optional().describe("Number of turns to return (default: 50)"),
356
- offset: z.number().int().min(0).optional().describe("Pagination offset")
415
+ id: z2.string().describe("Agent ID (UUID)"),
416
+ status: z2.enum(["completed", "failed"]).optional().describe("Only return turns with this outcome"),
417
+ limit: z2.number().int().min(1).max(200).optional().describe("Number of turns to return (default: 50)"),
418
+ offset: z2.number().int().min(0).optional().describe("Pagination offset")
357
419
  },
358
420
  annotations: { readOnlyHint: true }
359
421
  },
@@ -380,7 +442,7 @@ function registerAgentTools(server2, client, ctx2) {
380
442
  {
381
443
  description: "Get token usage statistics per agent over a time window. Useful for monitoring costs.",
382
444
  inputSchema: {
383
- windowHours: z.number().int().min(1).optional().describe("Time window in hours (default: 24)")
445
+ windowHours: z2.number().int().min(1).optional().describe("Time window in hours (default: 24)")
384
446
  },
385
447
  annotations: { readOnlyHint: true }
386
448
  },
@@ -391,30 +453,6 @@ function registerAgentTools(server2, client, ctx2) {
391
453
  return jsonResult({ items: page.items, total: page.total });
392
454
  }
393
455
  );
394
- server2.registerTool(
395
- "create-agent",
396
- {
397
- description: "Create a new agent definition.",
398
- inputSchema: {
399
- name: z.string().describe("Agent name (unique, kebab-case)"),
400
- displayName: z.string().optional().describe("Display name shown in the UI"),
401
- description: z.string().optional().describe("Agent description"),
402
- identity: z.string().optional().describe('Agent identity (e.g. "senior backend developer")'),
403
- instructions: z.string().optional().describe("Agent instructions (appended to system prompt)"),
404
- systemPrompt: z.string().optional().describe("System prompt for the agent"),
405
- model: z.string().optional().describe('Model identifier (e.g. "claude-sonnet-4-6")'),
406
- skipPermissions: z.boolean().optional().describe("Skip permission prompts in coding agents"),
407
- driverProvider: z.string().optional().describe("AI provider instance name for the driver"),
408
- driverMode: z.enum(["api", "cli"]).optional().describe("Driver mode: api (conversational) or cli (coding)"),
409
- isSubAgent: z.boolean().optional().describe("Mark as a sub-agent (not shown in top-level lists)")
410
- },
411
- annotations: { readOnlyHint: false, destructiveHint: false }
412
- },
413
- async ({ name, ...rest }) => {
414
- const result = await client.post("/api/agents", { name, ...rest });
415
- return jsonResult(result);
416
- }
417
- );
418
456
  }
419
457
  var AVATAR_MIME_BY_EXT = {
420
458
  ".png": "image/png",
@@ -444,7 +482,7 @@ async function readAvatarFile(imagePath) {
444
482
  }
445
483
 
446
484
  // src/tools/skills.ts
447
- import { z as z2 } from "zod";
485
+ import { z as z3 } from "zod";
448
486
 
449
487
  // src/skill-bundle.ts
450
488
  import { createHash } from "node:crypto";
@@ -640,8 +678,8 @@ function registerSkillTools(server2, client, ctx2) {
640
678
  {
641
679
  description: "List skill definitions (active by default). Metadata only \u2014 id, name, description, status, origin, version, file count and timestamps. Use get-skill or download-skill to read a specific skill.",
642
680
  inputSchema: {
643
- status: z2.enum(["active", "archived"]).optional().describe("Lifecycle filter \u2014 defaults to 'active'; pass 'archived' for archived skills"),
644
- query: z2.string().optional().describe("Case-insensitive substring match against the name and description")
681
+ status: z3.enum(["active", "archived"]).optional().describe("Lifecycle filter \u2014 defaults to 'active'; pass 'archived' for archived skills"),
682
+ query: z3.string().optional().describe("Case-insensitive substring match against the name and description")
645
683
  },
646
684
  annotations: { readOnlyHint: true }
647
685
  },
@@ -660,8 +698,8 @@ function registerSkillTools(server2, client, ctx2) {
660
698
  {
661
699
  description: "Get detailed information about a specific skill, including content, allowed tools, files, and version info. For a large skill prefer download-skill with outDir, which puts the files on disk instead of in the conversation.",
662
700
  inputSchema: {
663
- id: z2.string().describe("Skill ID (UUID)"),
664
- includeContent: z2.boolean().optional().describe(
701
+ id: z3.string().describe("Skill ID (UUID)"),
702
+ includeContent: z3.boolean().optional().describe(
665
703
  "Defaults to true. With false, returns metadata plus a size and sha256 per file \u2014 enough to check what is stored without pulling the content in."
666
704
  )
667
705
  },
@@ -686,7 +724,7 @@ function registerSkillTools(server2, client, ctx2) {
686
724
  {
687
725
  description: "List version history for a skill. Returns version numbers, change summaries, and creation dates.",
688
726
  inputSchema: {
689
- id: z2.string().describe("Skill ID (UUID)")
727
+ id: z3.string().describe("Skill ID (UUID)")
690
728
  },
691
729
  annotations: { readOnlyHint: true }
692
730
  },
@@ -700,14 +738,14 @@ function registerSkillTools(server2, client, ctx2) {
700
738
  {
701
739
  description: "Download a skill as files in the target tool's on-disk layout (e.g. .claude/skills/<name>/SKILL.md for Claude Code). With `outDir` the files are written to disk and only their paths, sizes and hashes come back \u2014 the way to handle a skill of any size. Without it, the content is returned inline. Then edit the folder and push it back with update-skill + skillDir.",
702
740
  inputSchema: {
703
- id: z2.string().describe("Skill ID (UUID)"),
704
- format: z2.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
741
+ id: z3.string().describe("Skill ID (UUID)"),
742
+ format: z3.enum(["claude-code", "codex", "kimi-code", "opencode", "raw"]).optional().describe(
705
743
  "Target tool layout \u2014 defaults to 'claude-code'; 'raw' is the dudamel-native <name>/SKILL.md layout"
706
744
  ),
707
- outDir: z2.string().optional().describe(
745
+ outDir: z3.string().optional().describe(
708
746
  "Directory to write the files into (created if missing). Paths from the chosen format are kept, so outDir is the root the layout hangs from."
709
747
  ),
710
- overwrite: z2.boolean().optional().describe(
748
+ overwrite: z3.boolean().optional().describe(
711
749
  "Defaults to false: if a file already exists with different content the call is rejected and nothing is written, so a re-download cannot erase edits in flight."
712
750
  )
713
751
  },
@@ -729,7 +767,7 @@ function registerSkillTools(server2, client, ctx2) {
729
767
  {
730
768
  description: "Get the skill definitions assigned to a specific agent.",
731
769
  inputSchema: {
732
- agentId: z2.string().describe("Agent ID (UUID)")
770
+ agentId: z3.string().describe("Agent ID (UUID)")
733
771
  },
734
772
  annotations: { readOnlyHint: true }
735
773
  },
@@ -742,25 +780,28 @@ function registerSkillTools(server2, client, ctx2) {
742
780
  server2.registerTool(
743
781
  "create-skill",
744
782
  {
745
- description: "Create a new skill definition. The creator becomes the owner and can edit it and share edition with business roles via set-skill-roles. Pass `skillDir` to upload a directory from disk instead of inlining every file. Returns the new version plus a size and sha256 per stored file. " + FILES_SEMANTICS,
783
+ description: "Create a new skill definition. It belongs to one role (its owner role): the members of that role edit it and assign it to the role's agents; another role that needs it makes its own copy. Pass `skillDir` to upload a directory from disk instead of inlining every file. Returns the new version plus a size and sha256 per stored file. " + FILES_SEMANTICS,
746
784
  inputSchema: {
747
- name: z2.string().describe("Skill name (unique, kebab-case)"),
748
- content: z2.string().optional().describe(
785
+ name: z3.string().describe("Skill name (unique within the role, kebab-case)"),
786
+ content: z3.string().optional().describe(
749
787
  "Skill content \u2014 the full SKILL.md is fine: its frontmatter (description, version, allowed-tools, model) is honored, and an argument passed explicitly here wins over it. Required unless skillDir is given."
750
788
  ),
751
- skillDir: z2.string().optional().describe(SKILL_DIR_HELP),
752
- description: z2.string().optional().describe("Skill description"),
753
- disableModelInvocation: z2.boolean().optional().describe("Disable model-triggered invocation"),
754
- userInvocable: z2.boolean().optional().describe("Allow user to invoke via slash command"),
755
- model: z2.string().optional().describe("Model identifier or tier"),
756
- allowedTools: z2.array(z2.string()).optional().describe("List of allowed tool names"),
757
- currentVersion: z2.string().optional().describe("Initial version string"),
758
- files: z2.array(
759
- z2.object({
760
- path: z2.string().describe("Relative file path within the skill"),
761
- content: z2.string().describe("File content")
789
+ skillDir: z3.string().optional().describe(SKILL_DIR_HELP),
790
+ description: z3.string().optional().describe("Skill description"),
791
+ disableModelInvocation: z3.boolean().optional().describe("Disable model-triggered invocation"),
792
+ userInvocable: z3.boolean().optional().describe("Allow user to invoke via slash command"),
793
+ model: z3.string().optional().describe("Model identifier or tier"),
794
+ allowedTools: z3.array(z3.string()).optional().describe("List of allowed tool names"),
795
+ currentVersion: z3.string().optional().describe("Initial version string"),
796
+ files: z3.array(
797
+ z3.object({
798
+ path: z3.string().describe("Relative file path within the skill"),
799
+ content: z3.string().describe("File content")
762
800
  })
763
- ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`)
801
+ ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`),
802
+ ownerRoleId: z3.string().optional().describe(
803
+ "Role the skill belongs to (its agents are that role's) \u2014 required when the person has several roles. A name is unique per role."
804
+ )
764
805
  },
765
806
  annotations: { readOnlyHint: false, destructiveHint: false }
766
807
  },
@@ -774,7 +815,8 @@ function registerSkillTools(server2, client, ctx2) {
774
815
  model,
775
816
  allowedTools,
776
817
  currentVersion,
777
- files
818
+ files,
819
+ ownerRoleId
778
820
  }) => {
779
821
  const bundle = await resolveBundle({ content, files, skillDir });
780
822
  if (bundle.content === void 0) {
@@ -789,7 +831,8 @@ function registerSkillTools(server2, client, ctx2) {
789
831
  model,
790
832
  allowedTools,
791
833
  currentVersion,
792
- files: bundle.files
834
+ files: bundle.files,
835
+ ownerRoleId
793
836
  });
794
837
  return jsonResult(writeReceipt(result));
795
838
  }
@@ -799,25 +842,25 @@ function registerSkillTools(server2, client, ctx2) {
799
842
  {
800
843
  description: "Update a skill definition. Creates a new version entry. Pass `skillDir` to upload an edited directory from disk in one call instead of retyping every file. Returns the new version plus a size and sha256 per stored file, so the upload can be verified without downloading it back. " + FILES_SEMANTICS,
801
844
  inputSchema: {
802
- id: z2.string().describe("Skill ID (UUID)"),
803
- name: z2.string().optional().describe(
845
+ id: z3.string().describe("Skill ID (UUID)"),
846
+ name: z3.string().optional().describe(
804
847
  "New skill name (unique, kebab-case) \u2014 rename the skill; agent assignments are by id and survive the rename"
805
848
  ),
806
- content: z2.string().optional().describe(
849
+ content: z3.string().optional().describe(
807
850
  "New skill content \u2014 the full SKILL.md is fine: its frontmatter (description, version, allowed-tools, model) is honored, and an argument passed explicitly here wins over it."
808
851
  ),
809
- skillDir: z2.string().optional().describe(SKILL_DIR_HELP),
810
- description: z2.string().optional().describe("New description"),
811
- disableModelInvocation: z2.boolean().optional().describe("Disable model-triggered invocation"),
812
- userInvocable: z2.boolean().optional().describe("Allow user to invoke via slash command"),
813
- model: z2.string().optional().describe("Model identifier or tier"),
814
- allowedTools: z2.array(z2.string()).optional().describe("List of allowed tool names"),
815
- currentVersion: z2.string().optional().describe("Version string for this update"),
816
- changeSummary: z2.string().optional().describe("Summary of what changed in this version"),
817
- files: z2.array(
818
- z2.object({
819
- path: z2.string().describe("Relative file path within the skill"),
820
- content: z2.string().describe("File content")
852
+ skillDir: z3.string().optional().describe(SKILL_DIR_HELP),
853
+ description: z3.string().optional().describe("New description"),
854
+ disableModelInvocation: z3.boolean().optional().describe("Disable model-triggered invocation"),
855
+ userInvocable: z3.boolean().optional().describe("Allow user to invoke via slash command"),
856
+ model: z3.string().optional().describe("Model identifier or tier"),
857
+ allowedTools: z3.array(z3.string()).optional().describe("List of allowed tool names"),
858
+ currentVersion: z3.string().optional().describe("Version string for this update"),
859
+ changeSummary: z3.string().optional().describe("Summary of what changed in this version"),
860
+ files: z3.array(
861
+ z3.object({
862
+ path: z3.string().describe("Relative file path within the skill"),
863
+ content: z3.string().describe("File content")
821
864
  })
822
865
  ).optional().describe(`Embedded skill files. ${FILES_SEMANTICS}`)
823
866
  },
@@ -842,7 +885,7 @@ function registerSkillTools(server2, client, ctx2) {
842
885
  {
843
886
  description: "Archive a skill (logical delete \u2014 versions and files are kept; it disappears from default listings and cannot be assigned). Fails with SKILL_IN_USE while assigned to agents: unassign it first.",
844
887
  inputSchema: {
845
- id: z2.string().describe("Skill ID (UUID)")
888
+ id: z3.string().describe("Skill ID (UUID)")
846
889
  },
847
890
  annotations: { readOnlyHint: false, destructiveHint: false }
848
891
  },
@@ -856,7 +899,7 @@ function registerSkillTools(server2, client, ctx2) {
856
899
  {
857
900
  description: "Restore an archived skill to active, making it assignable again.",
858
901
  inputSchema: {
859
- id: z2.string().describe("Skill ID (UUID)")
902
+ id: z3.string().describe("Skill ID (UUID)")
860
903
  },
861
904
  annotations: { readOnlyHint: false, destructiveHint: false }
862
905
  },
@@ -865,46 +908,15 @@ function registerSkillTools(server2, client, ctx2) {
865
908
  return jsonResult(result);
866
909
  }
867
910
  );
868
- server2.registerTool(
869
- "get-skill-roles",
870
- {
871
- description: "List the business roles that can edit a skill. Requires edit permission on the skill (owner, permitted role, or admin).",
872
- inputSchema: {
873
- id: z2.string().describe("Skill ID (UUID)")
874
- },
875
- annotations: { readOnlyHint: true }
876
- },
877
- async ({ id }) => {
878
- const page = await client.get(`/api/skills/${id}/permissions`);
879
- return jsonResult({ items: page.items, total: page.total });
880
- }
881
- );
882
- server2.registerTool(
883
- "set-skill-roles",
884
- {
885
- description: "Replace the set of business roles that can edit a skill. The owner uses this to share (or revoke) edition with team roles. Requires edit permission on the skill.",
886
- inputSchema: {
887
- id: z2.string().describe("Skill ID (UUID)"),
888
- roleIds: z2.array(z2.string()).describe("Business role IDs that may edit the skill")
889
- },
890
- annotations: { readOnlyHint: false, destructiveHint: false }
891
- },
892
- async ({ id, roleIds }) => {
893
- const page = await client.put(`/api/skills/${id}/permissions`, {
894
- roleIds
895
- });
896
- return jsonResult({ items: page.items });
897
- }
898
- );
899
911
  server2.registerTool(
900
912
  "set-agent-skills",
901
913
  {
902
914
  description: "Set the skill assignments for an agent. Replaces existing assignments.",
903
915
  inputSchema: {
904
- agentId: z2.string().describe("Agent ID (UUID)"),
905
- skills: z2.array(
906
- z2.object({
907
- skillName: z2.string().describe("Skill name to assign")
916
+ agentId: z3.string().describe("Agent ID (UUID)"),
917
+ skills: z3.array(
918
+ z3.object({
919
+ skillName: z3.string().describe("Skill name to assign")
908
920
  })
909
921
  ).describe("List of skills to assign")
910
922
  },
@@ -920,14 +932,14 @@ function registerSkillTools(server2, client, ctx2) {
920
932
  }
921
933
 
922
934
  // src/tools/agent-mcp.ts
923
- import { z as z3 } from "zod";
935
+ import { z as z4 } from "zod";
924
936
  function registerAgentMcpTools(server2, client, ctx2) {
925
937
  server2.registerTool(
926
938
  "get-agent-mcp-servers",
927
939
  {
928
- description: "List MCP servers assigned to a specific agent.",
940
+ description: "List MCP servers assigned to a specific agent, each with its `mode` (what the owner role gets) and its `guestMode` (what anyone else talking to the agent gets; null = not in the guest profile).",
929
941
  inputSchema: {
930
- agentId: z3.string().describe("Agent ID (UUID)")
942
+ agentId: z4.string().describe("Agent ID (UUID)")
931
943
  },
932
944
  annotations: { readOnlyHint: true }
933
945
  },
@@ -940,20 +952,24 @@ function registerAgentMcpTools(server2, client, ctx2) {
940
952
  server2.registerTool(
941
953
  "set-agent-mcp-servers",
942
954
  {
943
- description: "Set the MCP server assignments for an agent. Replaces existing assignments. Optionally set per-server access mode via `modes` (keyed by MCP server id); ids omitted from `modes` default to 'write' (read-write).",
955
+ description: "Set the MCP server assignments for an agent. Replaces existing assignments. Optionally set per-server access mode via `modes` (keyed by MCP server id); ids omitted from `modes` default to 'write' (read-write). `guestModes` is the guest profile \u2014 what someone outside the agent's owner role gets on each server: omit it to leave the guest profile as it is (a newly assigned server starts out of it); pass it and the ids it omits leave the guest profile. A server whose integration the owner role does not use is refused (INTEGRATION_NOT_GRANTED); list-mcp-servers with ownerRoleId says which ones it may have.",
944
956
  inputSchema: {
945
- agentId: z3.string().describe("Agent ID (UUID)"),
946
- mcpServerIds: z3.array(z3.string()).describe("List of MCP Server IDs (UUIDs) to assign"),
947
- modes: z3.record(z3.enum(["read", "write"])).optional().describe(
957
+ agentId: z4.string().describe("Agent ID (UUID)"),
958
+ mcpServerIds: z4.array(z4.string()).describe("List of MCP Server IDs (UUIDs) to assign"),
959
+ modes: z4.record(z4.enum(["read", "write"])).optional().describe(
948
960
  "Per-server access mode keyed by MCP server id: 'read' (read-only tools) or 'write' (all tools). Omitted ids default to 'write'."
961
+ ),
962
+ guestModes: z4.record(z4.enum(["read", "write"])).optional().describe(
963
+ "Guest profile keyed by MCP server id, same values as `modes`. Absent = unchanged; present = only these ids are offered to guests."
949
964
  )
950
965
  },
951
966
  annotations: { readOnlyHint: false, destructiveHint: false }
952
967
  },
953
- async ({ agentId, mcpServerIds, modes }) => {
968
+ async ({ agentId, mcpServerIds, modes, guestModes }) => {
954
969
  const page = await client.put(`/api/agents/${agentId}/mcp-servers`, {
955
970
  mcpServerIds,
956
- modes
971
+ modes,
972
+ guestModes
957
973
  });
958
974
  return jsonResult({ mcpServerIds: page.items });
959
975
  }
@@ -965,7 +981,12 @@ function createServer(config) {
965
981
  return createSurfaceServer({
966
982
  name: "dudamel-agents",
967
983
  instructions: `Dudamel Agents MCP \u2014 manage agents, skills, and their skill/MCP/sub-agent assignments. Running as role=${config.role}, readOnly=${config.readOnly ?? false}.`,
968
- registrars: [registerAgentTools, registerSkillTools, registerAgentMcpTools],
984
+ registrars: [
985
+ registerAgentTools,
986
+ registerSkillTools,
987
+ registerAgentMcpTools,
988
+ registerOwnerTools(["agent", "skill"])
989
+ ],
969
990
  config
970
991
  });
971
992
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agent-mcp.d.ts","sourceRoot":"","sources":["../../src/tools/agent-mcp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CAoDN"}
1
+ {"version":3,"file":"agent-mcp.d.ts","sourceRoot":"","sources":["../../src/tools/agent-mcp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CAoEN"}
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tools/agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CA2SN;AAYD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBjE"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tools/agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CAuTN;AAYD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/tools/skills.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA6FvD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CA+XN"}
1
+ {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/tools/skills.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA6FvD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,WAAW,GACf,IAAI,CAsWN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudamel/mcp-agents",
3
- "version": "2026.1104.1",
3
+ "version": "2026.1106.2",
4
4
  "description": "Dudamel agents MCP — stdio client for Dudamel's agents management surface over its REST API.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "esbuild": "^0.25.0",
35
- "@dudamel/contracts": "0.1.0",
36
35
  "@dudamel/mcp-common": "0.1.0",
36
+ "@dudamel/contracts": "0.1.0",
37
37
  "@dudamel/mcp-tool-contract": "0.1.0"
38
38
  },
39
39
  "scripts": {