wolfpack-mcp 1.0.52 → 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
  },
@@ -311,6 +347,7 @@ export const AGENT_BUILDER_TOOLS = [
311
347
  type: 'string',
312
348
  description: 'Agent profile ID. When provided, creates an agent-private skill instead of org-level.',
313
349
  },
350
+ ...ORG_SLUG_PROP,
314
351
  },
315
352
  required: ['name', 'description', 'content'],
316
353
  },
@@ -325,6 +362,7 @@ export const AGENT_BUILDER_TOOLS = [
325
362
  name: { type: 'string', description: 'Updated skill name' },
326
363
  description: { type: 'string', description: 'Updated description' },
327
364
  content: { type: 'string', description: 'Updated instruction body' },
365
+ ...ORG_SLUG_PROP,
328
366
  },
329
367
  required: ['skill_id'],
330
368
  },
@@ -344,6 +382,7 @@ export const AGENT_BUILDER_TOOLS = [
344
382
  name: { type: 'string', description: 'Resource filename' },
345
383
  content: { type: 'string', description: 'Resource text content' },
346
384
  mime_type: { type: 'string', description: 'MIME type (optional)' },
385
+ ...ORG_SLUG_PROP,
347
386
  },
348
387
  required: ['skill_id', 'type', 'name', 'content'],
349
388
  },
@@ -359,6 +398,7 @@ export const AGENT_BUILDER_TOOLS = [
359
398
  name: { type: 'string', description: 'Updated filename' },
360
399
  content: { type: 'string', description: 'Updated text content' },
361
400
  mime_type: { type: 'string', description: 'Updated MIME type' },
401
+ ...ORG_SLUG_PROP,
362
402
  },
363
403
  required: ['skill_id', 'resource_id'],
364
404
  },
@@ -376,6 +416,7 @@ export const AGENT_BUILDER_TOOLS = [
376
416
  items: { type: 'string' },
377
417
  description: 'Array of skill IDs to assign (replaces all current assignments)',
378
418
  },
419
+ ...ORG_SLUG_PROP,
379
420
  },
380
421
  required: ['agent_id', 'skill_ids'],
381
422
  },
@@ -411,6 +452,7 @@ export const AGENT_BUILDER_TOOLS = [
411
452
  type: 'string',
412
453
  description: 'Agent profile ID. When provided, resolves with agent-scoped precedence (agent → org → system).',
413
454
  },
455
+ ...ORG_SLUG_PROP,
414
456
  },
415
457
  required: ['skill_name'],
416
458
  },
@@ -420,7 +462,7 @@ export const AGENT_BUILDER_TOOLS = [
420
462
  description: 'List all skills in the org skill library (org-level + system-level). ' +
421
463
  'Returns ID, name, description, and whether the skill is built-in. ' +
422
464
  'Use skill IDs with set_agent_skills to assign skills to an agent.',
423
- inputSchema: { type: 'object', properties: {} },
465
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
424
466
  },
425
467
  // ─── Group 6: Secrets ─────────────────────────────────────────────────────
426
468
  {
@@ -430,6 +472,7 @@ export const AGENT_BUILDER_TOOLS = [
430
472
  type: 'object',
431
473
  properties: {
432
474
  agent_id: { type: 'string', description: 'Agent profile ID' },
475
+ ...ORG_SLUG_PROP,
433
476
  },
434
477
  required: ['agent_id'],
435
478
  },
@@ -444,6 +487,7 @@ export const AGENT_BUILDER_TOOLS = [
444
487
  agent_id: { type: 'string', description: 'Agent profile ID' },
445
488
  name: { type: 'string', description: 'Secret name (e.g. MY_API_KEY)' },
446
489
  value: { type: 'string', description: 'Secret value (encrypted at rest)' },
490
+ ...ORG_SLUG_PROP,
447
491
  },
448
492
  required: ['agent_id', 'name', 'value'],
449
493
  },
@@ -452,31 +496,50 @@ export const AGENT_BUILDER_TOOLS = [
452
496
  {
453
497
  name: 'list_agent_templates',
454
498
  description: 'List agent templates available to the organisation. Use template IDs when calling create_agent.',
455
- inputSchema: { type: 'object', properties: {} },
499
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
456
500
  },
457
501
  {
458
502
  name: 'list_llm_models',
459
503
  description: 'List LLM providers and models available to the organisation. ' +
460
504
  'Use provider and model IDs when calling create_agent or update_agent.',
461
- inputSchema: { type: 'object', properties: {} },
505
+ inputSchema: { type: 'object', properties: { ...ORG_SLUG_PROP } },
462
506
  },
463
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
+ }
464
513
  // Zod schemas for argument parsing
465
- const AgentIdSchema = z.object({ agent_id: z.string() });
466
- const AgentSessionSchema = z.object({ agent_id: z.string(), session_id: z.string() });
467
- const AgentTaskSchema = z.object({ agent_id: z.string(), task_id: z.string() });
468
- 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 });
469
526
  export async function handleAgentBuilderTool(name, args, client) {
470
527
  const text = (t) => JSON.stringify(t, null, 2);
471
528
  switch (name) {
529
+ // ─── Organisations ─────────────────────────────────────────────────────
530
+ case 'list_organisations': {
531
+ const orgs = await client.listOrganisations();
532
+ return { content: [{ type: 'text', text: text(orgs) }] };
533
+ }
472
534
  // ─── Agent CRUD ────────────────────────────────────────────────────────
473
535
  case 'list_agents': {
474
- const agents = await client.listAgents();
536
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
537
+ const agents = await client.listAgents(resolveOrg(parsed));
475
538
  return { content: [{ type: 'text', text: text(agents) }] };
476
539
  }
477
540
  case 'get_agent': {
478
- const { agent_id } = AgentIdSchema.parse(args);
479
- const agent = await client.getAgent(agent_id);
541
+ const parsed = AgentIdSchema.parse(args);
542
+ const agent = await client.getAgent(parsed.agent_id, resolveOrg(parsed));
480
543
  if (!agent)
481
544
  return { content: [{ type: 'text', text: 'Agent not found' }] };
482
545
  return { content: [{ type: 'text', text: text(agent) }] };
@@ -487,13 +550,14 @@ export async function handleAgentBuilderTool(name, args, client) {
487
550
  template_id: z.string(),
488
551
  name: z.string(),
489
552
  config: z.record(z.unknown()).optional(),
553
+ org_slug: orgSlugField,
490
554
  })
491
555
  .parse(args);
492
556
  const agent = await client.createAgent({
493
557
  templateId: parsed.template_id,
494
558
  name: parsed.name,
495
559
  config: parsed.config,
496
- });
560
+ }, resolveOrg(parsed));
497
561
  return {
498
562
  content: [
499
563
  {
@@ -508,17 +572,21 @@ export async function handleAgentBuilderTool(name, args, client) {
508
572
  .object({
509
573
  agent_id: z.string(),
510
574
  name: z.string().optional(),
575
+ username: z.string().nullable().optional(),
511
576
  instructions: z.string().nullable().optional(),
512
577
  llm_provider: z.string().nullable().optional(),
513
578
  llm_model: z.string().nullable().optional(),
514
579
  llm_family: z.string().nullable().optional(),
515
580
  scheduling_enabled: z.boolean().optional(),
581
+ org_slug: orgSlugField,
516
582
  })
517
583
  .parse(args);
518
- const { agent_id, ...rest } = parsed;
584
+ const { agent_id, org_slug, ...rest } = parsed;
519
585
  const fields = {};
520
586
  if (rest.name !== undefined)
521
587
  fields.name = rest.name;
588
+ if (rest.username !== undefined)
589
+ fields.username = rest.username;
522
590
  if (rest.instructions !== undefined)
523
591
  fields.instructions = rest.instructions;
524
592
  if (rest.llm_provider !== undefined)
@@ -529,25 +597,29 @@ export async function handleAgentBuilderTool(name, args, client) {
529
597
  fields.llmFamily = rest.llm_family;
530
598
  if (rest.scheduling_enabled !== undefined)
531
599
  fields.schedulingEnabled = rest.scheduling_enabled;
532
- const agent = await client.updateAgent(agent_id, fields);
600
+ const agent = await client.updateAgent(agent_id, fields, resolveOrg(parsed));
533
601
  return { content: [{ type: 'text', text: `Updated agent\n\n${text(agent)}` }] };
534
602
  }
535
603
  // ─── Project Assignment ─────────────────────────────────────────────────
536
604
  case 'list_agent_projects': {
537
- const { agent_id } = AgentIdSchema.parse(args);
538
- const projects = await client.listAgentProjects(agent_id);
605
+ const parsed = AgentIdSchema.parse(args);
606
+ const projects = await client.listAgentProjects(parsed.agent_id, resolveOrg(parsed));
539
607
  return { content: [{ type: 'text', text: text(projects) }] };
540
608
  }
541
609
  case 'assign_agent_to_project': {
542
- const parsed = z.object({ agent_id: z.string(), project_slug: z.string() }).parse(args);
543
- 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));
544
614
  return {
545
615
  content: [{ type: 'text', text: `Assigned agent to project "${parsed.project_slug}"` }],
546
616
  };
547
617
  }
548
618
  case 'remove_agent_from_project': {
549
- const parsed = z.object({ agent_id: z.string(), project_slug: z.string() }).parse(args);
550
- 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));
551
623
  return {
552
624
  content: [{ type: 'text', text: `Removed agent from project "${parsed.project_slug}"` }],
553
625
  };
@@ -560,18 +632,19 @@ export async function handleAgentBuilderTool(name, args, client) {
560
632
  status: z.string().optional(),
561
633
  limit: z.number().optional(),
562
634
  offset: z.number().optional(),
635
+ org_slug: orgSlugField,
563
636
  })
564
637
  .parse(args);
565
638
  const sessions = await client.listAgentSessions(parsed.agent_id, {
566
639
  status: parsed.status,
567
640
  limit: parsed.limit,
568
641
  offset: parsed.offset,
569
- });
642
+ }, resolveOrg(parsed));
570
643
  return { content: [{ type: 'text', text: text(sessions) }] };
571
644
  }
572
645
  case 'get_agent_session': {
573
- const { agent_id, session_id } = AgentSessionSchema.parse(args);
574
- 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));
575
648
  if (!session)
576
649
  return { content: [{ type: 'text', text: 'Session not found' }] };
577
650
  return { content: [{ type: 'text', text: text(session) }] };
@@ -583,19 +656,22 @@ export async function handleAgentBuilderTool(name, args, client) {
583
656
  session_id: z.string(),
584
657
  limit: z.number().optional(),
585
658
  offset: z.number().optional(),
659
+ org_slug: orgSlugField,
586
660
  })
587
661
  .parse(args);
588
- const conv = await client.getAgentSessionConversation(parsed.agent_id, parsed.session_id, {
589
- limit: parsed.limit,
590
- offset: parsed.offset,
591
- });
662
+ const conv = await client.getAgentSessionConversation(parsed.agent_id, parsed.session_id, { limit: parsed.limit, offset: parsed.offset }, resolveOrg(parsed));
592
663
  return { content: [{ type: 'text', text: text(conv) }] };
593
664
  }
594
665
  case 'run_agent': {
595
666
  const parsed = z
596
- .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
+ })
597
673
  .parse(args);
598
- 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));
599
675
  return {
600
676
  content: [
601
677
  {
@@ -606,8 +682,8 @@ export async function handleAgentBuilderTool(name, args, client) {
606
682
  };
607
683
  }
608
684
  case 'stop_agent_session': {
609
- const { agent_id, session_id } = AgentSessionSchema.parse(args);
610
- 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));
611
687
  return {
612
688
  content: [
613
689
  { type: 'text', text: `Stopped session (status: ${session.status})\n\n${text(session)}` },
@@ -616,20 +692,25 @@ export async function handleAgentBuilderTool(name, args, client) {
616
692
  }
617
693
  case 'resume_agent_session': {
618
694
  const parsed = z
619
- .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
+ })
620
701
  .parse(args);
621
- 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));
622
703
  return { content: [{ type: 'text', text: `Resumed session\n\n${text(session)}` }] };
623
704
  }
624
705
  // ─── Tasks ──────────────────────────────────────────────────────────────
625
706
  case 'list_agent_tasks': {
626
- const { agent_id } = AgentIdSchema.parse(args);
627
- const tasks = await client.listAgentTasks(agent_id);
707
+ const parsed = AgentIdSchema.parse(args);
708
+ const tasks = await client.listAgentTasks(parsed.agent_id, resolveOrg(parsed));
628
709
  return { content: [{ type: 'text', text: text(tasks) }] };
629
710
  }
630
711
  case 'get_agent_task': {
631
- const { agent_id, task_id } = AgentTaskSchema.parse(args);
632
- 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));
633
714
  if (!task)
634
715
  return { content: [{ type: 'text', text: 'Task not found' }] };
635
716
  return { content: [{ type: 'text', text: text(task) }] };
@@ -642,6 +723,7 @@ export async function handleAgentBuilderTool(name, args, client) {
642
723
  prompt: z.string(),
643
724
  scheduled_enabled: z.boolean().optional(),
644
725
  sort_order: z.number().optional(),
726
+ org_slug: orgSlugField,
645
727
  })
646
728
  .parse(args);
647
729
  const task = await client.createAgentTask(parsed.agent_id, {
@@ -649,7 +731,7 @@ export async function handleAgentBuilderTool(name, args, client) {
649
731
  prompt: parsed.prompt,
650
732
  scheduledEnabled: parsed.scheduled_enabled,
651
733
  sortOrder: parsed.sort_order,
652
- });
734
+ }, resolveOrg(parsed));
653
735
  return { content: [{ type: 'text', text: `Created task "${task.name}"\n\n${text(task)}` }] };
654
736
  }
655
737
  case 'update_agent_task': {
@@ -662,6 +744,7 @@ export async function handleAgentBuilderTool(name, args, client) {
662
744
  scheduled_enabled: z.boolean().optional(),
663
745
  sort_order: z.number().optional(),
664
746
  is_active: z.boolean().optional(),
747
+ org_slug: orgSlugField,
665
748
  })
666
749
  .parse(args);
667
750
  const fields = {};
@@ -675,14 +758,19 @@ export async function handleAgentBuilderTool(name, args, client) {
675
758
  fields.sortOrder = parsed.sort_order;
676
759
  if (parsed.is_active !== undefined)
677
760
  fields.isActive = parsed.is_active;
678
- 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));
679
762
  return { content: [{ type: 'text', text: `Updated task\n\n${text(task)}` }] };
680
763
  }
681
764
  case 'run_agent_task': {
682
765
  const parsed = z
683
- .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
+ })
684
772
  .parse(args);
685
- 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));
686
774
  return {
687
775
  content: [
688
776
  {
@@ -693,13 +781,17 @@ export async function handleAgentBuilderTool(name, args, client) {
693
781
  };
694
782
  }
695
783
  case 'list_agent_queue': {
696
- const parsed = z.object({ agent_id: z.string(), status: z.string().optional() }).parse(args);
697
- 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));
698
788
  return { content: [{ type: 'text', text: text(entries) }] };
699
789
  }
700
790
  case 'cancel_queue_entry': {
701
- const parsed = z.object({ agent_id: z.string(), entry_id: z.string() }).parse(args);
702
- 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));
703
795
  return { content: [{ type: 'text', text: `Cancelled queue entry ${parsed.entry_id}` }] };
704
796
  }
705
797
  // ─── Skills ─────────────────────────────────────────────────────────────
@@ -710,13 +802,11 @@ export async function handleAgentBuilderTool(name, args, client) {
710
802
  description: z.string(),
711
803
  content: z.string(),
712
804
  agent_id: z.string().optional(),
805
+ org_slug: orgSlugField,
713
806
  })
714
807
  .parse(args);
715
- const { agent_id, ...fields } = parsed;
716
- const skill = await client.createSkill({
717
- ...fields,
718
- agentProfileId: agent_id,
719
- });
808
+ const { agent_id, org_slug, ...fields } = parsed;
809
+ const skill = await client.createSkill({ ...fields, agentProfileId: agent_id }, resolveOrg(parsed));
720
810
  const scope = agent_id ? 'agent-scoped' : 'org-level';
721
811
  return {
722
812
  content: [
@@ -731,10 +821,11 @@ export async function handleAgentBuilderTool(name, args, client) {
731
821
  name: z.string().optional(),
732
822
  description: z.string().optional(),
733
823
  content: z.string().optional(),
824
+ org_slug: orgSlugField,
734
825
  })
735
826
  .parse(args);
736
- const { skill_id, ...fields } = parsed;
737
- 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));
738
829
  return { content: [{ type: 'text', text: `Updated skill\n\n${text(skill)}` }] };
739
830
  }
740
831
  case 'create_skill_resource': {
@@ -745,10 +836,11 @@ export async function handleAgentBuilderTool(name, args, client) {
745
836
  name: z.string(),
746
837
  content: z.string(),
747
838
  mime_type: z.string().optional(),
839
+ org_slug: orgSlugField,
748
840
  })
749
841
  .parse(args);
750
- const { skill_id, mime_type, ...rest } = parsed;
751
- 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));
752
844
  return {
753
845
  content: [{ type: 'text', text: `Created resource "${parsed.name}"\n\n${text(resource)}` }],
754
846
  };
@@ -761,18 +853,22 @@ export async function handleAgentBuilderTool(name, args, client) {
761
853
  name: z.string().optional(),
762
854
  content: z.string().optional(),
763
855
  mime_type: z.string().optional(),
856
+ org_slug: orgSlugField,
764
857
  })
765
858
  .parse(args);
766
- const { skill_id, resource_id, mime_type, ...rest } = parsed;
767
- const resource = await client.updateSkillResource(skill_id, resource_id, {
768
- ...rest,
769
- mimeType: mime_type,
770
- });
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));
771
861
  return { content: [{ type: 'text', text: `Updated resource\n\n${text(resource)}` }] };
772
862
  }
773
863
  case 'set_agent_skills': {
774
- const parsed = z.object({ agent_id: z.string(), skill_ids: z.array(z.string()) }).parse(args);
775
- 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));
776
872
  return {
777
873
  content: [
778
874
  {
@@ -790,9 +886,13 @@ export async function handleAgentBuilderTool(name, args, client) {
790
886
  }
791
887
  case 'get_skill_detail': {
792
888
  const parsed = z
793
- .object({ skill_name: z.string(), agent_id: z.string().optional() })
889
+ .object({
890
+ skill_name: z.string(),
891
+ agent_id: z.string().optional(),
892
+ org_slug: orgSlugField,
893
+ })
794
894
  .parse(args);
795
- const skill = await client.getSkillDetail(parsed.skill_name, parsed.agent_id);
895
+ const skill = await client.getSkillDetail(parsed.skill_name, parsed.agent_id, resolveOrg(parsed));
796
896
  if (!skill) {
797
897
  return {
798
898
  content: [
@@ -806,29 +906,37 @@ export async function handleAgentBuilderTool(name, args, client) {
806
906
  return { content: [{ type: 'text', text: text(skill) }] };
807
907
  }
808
908
  case 'list_org_skills': {
809
- const skills = await client.listOrgSkills();
909
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
910
+ const skills = await client.listOrgSkills(resolveOrg(parsed));
810
911
  return { content: [{ type: 'text', text: text(skills) }] };
811
912
  }
812
913
  // ─── Secrets ─────────────────────────────────────────────────────────────
813
914
  case 'list_agent_secrets': {
814
- const { agent_id } = AgentIdSchema.parse(args);
815
- const secrets = await client.listAgentSecrets(agent_id);
915
+ const parsed = AgentIdSchema.parse(args);
916
+ const secrets = await client.listAgentSecrets(parsed.agent_id, resolveOrg(parsed));
816
917
  return { content: [{ type: 'text', text: text(secrets) }] };
817
918
  }
818
919
  case 'set_agent_secret': {
819
920
  const parsed = z
820
- .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
+ })
821
927
  .parse(args);
822
- 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));
823
929
  return { content: [{ type: 'text', text: `Set secret "${secret.name}"` }] };
824
930
  }
825
931
  // ─── Discovery ────────────────────────────────────────────────────────────
826
932
  case 'list_agent_templates': {
827
- const templates = await client.listAgentTemplates();
933
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
934
+ const templates = await client.listAgentTemplates(resolveOrg(parsed));
828
935
  return { content: [{ type: 'text', text: text(templates) }] };
829
936
  }
830
937
  case 'list_llm_models': {
831
- const models = await client.listLlmModels();
938
+ const parsed = z.object({ org_slug: orgSlugField }).parse(args);
939
+ const models = await client.listLlmModels(resolveOrg(parsed));
832
940
  return { content: [{ type: 'text', text: text(models) }] };
833
941
  }
834
942
  default: