wolfpack-mcp 1.0.51 → 1.0.53

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.
@@ -3,12 +3,25 @@
3
3
  * Registered only when the API key has the `agent_builder` capability.
4
4
  */
5
5
  import { z } from 'zod';
6
+ import { config } from './config.js';
7
+ const ORG_SLUG_PROP = {
8
+ org_slug: {
9
+ type: 'string',
10
+ description: 'Organisation slug. Required when you belong to multiple organisations. Use list_organisations to find slugs.',
11
+ },
12
+ };
6
13
  export const AGENT_BUILDER_TOOLS = [
14
+ // ─── Group 0: Organisations ─────────────────────────────────────────────
15
+ {
16
+ name: 'list_organisations',
17
+ description: 'List organisations you belong to. Use org_slug parameter in other agent builder tools when you belong to multiple organisations.',
18
+ inputSchema: { type: 'object', properties: {} },
19
+ },
7
20
  // ─── Group 1: Agent CRUD ─────────────────────────────────────────────────
8
21
  {
9
22
  name: 'list_agents',
10
23
  description: 'List all agents in the organisation. Returns name, status, template, and assigned projects.',
11
- inputSchema: { type: 'object', properties: {} },
24
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
12
25
  },
13
26
  {
14
27
  name: 'get_agent',
@@ -17,6 +30,7 @@ export const AGENT_BUILDER_TOOLS = [
17
30
  type: 'object',
18
31
  properties: {
19
32
  agent_id: { type: 'string', description: 'Agent profile ID' },
33
+ ...ORG_SLUG_PROP,
20
34
  },
21
35
  required: ['agent_id'],
22
36
  },
@@ -30,6 +44,7 @@ export const AGENT_BUILDER_TOOLS = [
30
44
  template_id: { type: 'string', description: 'Template ID to create the agent from' },
31
45
  name: { type: 'string', description: 'Display name for the agent' },
32
46
  config: { type: 'object', description: 'Optional agent-specific configuration' },
47
+ ...ORG_SLUG_PROP,
33
48
  },
34
49
  required: ['template_id', 'name'],
35
50
  },
@@ -42,6 +57,10 @@ export const AGENT_BUILDER_TOOLS = [
42
57
  properties: {
43
58
  agent_id: { type: 'string', description: 'Agent profile ID' },
44
59
  name: { type: 'string', description: 'Updated display name' },
60
+ username: {
61
+ type: 'string',
62
+ description: 'Username for the agent (e.g. "k9"). Set to null to clear.',
63
+ },
45
64
  instructions: {
46
65
  type: 'string',
47
66
  description: 'Agent-specific instructions (supplements template instructions). Set to null to clear.',
@@ -59,6 +78,7 @@ export const AGENT_BUILDER_TOOLS = [
59
78
  description: 'LLM model family (e.g. "sonnet"). Agent auto-upgrades to latest in family.',
60
79
  },
61
80
  scheduling_enabled: { type: 'boolean', description: 'Whether scheduled tasks are enabled' },
81
+ ...ORG_SLUG_PROP,
62
82
  },
63
83
  required: ['agent_id'],
64
84
  },
@@ -71,6 +91,7 @@ export const AGENT_BUILDER_TOOLS = [
71
91
  type: 'object',
72
92
  properties: {
73
93
  agent_id: { type: 'string', description: 'Agent profile ID' },
94
+ ...ORG_SLUG_PROP,
74
95
  },
75
96
  required: ['agent_id'],
76
97
  },
@@ -83,6 +104,7 @@ export const AGENT_BUILDER_TOOLS = [
83
104
  properties: {
84
105
  agent_id: { type: 'string', description: 'Agent profile ID' },
85
106
  project_slug: { type: 'string', description: 'Project slug to assign the agent to' },
107
+ ...ORG_SLUG_PROP,
86
108
  },
87
109
  required: ['agent_id', 'project_slug'],
88
110
  },
@@ -95,6 +117,7 @@ export const AGENT_BUILDER_TOOLS = [
95
117
  properties: {
96
118
  agent_id: { type: 'string', description: 'Agent profile ID' },
97
119
  project_slug: { type: 'string', description: 'Project slug to remove the agent from' },
120
+ ...ORG_SLUG_PROP,
98
121
  },
99
122
  required: ['agent_id', 'project_slug'],
100
123
  },
@@ -114,6 +137,7 @@ export const AGENT_BUILDER_TOOLS = [
114
137
  },
115
138
  limit: { type: 'number', description: 'Maximum sessions to return' },
116
139
  offset: { type: 'number', description: 'Sessions to skip for pagination' },
140
+ ...ORG_SLUG_PROP,
117
141
  },
118
142
  required: ['agent_id'],
119
143
  },
@@ -126,6 +150,7 @@ export const AGENT_BUILDER_TOOLS = [
126
150
  properties: {
127
151
  agent_id: { type: 'string', description: 'Agent profile ID' },
128
152
  session_id: { type: 'string', description: 'Session ID' },
153
+ ...ORG_SLUG_PROP,
129
154
  },
130
155
  required: ['agent_id', 'session_id'],
131
156
  },
@@ -140,6 +165,7 @@ export const AGENT_BUILDER_TOOLS = [
140
165
  session_id: { type: 'string', description: 'Session ID' },
141
166
  limit: { type: 'number', description: 'Turns to return' },
142
167
  offset: { type: 'number', description: 'Turns to skip' },
168
+ ...ORG_SLUG_PROP,
143
169
  },
144
170
  required: ['agent_id', 'session_id'],
145
171
  },
@@ -154,6 +180,7 @@ export const AGENT_BUILDER_TOOLS = [
154
180
  agent_id: { type: 'string', description: 'Agent profile ID' },
155
181
  prompt: { type: 'string', description: 'What the agent should do' },
156
182
  project_slug: { type: 'string', description: 'Project to scope the session to (optional)' },
183
+ ...ORG_SLUG_PROP,
157
184
  },
158
185
  required: ['agent_id', 'prompt'],
159
186
  },
@@ -166,6 +193,7 @@ export const AGENT_BUILDER_TOOLS = [
166
193
  properties: {
167
194
  agent_id: { type: 'string', description: 'Agent profile ID' },
168
195
  session_id: { type: 'string', description: 'Session ID to stop' },
196
+ ...ORG_SLUG_PROP,
169
197
  },
170
198
  required: ['agent_id', 'session_id'],
171
199
  },
@@ -179,6 +207,7 @@ export const AGENT_BUILDER_TOOLS = [
179
207
  agent_id: { type: 'string', description: 'Agent profile ID' },
180
208
  session_id: { type: 'string', description: 'Completed session ID to resume' },
181
209
  prompt: { type: 'string', description: 'Follow-up prompt for the agent' },
210
+ ...ORG_SLUG_PROP,
182
211
  },
183
212
  required: ['agent_id', 'session_id', 'prompt'],
184
213
  },
@@ -191,6 +220,7 @@ export const AGENT_BUILDER_TOOLS = [
191
220
  type: 'object',
192
221
  properties: {
193
222
  agent_id: { type: 'string', description: 'Agent profile ID' },
223
+ ...ORG_SLUG_PROP,
194
224
  },
195
225
  required: ['agent_id'],
196
226
  },
@@ -203,6 +233,7 @@ export const AGENT_BUILDER_TOOLS = [
203
233
  properties: {
204
234
  agent_id: { type: 'string', description: 'Agent profile ID' },
205
235
  task_id: { type: 'string', description: 'Task ID' },
236
+ ...ORG_SLUG_PROP,
206
237
  },
207
238
  required: ['agent_id', 'task_id'],
208
239
  },
@@ -224,6 +255,7 @@ export const AGENT_BUILDER_TOOLS = [
224
255
  type: 'number',
225
256
  description: 'Order within scheduled batch (lower = first)',
226
257
  },
258
+ ...ORG_SLUG_PROP,
227
259
  },
228
260
  required: ['agent_id', 'name', 'prompt'],
229
261
  },
@@ -241,6 +273,7 @@ export const AGENT_BUILDER_TOOLS = [
241
273
  scheduled_enabled: { type: 'boolean', description: 'Include in scheduled runs' },
242
274
  sort_order: { type: 'number', description: 'Order within scheduled batch' },
243
275
  is_active: { type: 'boolean', description: 'Whether this task is active' },
276
+ ...ORG_SLUG_PROP,
244
277
  },
245
278
  required: ['agent_id', 'task_id'],
246
279
  },
@@ -255,6 +288,7 @@ export const AGENT_BUILDER_TOOLS = [
255
288
  agent_id: { type: 'string', description: 'Agent profile ID' },
256
289
  task_id: { type: 'string', description: 'Task ID to run' },
257
290
  project_slug: { type: 'string', description: 'Project to scope the session to (optional)' },
291
+ ...ORG_SLUG_PROP,
258
292
  },
259
293
  required: ['agent_id', 'task_id'],
260
294
  },
@@ -271,6 +305,7 @@ export const AGENT_BUILDER_TOOLS = [
271
305
  enum: ['queued', 'running', 'completed', 'failed', 'cancelled'],
272
306
  description: 'Filter by queue entry status',
273
307
  },
308
+ ...ORG_SLUG_PROP,
274
309
  },
275
310
  required: ['agent_id'],
276
311
  },
@@ -283,6 +318,7 @@ export const AGENT_BUILDER_TOOLS = [
283
318
  properties: {
284
319
  agent_id: { type: 'string', description: 'Agent profile ID' },
285
320
  entry_id: { type: 'string', description: 'Queue entry ID to cancel' },
321
+ ...ORG_SLUG_PROP,
286
322
  },
287
323
  required: ['agent_id', 'entry_id'],
288
324
  },
@@ -290,7 +326,8 @@ export const AGENT_BUILDER_TOOLS = [
290
326
  // ─── Group 5: Skills (authoring) ─────────────────────────────────────────
291
327
  {
292
328
  name: 'create_skill',
293
- description: 'Create a new org-level skill. Skills are reusable capability packs agents can load on demand.',
329
+ description: 'Create a skill. By default creates an org-level skill. ' +
330
+ 'Pass agent_id to create an agent-private skill scoped to that agent only.',
294
331
  inputSchema: {
295
332
  type: 'object',
296
333
  properties: {
@@ -306,6 +343,11 @@ export const AGENT_BUILDER_TOOLS = [
306
343
  type: 'string',
307
344
  description: 'Instruction body in markdown',
308
345
  },
346
+ agent_id: {
347
+ type: 'string',
348
+ description: 'Agent profile ID. When provided, creates an agent-private skill instead of org-level.',
349
+ },
350
+ ...ORG_SLUG_PROP,
309
351
  },
310
352
  required: ['name', 'description', 'content'],
311
353
  },
@@ -320,6 +362,7 @@ export const AGENT_BUILDER_TOOLS = [
320
362
  name: { type: 'string', description: 'Updated skill name' },
321
363
  description: { type: 'string', description: 'Updated description' },
322
364
  content: { type: 'string', description: 'Updated instruction body' },
365
+ ...ORG_SLUG_PROP,
323
366
  },
324
367
  required: ['skill_id'],
325
368
  },
@@ -339,6 +382,7 @@ export const AGENT_BUILDER_TOOLS = [
339
382
  name: { type: 'string', description: 'Resource filename' },
340
383
  content: { type: 'string', description: 'Resource text content' },
341
384
  mime_type: { type: 'string', description: 'MIME type (optional)' },
385
+ ...ORG_SLUG_PROP,
342
386
  },
343
387
  required: ['skill_id', 'type', 'name', 'content'],
344
388
  },
@@ -354,6 +398,7 @@ export const AGENT_BUILDER_TOOLS = [
354
398
  name: { type: 'string', description: 'Updated filename' },
355
399
  content: { type: 'string', description: 'Updated text content' },
356
400
  mime_type: { type: 'string', description: 'Updated MIME type' },
401
+ ...ORG_SLUG_PROP,
357
402
  },
358
403
  required: ['skill_id', 'resource_id'],
359
404
  },
@@ -371,22 +416,31 @@ export const AGENT_BUILDER_TOOLS = [
371
416
  items: { type: 'string' },
372
417
  description: 'Array of skill IDs to assign (replaces all current assignments)',
373
418
  },
419
+ ...ORG_SLUG_PROP,
374
420
  },
375
421
  required: ['agent_id', 'skill_ids'],
376
422
  },
377
423
  },
378
- // ─── Group 5b: Skills (reading org library) ──────────────────────────────
424
+ // ─── Group 5b: Skills (reading) ─────────────────────────────────────────
379
425
  {
380
- name: 'list_org_skills',
381
- description: 'List all skills in the org skill library (org-level + system-level). ' +
382
- 'Returns ID, name, description, and whether the skill is built-in. ' +
383
- 'Use skill IDs with set_agent_skills to assign skills to an agent.',
384
- inputSchema: { type: 'object', properties: {} },
426
+ name: 'list_agent_skills',
427
+ description: 'List all skills for a specific agent: agent-private skills + linked org skills + built-in skills. ' +
428
+ 'Returns full skill objects with IDs. Agent-scoped skills have agentProfileId set. ' +
429
+ 'Use this to see what skills an agent has and get IDs for update_skill.',
430
+ inputSchema: {
431
+ type: 'object',
432
+ properties: {
433
+ agent_id: { type: 'string', description: 'Agent profile ID' },
434
+ },
435
+ required: ['agent_id'],
436
+ },
385
437
  },
386
438
  {
387
- name: 'get_org_skill',
388
- description: 'Get the full content of an org-level skill by name. ' +
389
- 'Returns instructions, metadata, and a list of attached resources.',
439
+ name: 'get_skill_detail',
440
+ description: 'Get the full content of a skill by name. ' +
441
+ 'Returns instructions, metadata, and a list of attached resources. ' +
442
+ 'With agent_id: resolves agent-private → org → system (use after list_agent_skills). ' +
443
+ 'Without agent_id: resolves org → system (use after list_org_skills).',
390
444
  inputSchema: {
391
445
  type: 'object',
392
446
  properties: {
@@ -394,10 +448,22 @@ export const AGENT_BUILDER_TOOLS = [
394
448
  type: 'string',
395
449
  description: 'The name of the skill to load (e.g. "deploy-app")',
396
450
  },
451
+ agent_id: {
452
+ type: 'string',
453
+ description: 'Agent profile ID. When provided, resolves with agent-scoped precedence (agent → org → system).',
454
+ },
455
+ ...ORG_SLUG_PROP,
397
456
  },
398
457
  required: ['skill_name'],
399
458
  },
400
459
  },
460
+ {
461
+ name: 'list_org_skills',
462
+ description: 'List all skills in the org skill library (org-level + system-level). ' +
463
+ 'Returns ID, name, description, and whether the skill is built-in. ' +
464
+ 'Use skill IDs with set_agent_skills to assign skills to an agent.',
465
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
466
+ },
401
467
  // ─── Group 6: Secrets ─────────────────────────────────────────────────────
402
468
  {
403
469
  name: 'list_agent_secrets',
@@ -406,6 +472,7 @@ export const AGENT_BUILDER_TOOLS = [
406
472
  type: 'object',
407
473
  properties: {
408
474
  agent_id: { type: 'string', description: 'Agent profile ID' },
475
+ ...ORG_SLUG_PROP,
409
476
  },
410
477
  required: ['agent_id'],
411
478
  },
@@ -420,6 +487,7 @@ export const AGENT_BUILDER_TOOLS = [
420
487
  agent_id: { type: 'string', description: 'Agent profile ID' },
421
488
  name: { type: 'string', description: 'Secret name (e.g. MY_API_KEY)' },
422
489
  value: { type: 'string', description: 'Secret value (encrypted at rest)' },
490
+ ...ORG_SLUG_PROP,
423
491
  },
424
492
  required: ['agent_id', 'name', 'value'],
425
493
  },
@@ -428,31 +496,50 @@ export const AGENT_BUILDER_TOOLS = [
428
496
  {
429
497
  name: 'list_agent_templates',
430
498
  description: 'List agent templates available to the organisation. Use template IDs when calling create_agent.',
431
- inputSchema: { type: 'object', properties: {} },
499
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
432
500
  },
433
501
  {
434
502
  name: 'list_llm_models',
435
503
  description: 'List LLM providers and models available to the organisation. ' +
436
504
  'Use provider and model IDs when calling create_agent or update_agent.',
437
- inputSchema: { type: 'object', properties: {} },
505
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
438
506
  },
439
507
  ];
508
+ // Zod helper: org_slug with config fallback
509
+ const orgSlugField = z.string().optional();
510
+ function resolveOrg(parsed) {
511
+ return parsed.org_slug || config.orgSlug;
512
+ }
440
513
  // Zod schemas for argument parsing
441
- const AgentIdSchema = z.object({ agent_id: z.string() });
442
- const AgentSessionSchema = z.object({ agent_id: z.string(), session_id: z.string() });
443
- const AgentTaskSchema = z.object({ agent_id: z.string(), task_id: z.string() });
444
- const SkillIdSchema = z.object({ skill_id: z.string() });
514
+ const AgentIdSchema = z.object({ agent_id: z.string(), org_slug: orgSlugField });
515
+ const AgentSessionSchema = z.object({
516
+ agent_id: z.string(),
517
+ session_id: z.string(),
518
+ org_slug: orgSlugField,
519
+ });
520
+ const AgentTaskSchema = z.object({
521
+ agent_id: z.string(),
522
+ task_id: z.string(),
523
+ org_slug: orgSlugField,
524
+ });
525
+ const SkillIdSchema = z.object({ skill_id: z.string(), org_slug: orgSlugField });
445
526
  export async function handleAgentBuilderTool(name, args, client) {
446
527
  const text = (t) => JSON.stringify(t, null, 2);
447
528
  switch (name) {
529
+ // ─── Organisations ─────────────────────────────────────────────────────
530
+ case 'list_organisations': {
531
+ const orgs = await client.listOrganisations();
532
+ return { content: [{ type: 'text', text: text(orgs) }] };
533
+ }
448
534
  // ─── Agent CRUD ────────────────────────────────────────────────────────
449
535
  case 'list_agents': {
450
- const agents = await client.listAgents();
536
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
537
+ const agents = await client.listAgents(resolveOrg(parsed));
451
538
  return { content: [{ type: 'text', text: text(agents) }] };
452
539
  }
453
540
  case 'get_agent': {
454
- const { agent_id } = AgentIdSchema.parse(args);
455
- const agent = await client.getAgent(agent_id);
541
+ const parsed = AgentIdSchema.parse(args);
542
+ const agent = await client.getAgent(parsed.agent_id, resolveOrg(parsed));
456
543
  if (!agent)
457
544
  return { content: [{ type: 'text', text: 'Agent not found' }] };
458
545
  return { content: [{ type: 'text', text: text(agent) }] };
@@ -463,13 +550,14 @@ export async function handleAgentBuilderTool(name, args, client) {
463
550
  template_id: z.string(),
464
551
  name: z.string(),
465
552
  config: z.record(z.unknown()).optional(),
553
+ org_slug: orgSlugField,
466
554
  })
467
555
  .parse(args);
468
556
  const agent = await client.createAgent({
469
557
  templateId: parsed.template_id,
470
558
  name: parsed.name,
471
559
  config: parsed.config,
472
- });
560
+ }, resolveOrg(parsed));
473
561
  return {
474
562
  content: [
475
563
  {
@@ -484,17 +572,21 @@ export async function handleAgentBuilderTool(name, args, client) {
484
572
  .object({
485
573
  agent_id: z.string(),
486
574
  name: z.string().optional(),
575
+ username: z.string().nullable().optional(),
487
576
  instructions: z.string().nullable().optional(),
488
577
  llm_provider: z.string().nullable().optional(),
489
578
  llm_model: z.string().nullable().optional(),
490
579
  llm_family: z.string().nullable().optional(),
491
580
  scheduling_enabled: z.boolean().optional(),
581
+ org_slug: orgSlugField,
492
582
  })
493
583
  .parse(args);
494
- const { agent_id, ...rest } = parsed;
584
+ const { agent_id, org_slug, ...rest } = parsed;
495
585
  const fields = {};
496
586
  if (rest.name !== undefined)
497
587
  fields.name = rest.name;
588
+ if (rest.username !== undefined)
589
+ fields.username = rest.username;
498
590
  if (rest.instructions !== undefined)
499
591
  fields.instructions = rest.instructions;
500
592
  if (rest.llm_provider !== undefined)
@@ -505,25 +597,29 @@ export async function handleAgentBuilderTool(name, args, client) {
505
597
  fields.llmFamily = rest.llm_family;
506
598
  if (rest.scheduling_enabled !== undefined)
507
599
  fields.schedulingEnabled = rest.scheduling_enabled;
508
- const agent = await client.updateAgent(agent_id, fields);
600
+ const agent = await client.updateAgent(agent_id, fields, resolveOrg(parsed));
509
601
  return { content: [{ type: 'text', text: `Updated agent\n\n${text(agent)}` }] };
510
602
  }
511
603
  // ─── Project Assignment ─────────────────────────────────────────────────
512
604
  case 'list_agent_projects': {
513
- const { agent_id } = AgentIdSchema.parse(args);
514
- const projects = await client.listAgentProjects(agent_id);
605
+ const parsed = AgentIdSchema.parse(args);
606
+ const projects = await client.listAgentProjects(parsed.agent_id, resolveOrg(parsed));
515
607
  return { content: [{ type: 'text', text: text(projects) }] };
516
608
  }
517
609
  case 'assign_agent_to_project': {
518
- const parsed = z.object({ agent_id: z.string(), project_slug: z.string() }).parse(args);
519
- await client.assignAgentToProject(parsed.agent_id, parsed.project_slug);
610
+ const parsed = z
611
+ .object({ agent_id: z.string(), project_slug: z.string(), org_slug: orgSlugField })
612
+ .parse(args);
613
+ await client.assignAgentToProject(parsed.agent_id, parsed.project_slug, resolveOrg(parsed));
520
614
  return {
521
615
  content: [{ type: 'text', text: `Assigned agent to project "${parsed.project_slug}"` }],
522
616
  };
523
617
  }
524
618
  case 'remove_agent_from_project': {
525
- const parsed = z.object({ agent_id: z.string(), project_slug: z.string() }).parse(args);
526
- await client.removeAgentFromProject(parsed.agent_id, parsed.project_slug);
619
+ const parsed = z
620
+ .object({ agent_id: z.string(), project_slug: z.string(), org_slug: orgSlugField })
621
+ .parse(args);
622
+ await client.removeAgentFromProject(parsed.agent_id, parsed.project_slug, resolveOrg(parsed));
527
623
  return {
528
624
  content: [{ type: 'text', text: `Removed agent from project "${parsed.project_slug}"` }],
529
625
  };
@@ -536,18 +632,19 @@ export async function handleAgentBuilderTool(name, args, client) {
536
632
  status: z.string().optional(),
537
633
  limit: z.number().optional(),
538
634
  offset: z.number().optional(),
635
+ org_slug: orgSlugField,
539
636
  })
540
637
  .parse(args);
541
638
  const sessions = await client.listAgentSessions(parsed.agent_id, {
542
639
  status: parsed.status,
543
640
  limit: parsed.limit,
544
641
  offset: parsed.offset,
545
- });
642
+ }, resolveOrg(parsed));
546
643
  return { content: [{ type: 'text', text: text(sessions) }] };
547
644
  }
548
645
  case 'get_agent_session': {
549
- const { agent_id, session_id } = AgentSessionSchema.parse(args);
550
- const session = await client.getAgentSession(agent_id, session_id);
646
+ const parsed = AgentSessionSchema.parse(args);
647
+ const session = await client.getAgentSession(parsed.agent_id, parsed.session_id, resolveOrg(parsed));
551
648
  if (!session)
552
649
  return { content: [{ type: 'text', text: 'Session not found' }] };
553
650
  return { content: [{ type: 'text', text: text(session) }] };
@@ -559,19 +656,22 @@ export async function handleAgentBuilderTool(name, args, client) {
559
656
  session_id: z.string(),
560
657
  limit: z.number().optional(),
561
658
  offset: z.number().optional(),
659
+ org_slug: orgSlugField,
562
660
  })
563
661
  .parse(args);
564
- const conv = await client.getAgentSessionConversation(parsed.agent_id, parsed.session_id, {
565
- limit: parsed.limit,
566
- offset: parsed.offset,
567
- });
662
+ const conv = await client.getAgentSessionConversation(parsed.agent_id, parsed.session_id, { limit: parsed.limit, offset: parsed.offset }, resolveOrg(parsed));
568
663
  return { content: [{ type: 'text', text: text(conv) }] };
569
664
  }
570
665
  case 'run_agent': {
571
666
  const parsed = z
572
- .object({ agent_id: z.string(), prompt: z.string(), project_slug: z.string().optional() })
667
+ .object({
668
+ agent_id: z.string(),
669
+ prompt: z.string(),
670
+ project_slug: z.string().optional(),
671
+ org_slug: orgSlugField,
672
+ })
573
673
  .parse(args);
574
- const result = await client.runAgent(parsed.agent_id, parsed.prompt, parsed.project_slug);
674
+ const result = await client.runAgent(parsed.agent_id, parsed.prompt, parsed.project_slug, resolveOrg(parsed));
575
675
  return {
576
676
  content: [
577
677
  {
@@ -582,8 +682,8 @@ export async function handleAgentBuilderTool(name, args, client) {
582
682
  };
583
683
  }
584
684
  case 'stop_agent_session': {
585
- const { agent_id, session_id } = AgentSessionSchema.parse(args);
586
- const session = await client.stopAgentSession(agent_id, session_id);
685
+ const parsed = AgentSessionSchema.parse(args);
686
+ const session = await client.stopAgentSession(parsed.agent_id, parsed.session_id, resolveOrg(parsed));
587
687
  return {
588
688
  content: [
589
689
  { type: 'text', text: `Stopped session (status: ${session.status})\n\n${text(session)}` },
@@ -592,20 +692,25 @@ export async function handleAgentBuilderTool(name, args, client) {
592
692
  }
593
693
  case 'resume_agent_session': {
594
694
  const parsed = z
595
- .object({ agent_id: z.string(), session_id: z.string(), prompt: z.string() })
695
+ .object({
696
+ agent_id: z.string(),
697
+ session_id: z.string(),
698
+ prompt: z.string(),
699
+ org_slug: orgSlugField,
700
+ })
596
701
  .parse(args);
597
- const session = await client.resumeAgentSession(parsed.agent_id, parsed.session_id, parsed.prompt);
702
+ const session = await client.resumeAgentSession(parsed.agent_id, parsed.session_id, parsed.prompt, resolveOrg(parsed));
598
703
  return { content: [{ type: 'text', text: `Resumed session\n\n${text(session)}` }] };
599
704
  }
600
705
  // ─── Tasks ──────────────────────────────────────────────────────────────
601
706
  case 'list_agent_tasks': {
602
- const { agent_id } = AgentIdSchema.parse(args);
603
- const tasks = await client.listAgentTasks(agent_id);
707
+ const parsed = AgentIdSchema.parse(args);
708
+ const tasks = await client.listAgentTasks(parsed.agent_id, resolveOrg(parsed));
604
709
  return { content: [{ type: 'text', text: text(tasks) }] };
605
710
  }
606
711
  case 'get_agent_task': {
607
- const { agent_id, task_id } = AgentTaskSchema.parse(args);
608
- const task = await client.getAgentTask(agent_id, task_id);
712
+ const parsed = AgentTaskSchema.parse(args);
713
+ const task = await client.getAgentTask(parsed.agent_id, parsed.task_id, resolveOrg(parsed));
609
714
  if (!task)
610
715
  return { content: [{ type: 'text', text: 'Task not found' }] };
611
716
  return { content: [{ type: 'text', text: text(task) }] };
@@ -618,6 +723,7 @@ export async function handleAgentBuilderTool(name, args, client) {
618
723
  prompt: z.string(),
619
724
  scheduled_enabled: z.boolean().optional(),
620
725
  sort_order: z.number().optional(),
726
+ org_slug: orgSlugField,
621
727
  })
622
728
  .parse(args);
623
729
  const task = await client.createAgentTask(parsed.agent_id, {
@@ -625,7 +731,7 @@ export async function handleAgentBuilderTool(name, args, client) {
625
731
  prompt: parsed.prompt,
626
732
  scheduledEnabled: parsed.scheduled_enabled,
627
733
  sortOrder: parsed.sort_order,
628
- });
734
+ }, resolveOrg(parsed));
629
735
  return { content: [{ type: 'text', text: `Created task "${task.name}"\n\n${text(task)}` }] };
630
736
  }
631
737
  case 'update_agent_task': {
@@ -638,6 +744,7 @@ export async function handleAgentBuilderTool(name, args, client) {
638
744
  scheduled_enabled: z.boolean().optional(),
639
745
  sort_order: z.number().optional(),
640
746
  is_active: z.boolean().optional(),
747
+ org_slug: orgSlugField,
641
748
  })
642
749
  .parse(args);
643
750
  const fields = {};
@@ -651,14 +758,19 @@ export async function handleAgentBuilderTool(name, args, client) {
651
758
  fields.sortOrder = parsed.sort_order;
652
759
  if (parsed.is_active !== undefined)
653
760
  fields.isActive = parsed.is_active;
654
- const task = await client.updateAgentTask(parsed.agent_id, parsed.task_id, fields);
761
+ const task = await client.updateAgentTask(parsed.agent_id, parsed.task_id, fields, resolveOrg(parsed));
655
762
  return { content: [{ type: 'text', text: `Updated task\n\n${text(task)}` }] };
656
763
  }
657
764
  case 'run_agent_task': {
658
765
  const parsed = z
659
- .object({ agent_id: z.string(), task_id: z.string(), project_slug: z.string().optional() })
766
+ .object({
767
+ agent_id: z.string(),
768
+ task_id: z.string(),
769
+ project_slug: z.string().optional(),
770
+ org_slug: orgSlugField,
771
+ })
660
772
  .parse(args);
661
- const result = await client.runAgentTask(parsed.agent_id, parsed.task_id, parsed.project_slug);
773
+ const result = await client.runAgentTask(parsed.agent_id, parsed.task_id, parsed.project_slug, resolveOrg(parsed));
662
774
  return {
663
775
  content: [
664
776
  {
@@ -669,23 +781,37 @@ export async function handleAgentBuilderTool(name, args, client) {
669
781
  };
670
782
  }
671
783
  case 'list_agent_queue': {
672
- const parsed = z.object({ agent_id: z.string(), status: z.string().optional() }).parse(args);
673
- const entries = await client.listAgentQueue(parsed.agent_id, parsed.status);
784
+ const parsed = z
785
+ .object({ agent_id: z.string(), status: z.string().optional(), org_slug: orgSlugField })
786
+ .parse(args);
787
+ const entries = await client.listAgentQueue(parsed.agent_id, parsed.status, resolveOrg(parsed));
674
788
  return { content: [{ type: 'text', text: text(entries) }] };
675
789
  }
676
790
  case 'cancel_queue_entry': {
677
- const parsed = z.object({ agent_id: z.string(), entry_id: z.string() }).parse(args);
678
- await client.cancelQueueEntry(parsed.agent_id, parsed.entry_id);
791
+ const parsed = z
792
+ .object({ agent_id: z.string(), entry_id: z.string(), org_slug: orgSlugField })
793
+ .parse(args);
794
+ await client.cancelQueueEntry(parsed.agent_id, parsed.entry_id, resolveOrg(parsed));
679
795
  return { content: [{ type: 'text', text: `Cancelled queue entry ${parsed.entry_id}` }] };
680
796
  }
681
797
  // ─── Skills ─────────────────────────────────────────────────────────────
682
798
  case 'create_skill': {
683
799
  const parsed = z
684
- .object({ name: z.string(), description: z.string(), content: z.string() })
800
+ .object({
801
+ name: z.string(),
802
+ description: z.string(),
803
+ content: z.string(),
804
+ agent_id: z.string().optional(),
805
+ org_slug: orgSlugField,
806
+ })
685
807
  .parse(args);
686
- const skill = await client.createSkill(parsed);
808
+ const { agent_id, org_slug, ...fields } = parsed;
809
+ const skill = await client.createSkill({ ...fields, agentProfileId: agent_id }, resolveOrg(parsed));
810
+ const scope = agent_id ? 'agent-scoped' : 'org-level';
687
811
  return {
688
- content: [{ type: 'text', text: `Created skill "${parsed.name}"\n\n${text(skill)}` }],
812
+ content: [
813
+ { type: 'text', text: `Created ${scope} skill "${parsed.name}"\n\n${text(skill)}` },
814
+ ],
689
815
  };
690
816
  }
691
817
  case 'update_skill': {
@@ -695,10 +821,11 @@ export async function handleAgentBuilderTool(name, args, client) {
695
821
  name: z.string().optional(),
696
822
  description: z.string().optional(),
697
823
  content: z.string().optional(),
824
+ org_slug: orgSlugField,
698
825
  })
699
826
  .parse(args);
700
- const { skill_id, ...fields } = parsed;
701
- const skill = await client.updateSkill(skill_id, fields);
827
+ const { skill_id, org_slug, ...fields } = parsed;
828
+ const skill = await client.updateSkill(skill_id, fields, resolveOrg(parsed));
702
829
  return { content: [{ type: 'text', text: `Updated skill\n\n${text(skill)}` }] };
703
830
  }
704
831
  case 'create_skill_resource': {
@@ -709,10 +836,11 @@ export async function handleAgentBuilderTool(name, args, client) {
709
836
  name: z.string(),
710
837
  content: z.string(),
711
838
  mime_type: z.string().optional(),
839
+ org_slug: orgSlugField,
712
840
  })
713
841
  .parse(args);
714
- const { skill_id, mime_type, ...rest } = parsed;
715
- const resource = await client.createSkillResource(skill_id, { ...rest, mimeType: mime_type });
842
+ const { skill_id, mime_type, org_slug, ...rest } = parsed;
843
+ const resource = await client.createSkillResource(skill_id, { ...rest, mimeType: mime_type }, resolveOrg(parsed));
716
844
  return {
717
845
  content: [{ type: 'text', text: `Created resource "${parsed.name}"\n\n${text(resource)}` }],
718
846
  };
@@ -725,18 +853,22 @@ export async function handleAgentBuilderTool(name, args, client) {
725
853
  name: z.string().optional(),
726
854
  content: z.string().optional(),
727
855
  mime_type: z.string().optional(),
856
+ org_slug: orgSlugField,
728
857
  })
729
858
  .parse(args);
730
- const { skill_id, resource_id, mime_type, ...rest } = parsed;
731
- const resource = await client.updateSkillResource(skill_id, resource_id, {
732
- ...rest,
733
- mimeType: mime_type,
734
- });
859
+ const { skill_id, resource_id, mime_type, org_slug, ...rest } = parsed;
860
+ const resource = await client.updateSkillResource(skill_id, resource_id, { ...rest, mimeType: mime_type }, resolveOrg(parsed));
735
861
  return { content: [{ type: 'text', text: `Updated resource\n\n${text(resource)}` }] };
736
862
  }
737
863
  case 'set_agent_skills': {
738
- const parsed = z.object({ agent_id: z.string(), skill_ids: z.array(z.string()) }).parse(args);
739
- await client.setAgentSkills(parsed.agent_id, parsed.skill_ids);
864
+ const parsed = z
865
+ .object({
866
+ agent_id: z.string(),
867
+ skill_ids: z.array(z.string()),
868
+ org_slug: orgSlugField,
869
+ })
870
+ .parse(args);
871
+ await client.setAgentSkills(parsed.agent_id, parsed.skill_ids, resolveOrg(parsed));
740
872
  return {
741
873
  content: [
742
874
  {
@@ -746,46 +878,65 @@ export async function handleAgentBuilderTool(name, args, client) {
746
878
  ],
747
879
  };
748
880
  }
749
- // ─── Skills (reading org library) ────────────────────────────────────────
750
- case 'list_org_skills': {
751
- const skills = await client.listOrgSkills();
881
+ // ─── Skills (reading) ─────────────────────────────────────────────────────
882
+ case 'list_agent_skills': {
883
+ const parsed = z.object({ agent_id: z.string() }).parse(args);
884
+ const skills = await client.listAgentSkills(parsed.agent_id);
752
885
  return { content: [{ type: 'text', text: text(skills) }] };
753
886
  }
754
- case 'get_org_skill': {
755
- const parsed = z.object({ skill_name: z.string() }).parse(args);
756
- const skill = await client.getOrgSkill(parsed.skill_name);
887
+ case 'get_skill_detail': {
888
+ const parsed = z
889
+ .object({
890
+ skill_name: z.string(),
891
+ agent_id: z.string().optional(),
892
+ org_slug: orgSlugField,
893
+ })
894
+ .parse(args);
895
+ const skill = await client.getSkillDetail(parsed.skill_name, parsed.agent_id, resolveOrg(parsed));
757
896
  if (!skill) {
758
897
  return {
759
898
  content: [
760
899
  {
761
900
  type: 'text',
762
- text: `Skill '${parsed.skill_name}' not found. Use list_org_skills to see available skills.`,
901
+ text: `Skill '${parsed.skill_name}' not found. Use list_agent_skills or list_org_skills to see available skills.`,
763
902
  },
764
903
  ],
765
904
  };
766
905
  }
767
906
  return { content: [{ type: 'text', text: text(skill) }] };
768
907
  }
908
+ case 'list_org_skills': {
909
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
910
+ const skills = await client.listOrgSkills(resolveOrg(parsed));
911
+ return { content: [{ type: 'text', text: text(skills) }] };
912
+ }
769
913
  // ─── Secrets ─────────────────────────────────────────────────────────────
770
914
  case 'list_agent_secrets': {
771
- const { agent_id } = AgentIdSchema.parse(args);
772
- const secrets = await client.listAgentSecrets(agent_id);
915
+ const parsed = AgentIdSchema.parse(args);
916
+ const secrets = await client.listAgentSecrets(parsed.agent_id, resolveOrg(parsed));
773
917
  return { content: [{ type: 'text', text: text(secrets) }] };
774
918
  }
775
919
  case 'set_agent_secret': {
776
920
  const parsed = z
777
- .object({ agent_id: z.string(), name: z.string(), value: z.string() })
921
+ .object({
922
+ agent_id: z.string(),
923
+ name: z.string(),
924
+ value: z.string(),
925
+ org_slug: orgSlugField,
926
+ })
778
927
  .parse(args);
779
- const secret = await client.setAgentSecret(parsed.agent_id, parsed.name, parsed.value);
928
+ const secret = await client.setAgentSecret(parsed.agent_id, parsed.name, parsed.value, resolveOrg(parsed));
780
929
  return { content: [{ type: 'text', text: `Set secret "${secret.name}"` }] };
781
930
  }
782
931
  // ─── Discovery ────────────────────────────────────────────────────────────
783
932
  case 'list_agent_templates': {
784
- const templates = await client.listAgentTemplates();
933
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
934
+ const templates = await client.listAgentTemplates(resolveOrg(parsed));
785
935
  return { content: [{ type: 'text', text: text(templates) }] };
786
936
  }
787
937
  case 'list_llm_models': {
788
- const models = await client.listLlmModels();
938
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
939
+ const models = await client.listLlmModels(resolveOrg(parsed));
789
940
  return { content: [{ type: 'text', text: text(models) }] };
790
941
  }
791
942
  default: