@roarkanalytics/sdk-mcp 4.44.2 → 4.44.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/client-headers.d.mts +2 -2
  3. package/client-headers.d.ts +2 -2
  4. package/client-headers.js +1 -1
  5. package/client-headers.mjs +1 -1
  6. package/directory-output-schemas.d.mts +139 -0
  7. package/directory-output-schemas.d.mts.map +1 -0
  8. package/directory-output-schemas.d.ts +139 -0
  9. package/directory-output-schemas.d.ts.map +1 -0
  10. package/directory-output-schemas.js +251 -0
  11. package/directory-output-schemas.js.map +1 -0
  12. package/directory-output-schemas.mjs +248 -0
  13. package/directory-output-schemas.mjs.map +1 -0
  14. package/directory-tools.d.mts +2 -0
  15. package/directory-tools.d.mts.map +1 -1
  16. package/directory-tools.d.ts +2 -0
  17. package/directory-tools.d.ts.map +1 -1
  18. package/directory-tools.js +253 -115
  19. package/directory-tools.js.map +1 -1
  20. package/directory-tools.mjs +252 -114
  21. package/directory-tools.mjs.map +1 -1
  22. package/docs-search-tool.d.mts +10 -3
  23. package/docs-search-tool.d.mts.map +1 -1
  24. package/docs-search-tool.d.ts +10 -3
  25. package/docs-search-tool.d.ts.map +1 -1
  26. package/docs-search-tool.js +36 -6
  27. package/docs-search-tool.js.map +1 -1
  28. package/docs-search-tool.mjs +34 -5
  29. package/docs-search-tool.mjs.map +1 -1
  30. package/http.d.mts.map +1 -1
  31. package/http.d.ts.map +1 -1
  32. package/http.js +8 -7
  33. package/http.js.map +1 -1
  34. package/http.mjs +9 -8
  35. package/http.mjs.map +1 -1
  36. package/oauth.d.mts +16 -1
  37. package/oauth.d.mts.map +1 -1
  38. package/oauth.d.ts +16 -1
  39. package/oauth.d.ts.map +1 -1
  40. package/oauth.js +24 -1
  41. package/oauth.js.map +1 -1
  42. package/oauth.mjs +22 -0
  43. package/oauth.mjs.map +1 -1
  44. package/options.d.mts +10 -0
  45. package/options.d.mts.map +1 -1
  46. package/options.d.ts +10 -0
  47. package/options.d.ts.map +1 -1
  48. package/options.js +29 -3
  49. package/options.js.map +1 -1
  50. package/options.mjs +27 -3
  51. package/options.mjs.map +1 -1
  52. package/package.json +11 -1
  53. package/server.d.mts.map +1 -1
  54. package/server.d.ts.map +1 -1
  55. package/server.js +8 -1
  56. package/server.js.map +1 -1
  57. package/server.mjs +8 -1
  58. package/server.mjs.map +1 -1
  59. package/src/client-headers.ts +1 -1
  60. package/src/directory-output-schemas.ts +318 -0
  61. package/src/directory-tools.ts +291 -99
  62. package/src/docs-search-tool.ts +42 -6
  63. package/src/http.ts +9 -7
  64. package/src/oauth.ts +28 -1
  65. package/src/options.ts +30 -3
  66. package/src/server.ts +9 -1
  67. package/src/types.ts +1 -0
  68. package/types.d.mts +1 -0
  69. package/types.d.mts.map +1 -1
  70. package/types.d.ts +1 -0
  71. package/types.d.ts.map +1 -1
  72. package/types.js.map +1 -1
  73. package/types.mjs.map +1 -1
@@ -18,6 +18,7 @@ import {
18
18
  asErrorResult,
19
19
  asTextContentResult,
20
20
  } from './types';
21
+ import { directoryOutputSchemas } from './directory-output-schemas';
21
22
 
22
23
  /**
23
24
  * Request types for the SDK methods these tools call.
@@ -126,8 +127,11 @@ const CALL_STATUSES = ['RINGING', 'IN_PROGRESS', 'ENDED'] as const;
126
127
  const CALL_SORT_FIELDS = ['createdAt', 'startedAt', 'endedAt', 'duration', 'title', 'status'] as const;
127
128
  const SORT_DIRECTIONS = ['asc', 'desc'] as const;
128
129
  /** GET /v1/call rejects a non-UUID in `agentId` and in `properties[agent_id][eq]`. */
129
- const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
130
+ const UUID_SOURCE = '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
131
+ const UUID_PATTERN = new RegExp(`^${UUID_SOURCE}$`);
130
132
  const MAX_AGENT_IDS = 100;
133
+ /** The rule `optionalAgentIds` enforces, as a JSON Schema pattern: 1 to MAX_AGENT_IDS comma-separated UUIDs. */
134
+ export const AGENT_IDS_PATTERN = `^${UUID_SOURCE}(,${UUID_SOURCE}){0,${MAX_AGENT_IDS - 1}}$`;
131
135
  const MAX_PROPERTY_FILTERS = 20;
132
136
  const FLOW_TYPES = ['SCRIPTED', 'IMPROV', 'VOICEMAIL'] as const;
133
137
  const TRANSCRIPT_SOURCES = [
@@ -143,16 +147,23 @@ class ToolInputError extends Error {
143
147
  }
144
148
  }
145
149
 
150
+ // Every tool talks only to the Roark API, so openWorldHint is false, except
151
+ // run_simulation, which places phone calls to the agent under test.
146
152
  const readAnnotations = (title: string) => ({
147
153
  title,
148
154
  readOnlyHint: true as const,
149
155
  destructiveHint: false as const,
156
+ idempotentHint: true as const,
157
+ openWorldHint: false as const,
150
158
  });
151
159
 
152
- const writeAnnotations = (title: string) => ({
160
+ // Each write creates a new record, so repeating a call is not idempotent.
161
+ const writeAnnotations = (title: string, { openWorld = false }: { openWorld?: boolean } = {}) => ({
153
162
  title,
154
163
  readOnlyHint: false as const,
155
164
  destructiveHint: true as const,
165
+ idempotentHint: false as const,
166
+ openWorldHint: openWorld,
156
167
  });
157
168
 
158
169
  const projectProperty = {
@@ -161,16 +172,20 @@ const projectProperty = {
161
172
  'Roark project id. Required when this connection is not already pinned to one project. list_projects returns the ids this credential can use.',
162
173
  };
163
174
 
164
- const pagingProperties = {
175
+ /** `after` and `limit`, with the page size the endpoint uses when `limit` is omitted. */
176
+ const paging = (defaultLimit: number) => ({
165
177
  after: {
166
178
  type: 'string' as const,
167
- description: 'Cursor from a previous response. Omit for the first page.',
179
+ description:
180
+ 'Paging cursor: pass pagination.nextCursor from the previous response to get the next page. Omit for the first page.',
168
181
  },
169
182
  limit: {
170
183
  type: 'number' as const,
171
- description: 'Maximum number of rows to return.',
184
+ description: `Page size: the most rows one response returns. When omitted, the API returns up to ${defaultLimit}.`,
172
185
  },
173
- };
186
+ });
187
+
188
+ const pagingProperties = paging(20);
174
189
 
175
190
  type JsonSchema = Tool['inputSchema'];
176
191
 
@@ -407,9 +422,17 @@ const callListQuery = (args: Record<string, unknown>): CallListParams =>
407
422
  limit: optionalLimit(args),
408
423
  }) as CallListParams;
409
424
 
425
+ // Every tool declares an outputSchema, so the response body is also returned as
426
+ // structuredContent. The JSON text stays for clients that read only content.
410
427
  const callApi = async (fn: () => Promise<unknown>): Promise<ToolCallResult> => {
411
428
  try {
412
- return asTextContentResult(await fn());
429
+ const result = await fn();
430
+ // A tool with an outputSchema must return structuredContent, which is an object. The API
431
+ // always answers with { data, ... }; anything else is reported rather than sent unstructured.
432
+ if (!isRecord(result)) {
433
+ return asErrorResult(`Unexpected response from the Roark API: ${JSON.stringify(result) ?? 'empty'}`);
434
+ }
435
+ return { ...asTextContentResult(result), structuredContent: result };
413
436
  } catch (error) {
414
437
  if (error instanceof ToolInputError || error instanceof APIError || error instanceof Error) {
415
438
  return asErrorResult(error.message);
@@ -434,6 +457,7 @@ const defineTool = (
434
457
  title: string,
435
458
  description: string,
436
459
  inputSchema: JsonSchema,
460
+ outputSchema: NonNullable<Tool['outputSchema']>,
437
461
  annotations: Tool['annotations'],
438
462
  metadata: Metadata,
439
463
  fn: (reqContext: McpRequestContext, args: Record<string, unknown>) => Promise<unknown>,
@@ -444,6 +468,7 @@ const defineTool = (
444
468
  title,
445
469
  description,
446
470
  inputSchema,
471
+ outputSchema,
447
472
  annotations,
448
473
  },
449
474
  handler: handler(fn),
@@ -451,9 +476,12 @@ const defineTool = (
451
476
 
452
477
  const endpointSchema = {
453
478
  type: 'object' as const,
454
- description: 'An agent endpoint Roark dials or connects to.',
479
+ description: 'An agent endpoint the run tests.',
455
480
  properties: {
456
- id: { type: 'string' as const, description: 'Agent endpoint id from list_agent_endpoints.' },
481
+ id: {
482
+ type: 'string' as const,
483
+ description: 'Agent endpoint id, from list_agent_endpoints or create_agent_endpoint.',
484
+ },
457
485
  },
458
486
  required: ['id'],
459
487
  };
@@ -462,8 +490,11 @@ const metricRefSchema = {
462
490
  type: 'object' as const,
463
491
  description: 'A metric to score, by id or by slug.',
464
492
  properties: {
465
- id: { type: 'string' as const, description: 'Metric definition id.' },
466
- slug: { type: 'string' as const, description: 'Metric slug, such as call_outcome.' },
493
+ id: { type: 'string' as const, description: 'Metric definition id, from list_metric_definitions.' },
494
+ slug: {
495
+ type: 'string' as const,
496
+ description: 'Metric slug, from list_metric_definitions. Use instead of id.',
497
+ },
467
498
  },
468
499
  };
469
500
 
@@ -476,33 +507,62 @@ const stringMapSchema = (description: string) => ({
476
507
 
477
508
  const flowAttachmentSchema = {
478
509
  type: 'object' as const,
479
- description:
480
- 'A customer flow to include. Set happyPath, edgeCases, or both. id comes from list_customer_flows.',
510
+ description: 'A customer flow to include. Name it by id or slug, and set happyPath, edgeCases, or both.',
481
511
  properties: {
482
- id: { type: 'string' as const, description: 'Customer flow id.' },
483
- slug: { type: 'string' as const, description: 'Roark-curated flow slug, used instead of id.' },
484
- happyPath: { type: 'boolean' as const, description: 'Whether to run the flow happy path.' },
512
+ id: {
513
+ type: 'string' as const,
514
+ description: 'Customer flow id, from list_customer_flows or create_customer_flow.',
515
+ },
516
+ slug: {
517
+ type: 'string' as const,
518
+ description:
519
+ 'Stable slug of a flow Roark provides, used instead of id. GET /v1/simulation/template lists them. Flows made in the project have no slug.',
520
+ },
521
+ happyPath: {
522
+ type: 'boolean' as const,
523
+ description:
524
+ "true runs the flow's happy path, the conversation going as intended. It is resolved when the run starts, so it follows the flow as it is then.",
525
+ },
485
526
  edgeCases: {
486
527
  type: ['string', 'array'] as const,
487
528
  description:
488
- 'The string ALL runs every edge case. An array runs only the listed edge cases, each named by id or slug.',
529
+ 'The string ALL runs every edge case the flow has when the run starts. An array runs only the listed edge cases, each named by id or slug.',
489
530
  items: {
490
531
  type: 'object' as const,
491
532
  properties: {
492
- id: { type: 'string' as const, description: 'Edge case id from list_customer_flows.' },
493
- slug: { type: 'string' as const, description: 'Edge case slug, used instead of id.' },
533
+ id: {
534
+ type: 'string' as const,
535
+ description: "Edge case id, from the flow's edgeCases in list_customer_flows.",
536
+ },
537
+ slug: {
538
+ type: 'string' as const,
539
+ description:
540
+ 'Stable slug of an edge case Roark provides, matched within this flow. Used instead of id.',
541
+ },
494
542
  personaOverrideId: {
495
543
  type: 'string' as const,
496
- description: 'Persona id to use for this edge case.',
544
+ description:
545
+ 'Persona id, from list_personas, to run this edge case as instead of its own persona.',
497
546
  },
498
- variables: stringMapSchema('Values for this edge case only.'),
547
+ variables: stringMapSchema(
548
+ 'Values for the {{variables}} in this edge case only, as variable name to string value.',
549
+ ),
499
550
  },
500
551
  },
501
552
  },
502
- personaOverrideId: { type: 'string' as const, description: 'Persona id to use for this attachment.' },
553
+ personaOverrideId: {
554
+ type: 'string' as const,
555
+ description:
556
+ 'Persona id, from list_personas, to run everything in this flow as instead of its own persona.',
557
+ },
503
558
  },
504
559
  };
505
560
 
561
+ const callIdDescription = 'Roark call id, from list_calls.';
562
+
563
+ const directionDescription =
564
+ 'INBOUND: the simulated caller phones the agent. OUTBOUND: the agent places the call to the simulated caller.';
565
+
506
566
  const buildRunBody = (args: Record<string, unknown>): SimulationRunParams => {
507
567
  const hasPlanId = args['planId'] !== undefined;
508
568
  const hasPlan = args['plan'] !== undefined;
@@ -664,6 +724,7 @@ export function directoryTools(): McpTool[] {
664
724
  'List projects',
665
725
  'Lists the Roark projects this credential can use, with the permissions it holds in each. Returns each project id, name, slug, and organization.',
666
726
  objectSchema({}),
727
+ directoryOutputSchemas.listProjects,
667
728
  readAnnotations('List projects'),
668
729
  readMeta('project', '/v1/projects'),
669
730
  async (reqContext) => reqContext.client.project.list(),
@@ -671,12 +732,17 @@ export function directoryTools(): McpTool[] {
671
732
  defineTool(
672
733
  'list_agents',
673
734
  'List agents',
674
- 'Lists voice and chat agents in a Roark project. Returns each agent id, name, custom id, and description.',
735
+ 'Lists voice and chat agents in a Roark project, every agent unless searchText narrows it. Returns each agent id, name, custom id, and description, one page at a time.',
675
736
  objectSchema({
676
737
  project: projectProperty,
677
- searchText: { type: 'string', description: 'Match against agent name or description.' },
738
+ searchText: {
739
+ type: 'string',
740
+ description:
741
+ 'Text to match against agent names and descriptions. When omitted, every agent is listed.',
742
+ },
678
743
  ...pagingProperties,
679
744
  }),
745
+ directoryOutputSchemas.listAgents,
680
746
  readAnnotations('List agents'),
681
747
  readMeta('agent', '/v1/agent'),
682
748
  async (reqContext, args) =>
@@ -691,13 +757,22 @@ export function directoryTools(): McpTool[] {
691
757
  defineTool(
692
758
  'list_agent_endpoints',
693
759
  'List agent endpoints',
694
- 'Lists the endpoints Roark uses to reach agents in a project. Returns each endpoint id, agent id, direction, type, and address. A simulation runs against an endpoint id.',
760
+ 'Lists the endpoints Roark uses to reach agents in a project: phone numbers and other transports. Returns each endpoint id, agent id, direction, type, and address. A simulation runs against an endpoint id.',
695
761
  objectSchema({
696
762
  project: projectProperty,
697
- agentId: { type: 'string', description: 'Return endpoints for this agent only.' },
698
- searchText: { type: 'string', description: 'Match against endpoint address or environment name.' },
763
+ agentId: {
764
+ type: 'string',
765
+ description:
766
+ "Agent id, from list_agents, to list only that agent's endpoints. When omitted, endpoints for every agent are listed.",
767
+ },
768
+ searchText: {
769
+ type: 'string',
770
+ description:
771
+ 'Text to match against the endpoint address, such as a phone number, or its environment name.',
772
+ },
699
773
  ...pagingProperties,
700
774
  }),
775
+ directoryOutputSchemas.listAgentEndpoints,
701
776
  readAnnotations('List agent endpoints'),
702
777
  readMeta('agentEndpoint', '/v1/agent/endpoint'),
703
778
  async (reqContext, args) =>
@@ -713,32 +788,37 @@ export function directoryTools(): McpTool[] {
713
788
  defineTool(
714
789
  'list_calls',
715
790
  'List calls',
716
- 'Lists calls in a Roark project, including simulated and live calls. Returns call ids, status, direction, and timestamps. Does not include transcripts. ' +
717
- 'agentId is one agent UUID, or up to 100 comma-separated UUIDs with no spaces. ' +
718
- 'properties filters with one operator per name: eq is a case-insensitive exact match, and exists checks whether the property is set. ' +
719
- "Built-in agent_name, also accepted as agentName, matches any participating agent's current name. Built-in agent_id matches one agent UUID. Any other name is a custom property. " +
720
- 'sortBy is createdAt (the default), startedAt, endedAt, duration, title, or status, and sortDirection is desc (the default) or asc. The filters and the sort apply together.',
791
+ 'Lists calls in a Roark project, simulated and live. Returns call ids, status, direction, and timestamps, without transcripts. Every filter and the sort apply together.',
721
792
  objectSchema({
722
793
  project: projectProperty,
723
- searchText: { type: 'string', description: 'Match against call title, summary, or transcript text.' },
724
- status: { type: 'string', enum: [...CALL_STATUSES], description: 'Call status filter.' },
794
+ searchText: {
795
+ type: 'string',
796
+ description: 'Text to match against call titles, summaries, and transcripts.',
797
+ },
798
+ status: {
799
+ type: 'string',
800
+ enum: [...CALL_STATUSES],
801
+ description:
802
+ 'Where the calls are in their lifecycle: RINGING has not connected yet, IN_PROGRESS is live, ENDED has finished. When omitted, calls in every state are listed.',
803
+ },
725
804
  agentId: {
726
805
  type: 'string',
806
+ pattern: AGENT_IDS_PATTERN,
727
807
  description:
728
- 'One agent UUID, or up to 100 comma-separated UUIDs with no spaces. Returns calls that include any of these agents.',
808
+ 'Agents whose calls to list, by id from list_agents. A call matches when any of them took part. Separate several ids with commas.',
729
809
  },
730
810
  properties: {
731
811
  type: 'object',
732
812
  description:
733
- "One entry per property name, at most 20. Each entry sets eq (case-insensitive exact match, sent as properties[<name>][eq]=<value>) or exists (properties[<name>][exists]=true or false), and not both. agent_name (alias agentName) matches any participating agent's current name. agent_id takes one UUID. Any other name is a custom property.",
813
+ "Call property filters, keyed by property name, at most 20. Each entry sets eq or exists, not both. eq matches a value, ignoring case, and exists checks whether the property is set. The built-in agent_name, also accepted as agentName, matches any participating agent's current name, and agent_id matches one agent id. Any other name is a custom property set on the call.",
734
814
  additionalProperties: {
735
815
  type: 'object',
736
- description: 'Exactly one of eq or exists.',
816
+ description: 'One filter: eq or exists.',
737
817
  properties: {
738
- eq: { type: 'string', description: 'Case-insensitive exact match.' },
818
+ eq: { type: 'string', description: 'Value the property must equal, ignoring case.' },
739
819
  exists: {
740
820
  type: 'boolean',
741
- description: 'true: the property is set. false: the property is missing.',
821
+ description: 'true lists calls that have the property set. false lists calls that do not.',
742
822
  },
743
823
  },
744
824
  },
@@ -746,20 +826,24 @@ export function directoryTools(): McpTool[] {
746
826
  sortBy: {
747
827
  type: 'string',
748
828
  enum: [...CALL_SORT_FIELDS],
829
+ default: 'createdAt',
749
830
  description:
750
- 'Field to sort by. createdAt is the default. Combines with the filters and with sortDirection.',
831
+ 'What orders the results: when the call was created, started, or ended, how long it lasted, its title, or its status.',
751
832
  },
752
833
  sortDirection: {
753
834
  type: 'string',
754
835
  enum: [...SORT_DIRECTIONS],
755
- description: 'asc or desc. desc is the default. Combines with sortBy and the filters.',
836
+ default: 'desc',
837
+ description: 'asc puts the earliest or smallest first, desc the latest or largest.',
756
838
  },
757
839
  simulationRunPlanJobId: {
758
840
  type: 'string',
759
- description: 'Return calls from this simulation run only.',
841
+ description:
842
+ 'Simulation run id, the simulationRunPlanJobId that run_simulation returns, to list only the calls that run placed.',
760
843
  },
761
844
  ...pagingProperties,
762
845
  }),
846
+ directoryOutputSchemas.listCalls,
763
847
  readAnnotations('List calls'),
764
848
  readMeta('call', '/v1/call'),
765
849
  async (reqContext, args) => scopedClient(reqContext, args).call.list(callListQuery(args)),
@@ -771,10 +855,11 @@ export function directoryTools(): McpTool[] {
771
855
  objectSchema(
772
856
  {
773
857
  project: projectProperty,
774
- callId: { type: 'string', description: 'Call id.' },
858
+ callId: { type: 'string', description: callIdDescription },
775
859
  },
776
860
  ['callId'],
777
861
  ),
862
+ directoryOutputSchemas.getCall,
778
863
  readAnnotations('Get call'),
779
864
  readMeta('call', '/v1/call/{callId}'),
780
865
  async (reqContext, args) => scopedClient(reqContext, args).call.getByID(requireString(args, 'callId')),
@@ -782,20 +867,21 @@ export function directoryTools(): McpTool[] {
782
867
  defineTool(
783
868
  'get_call_transcript',
784
869
  'Get call transcript',
785
- 'Returns the transcript of one call in a Roark project: participants and the text of each turn, with timing.',
870
+ 'Returns the transcript of one call in a Roark project: who took part, and the text of each turn with its timing.',
786
871
  objectSchema(
787
872
  {
788
873
  project: projectProperty,
789
- callId: { type: 'string', description: 'Call id.' },
874
+ callId: { type: 'string', description: callIdDescription },
790
875
  source: {
791
876
  type: 'string',
792
877
  enum: [...TRANSCRIPT_SOURCES],
793
878
  description:
794
- 'Transcription source. When omitted, the API uses the best source it has for the call.',
879
+ 'Which transcription to return: Roark post-call transcription, or the one the simulated caller or your agent captured live. When omitted, the first available of CUSTOMER_AGENT_REALTIME, SIMULATION_AGENT_REALTIME, then ROARK_POST_CALL.',
795
880
  },
796
881
  },
797
882
  ['callId'],
798
883
  ),
884
+ directoryOutputSchemas.getCallTranscript,
799
885
  readAnnotations('Get call transcript'),
800
886
  readMeta('call', '/v1/call/{callId}/transcript'),
801
887
  async (reqContext, args) =>
@@ -807,11 +893,11 @@ export function directoryTools(): McpTool[] {
807
893
  defineTool(
808
894
  'list_call_metrics',
809
895
  'List call metrics',
810
- 'Returns the metric scores recorded for one call in a Roark project. status success returns computed scores only. status all also returns rows that have no value. flatten true returns one row per score; when omitted, scores are grouped by metric.',
896
+ 'Returns the metric scores recorded for one call in a Roark project, grouped by metric unless flatten is true.',
811
897
  objectSchema(
812
898
  {
813
899
  project: projectProperty,
814
- callId: { type: 'string', description: 'Call id.' },
900
+ callId: { type: 'string', description: callIdDescription },
815
901
  flatten: {
816
902
  type: 'string',
817
903
  description:
@@ -820,11 +906,13 @@ export function directoryTools(): McpTool[] {
820
906
  status: {
821
907
  type: 'string',
822
908
  enum: ['success', 'all'],
823
- description: 'success returns computed scores. all also returns rows with no value.',
909
+ description:
910
+ 'success returns computed scores only. all also returns metrics with no value (not applicable, missing data, or an error), so a caller can tell a finished metric from one still computing. When omitted, success.',
824
911
  },
825
912
  },
826
913
  ['callId'],
827
914
  ),
915
+ directoryOutputSchemas.listCallMetrics,
828
916
  readAnnotations('List call metrics'),
829
917
  readMeta('call', '/v1/call/{callId}/metrics'),
830
918
  async (reqContext, args) =>
@@ -840,7 +928,8 @@ export function directoryTools(): McpTool[] {
840
928
  'list_metric_definitions',
841
929
  'List metric definitions',
842
930
  'Lists the metrics a Roark project can score, including built-in and custom metrics. Returns each metric id, slug, name, and type.',
843
- objectSchema({ project: projectProperty, ...pagingProperties }),
931
+ objectSchema({ project: projectProperty, ...paging(500) }),
932
+ directoryOutputSchemas.listMetricDefinitions,
844
933
  readAnnotations('List metric definitions'),
845
934
  readMeta('metric', '/v1/metric/definitions'),
846
935
  async (reqContext, args) =>
@@ -867,6 +956,7 @@ export function directoryTools(): McpTool[] {
867
956
  },
868
957
  ['jobId'],
869
958
  ),
959
+ directoryOutputSchemas.getSimulationResults,
870
960
  readAnnotations('Get simulation results'),
871
961
  readMeta('simulationRunPlanJob', '/v1/simulation/plan/job/{jobId}/results'),
872
962
  async (reqContext, args) =>
@@ -878,12 +968,17 @@ export function directoryTools(): McpTool[] {
878
968
  defineTool(
879
969
  'list_personas',
880
970
  'List personas',
881
- 'Lists simulated caller personas in a Roark project. Returns each persona id, name, language, accent, and gender.',
971
+ 'Lists simulated caller personas in a Roark project, every persona unless searchText narrows it. Returns each persona id, name, language, accent, and gender, one page at a time.',
882
972
  objectSchema({
883
973
  project: projectProperty,
884
- searchText: { type: 'string', description: 'Match against persona name or description.' },
974
+ searchText: {
975
+ type: 'string',
976
+ description:
977
+ 'Text to match against persona names and descriptions. When omitted, every persona is listed.',
978
+ },
885
979
  ...pagingProperties,
886
980
  }),
981
+ directoryOutputSchemas.listPersonas,
887
982
  readAnnotations('List personas'),
888
983
  readMeta('simulationPersona', '/v1/persona'),
889
984
  async (reqContext, args) =>
@@ -898,18 +993,28 @@ export function directoryTools(): McpTool[] {
898
993
  defineTool(
899
994
  'list_customer_flows',
900
995
  'List customer flows',
901
- 'Lists customer flows in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Returns each flow id, title, and type. The step graph of a scripted flow is not included.',
996
+ 'Lists customer flows in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Returns each flow id, title, type, happy path, and edge cases. The step graph of a scripted flow is not included.',
902
997
  objectSchema({
903
998
  project: projectProperty,
904
- searchText: { type: 'string', description: 'Match against flow title.' },
905
- type: { type: 'string', enum: [...FLOW_TYPES], description: 'Flow type filter.' },
999
+ searchText: {
1000
+ type: 'string',
1001
+ description: 'Text to match against flow titles. When omitted, flows are not filtered by title.',
1002
+ },
1003
+ type: {
1004
+ type: 'string',
1005
+ enum: [...FLOW_TYPES],
1006
+ description:
1007
+ 'How the simulated caller behaves. IMPROV gives the caller a goal to improvise around, SCRIPTED follows an exact step graph, and VOICEMAIL plays a voicemail greeting to test the message the agent leaves. When omitted, flows of every type are listed.',
1008
+ },
906
1009
  includeSystem: {
907
1010
  type: 'string',
908
1011
  enum: ['true', 'false'],
909
- description: 'true includes flows Roark provides. false returns only flows in the project.',
1012
+ description:
1013
+ 'true also lists flows Roark provides. false, or omitting it, lists only flows made in the project.',
910
1014
  },
911
1015
  ...pagingProperties,
912
1016
  }),
1017
+ directoryOutputSchemas.listCustomerFlows,
913
1018
  readAnnotations('List customer flows'),
914
1019
  readMeta('customerFlow', '/v1/customer-flow'),
915
1020
  async (reqContext, args) =>
@@ -928,6 +1033,7 @@ export function directoryTools(): McpTool[] {
928
1033
  'List simulation environments',
929
1034
  'Lists call environments in a Roark project, including environments Roark provides. Returns each environment id, name, and background noise. Creating a customer flow requires an environment id.',
930
1035
  objectSchema({ project: projectProperty, ...pagingProperties }),
1036
+ directoryOutputSchemas.listSimulationEnvironments,
931
1037
  readAnnotations('List simulation environments'),
932
1038
  readMeta('simulationEnvironment', '/v1/simulation/environment'),
933
1039
  async (reqContext, args) =>
@@ -938,16 +1044,24 @@ export function directoryTools(): McpTool[] {
938
1044
  defineTool(
939
1045
  'create_agent',
940
1046
  'Create agent',
941
- 'Creates an agent in a Roark project. Requires a name. Returns the created agent, including its id. Does not create an endpoint.',
1047
+ 'Creates an agent in a Roark project. Each call adds a new agent. Requires a name. Returns the created agent, including its id. Does not create an endpoint; create_agent_endpoint does.',
942
1048
  objectSchema(
943
1049
  {
944
1050
  project: projectProperty,
945
- name: { type: 'string', description: 'Agent name.' },
1051
+ name: {
1052
+ type: 'string',
1053
+ description: 'Display name for the agent, shown in Roark and returned by list_agents.',
1054
+ },
946
1055
  description: { type: 'string', description: 'What the agent does.' },
947
- customId: { type: 'string', description: 'Caller-chosen id, unique in the project.' },
1056
+ customId: {
1057
+ type: 'string',
1058
+ description:
1059
+ 'Your own identifier for the agent, such as its id in your platform. Unique in the project.',
1060
+ },
948
1061
  },
949
1062
  ['name'],
950
1063
  ),
1064
+ directoryOutputSchemas.createAgent,
951
1065
  writeAnnotations('Create agent'),
952
1066
  writeMeta('agent', '/v1/agent'),
953
1067
  async (reqContext, args) =>
@@ -962,30 +1076,41 @@ export function directoryTools(): McpTool[] {
962
1076
  defineTool(
963
1077
  'create_agent_endpoint',
964
1078
  'Create agent endpoint',
965
- 'Creates a phone endpoint for an agent in a Roark project. Roark places simulated calls to this number. Requires an agent id, an E.164 phone number, and a direction of INCOMING, OUTGOING, or INCOMING_AND_OUTGOING. Phone is the only endpoint type this tool creates.',
1079
+ 'Creates a phone endpoint for an agent in a Roark project. Each call adds a new endpoint; it places no calls itself. Simulations then call the agent on this number, or receive its calls. Phone is the only endpoint type this tool creates.',
966
1080
  objectSchema(
967
1081
  {
968
1082
  project: projectProperty,
969
1083
  agentId: { type: 'string', description: 'Agent id from list_agents or create_agent.' },
970
- value: { type: 'string', description: 'Phone number in E.164 format, starting with +.' },
1084
+ value: {
1085
+ type: 'string',
1086
+ description: "The agent's phone number in E.164 form, such as +14155550123.",
1087
+ },
971
1088
  direction: {
972
1089
  type: 'string',
973
1090
  enum: [...ENDPOINT_DIRECTIONS],
974
- description: 'Which way calls can travel on this number.',
1091
+ description:
1092
+ 'Which way calls travel on this number: INCOMING when callers reach the agent here, OUTGOING when the agent calls out from it, or both.',
1093
+ },
1094
+ environment: {
1095
+ type: 'string',
1096
+ description:
1097
+ 'Environment label for the endpoint, such as production or staging. When omitted, production.',
975
1098
  },
976
- environment: { type: 'string', description: 'Environment name. The API default is production.' },
977
1099
  outboundDialType: {
978
1100
  type: 'string',
979
1101
  enum: ['NONE', 'HTTP_REQUEST'],
980
- description: 'How Roark places an outbound call. The API default is NONE.',
1102
+ description:
1103
+ 'How Roark starts an outbound simulation: HTTP_REQUEST sends an HTTP request to your platform to make the agent dial, NONE sends nothing. When omitted, NONE.',
981
1104
  },
982
1105
  outboundDialHttpRequestDefinitionId: {
983
1106
  type: 'string',
984
- description: 'HTTP request definition id. Required when outboundDialType is HTTP_REQUEST.',
1107
+ description:
1108
+ 'Id of the HTTP request definition Roark sends to make the agent dial, from GET /v1/http-request-definition. Required when outboundDialType is HTTP_REQUEST.',
985
1109
  },
986
1110
  },
987
1111
  ['agentId', 'value', 'direction'],
988
1112
  ),
1113
+ directoryOutputSchemas.createAgentEndpoint,
989
1114
  writeAnnotations('Create agent endpoint'),
990
1115
  writeMeta('agentEndpoint', '/v1/agent/endpoint'),
991
1116
  async (reqContext, args) =>
@@ -994,32 +1119,43 @@ export function directoryTools(): McpTool[] {
994
1119
  defineTool(
995
1120
  'create_persona',
996
1121
  'Create persona',
997
- 'Creates a simulated caller persona in a Roark project. Requires a name, language, accent, and gender. Returns the created persona, including its id.',
1122
+ 'Creates a simulated caller persona in a Roark project. Each call adds a new persona, so repeating it creates a duplicate. It changes nothing else and places no calls. Returns the created persona; pass its id as personaOverrideId to create_customer_flow to use it.',
998
1123
  objectSchema(
999
1124
  {
1000
1125
  project: projectProperty,
1001
1126
  name: { type: 'string', description: 'Name the caller uses in conversation.' },
1002
- language: { type: 'string', enum: [...LANGUAGES], description: 'Primary spoken language.' },
1003
- accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the persona is voiced with.' },
1127
+ language: {
1128
+ type: 'string',
1129
+ enum: [...LANGUAGES],
1130
+ description:
1131
+ 'The language the simulated caller speaks, as an ISO 639-1 code: EN is English, ES Spanish.',
1132
+ },
1133
+ accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the caller speaks with.' },
1004
1134
  gender: { type: 'string', enum: [...GENDERS], description: 'Gender the persona is voiced with.' },
1005
1135
  age: {
1006
1136
  type: 'string',
1007
1137
  enum: [...AGES],
1008
- description: 'How old the caller sounds. The API default is ADULT.',
1138
+ default: 'ADULT',
1139
+ description: 'How old the caller sounds.',
1009
1140
  },
1010
1141
  baseEmotion: {
1011
1142
  type: 'string',
1012
1143
  enum: [...EMOTIONS],
1013
- description: 'Emotional baseline. The API default is NEUTRAL.',
1144
+ default: 'NEUTRAL',
1145
+ description: 'The emotional state the simulated caller brings to the call.',
1014
1146
  },
1015
1147
  backstoryPrompt: {
1016
1148
  type: 'string',
1017
1149
  description: 'Background and behavior the simulated caller plays.',
1018
1150
  },
1019
- description: { type: 'string', description: 'Short label for the persona.' },
1151
+ description: {
1152
+ type: 'string',
1153
+ description: 'Short summary of the persona, to tell it apart from others in the project.',
1154
+ },
1020
1155
  },
1021
1156
  ['name', 'language', 'accent', 'gender'],
1022
1157
  ),
1158
+ directoryOutputSchemas.createPersona,
1023
1159
  writeAnnotations('Create persona'),
1024
1160
  writeMeta('simulationPersona', '/v1/persona'),
1025
1161
  async (reqContext, args) =>
@@ -1028,22 +1164,29 @@ export function directoryTools(): McpTool[] {
1028
1164
  defineTool(
1029
1165
  'create_customer_flow',
1030
1166
  'Create customer flow',
1031
- 'Creates an improv customer flow in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Requires a title, at least one agent id, and a happy path with a title, a persona id, and an environment id. Returns the created flow, including its id. Scripted step graphs are not created by this tool.',
1167
+ 'Creates an improv customer flow in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Each call adds a new flow. Requires a title, at least one agent id, and a happy path with a title, a persona id, and an environment id. Returns the created flow, including its id. Scripted step graphs are not created by this tool.',
1032
1168
  objectSchema(
1033
1169
  {
1034
1170
  project: projectProperty,
1035
- title: { type: 'string', description: 'Flow title.' },
1171
+ title: {
1172
+ type: 'string',
1173
+ description: 'Name for the flow, shown in Roark and returned by list_customer_flows.',
1174
+ },
1036
1175
  description: { type: 'string', description: 'What the conversation covers.' },
1037
1176
  agentIds: {
1038
1177
  type: 'array',
1039
1178
  items: { type: 'string' },
1040
- description: 'Agents this flow exercises. At least one.',
1179
+ minItems: 1,
1180
+ description: 'Ids of the agents this flow tests, from list_agents or create_agent.',
1041
1181
  },
1042
1182
  happyPath: {
1043
1183
  type: 'object',
1044
1184
  description: 'The way the conversation is meant to go.',
1045
1185
  properties: {
1046
- title: { type: 'string', description: 'Happy path title.' },
1186
+ title: {
1187
+ type: 'string',
1188
+ description: 'Name for the happy path, the run where the conversation goes as intended.',
1189
+ },
1047
1190
  prompt: { type: 'string', description: 'What the simulated caller is trying to do.' },
1048
1191
  personaOverrideId: {
1049
1192
  type: 'string',
@@ -1063,10 +1206,21 @@ export function directoryTools(): McpTool[] {
1063
1206
  items: {
1064
1207
  type: 'object',
1065
1208
  properties: {
1066
- title: { type: 'string' },
1067
- prompt: { type: 'string' },
1068
- personaOverrideId: { type: 'string' },
1069
- environmentId: { type: 'string' },
1209
+ title: { type: 'string', description: 'Name for this edge case.' },
1210
+ prompt: {
1211
+ type: 'string',
1212
+ description: 'What the simulated caller is trying to do in this edge case.',
1213
+ },
1214
+ personaOverrideId: {
1215
+ type: 'string',
1216
+ description:
1217
+ 'Persona id from list_personas or create_persona. When omitted, the happy path persona.',
1218
+ },
1219
+ environmentId: {
1220
+ type: 'string',
1221
+ description:
1222
+ 'Environment id from list_simulation_environments. When omitted, the happy path environment.',
1223
+ },
1070
1224
  },
1071
1225
  required: ['title'],
1072
1226
  },
@@ -1074,6 +1228,7 @@ export function directoryTools(): McpTool[] {
1074
1228
  },
1075
1229
  ['title', 'agentIds', 'happyPath'],
1076
1230
  ),
1231
+ directoryOutputSchemas.createCustomerFlow,
1077
1232
  writeAnnotations('Create customer flow'),
1078
1233
  writeMeta('customerFlow', '/v1/customer-flow'),
1079
1234
  async (reqContext, args) => scopedClient(reqContext, args).customerFlow.create(buildFlowBody(args)),
@@ -1081,58 +1236,93 @@ export function directoryTools(): McpTool[] {
1081
1236
  defineTool(
1082
1237
  'run_simulation',
1083
1238
  'Run simulation',
1084
- 'Starts a simulation run in a Roark project and places simulated calls. Pass exactly one of planId (an existing plan), plan (an inline plan), or template (a built-in template name, with agentEndpoints and direction). Returns the run id and how many calls the run places. This spends simulation usage on the account.',
1239
+ 'Starts a simulation run in a Roark project and places simulated calls to the agent. Pass exactly one of planId (an existing plan), plan (an inline plan), or template (a built-in template name, with agentEndpoints and direction). Returns the run id and how many calls the run places. This spends simulation usage on the account.',
1085
1240
  objectSchema({
1086
1241
  project: projectProperty,
1087
- planId: { type: 'string', description: 'Id of a saved simulation plan to run.' },
1242
+ planId: {
1243
+ type: 'string',
1244
+ description:
1245
+ 'A saved run plan to run again, with its own endpoints, flows, and metrics: the simulationRunPlanId of a run started with saveAsPlan true.',
1246
+ },
1088
1247
  plan: {
1089
1248
  type: 'object',
1090
1249
  description:
1091
1250
  'Inline plan to run once. Requires agentEndpoints, direction, and maxSimulationDurationSeconds.',
1092
1251
  properties: {
1093
- name: { type: 'string', description: 'Plan name. Required when saveAsPlan is true.' },
1094
- description: { type: 'string' },
1095
- direction: { type: 'string', enum: [...DIRECTIONS] },
1096
- agentEndpoints: { type: 'array', items: endpointSchema },
1252
+ name: {
1253
+ type: 'string',
1254
+ description:
1255
+ 'Name for the plan. When omitted, one is generated from the date. Needed for saveAsPlan.',
1256
+ },
1257
+ description: { type: 'string', description: 'Note on what the plan tests.' },
1258
+ direction: { type: 'string', enum: [...DIRECTIONS], description: directionDescription },
1259
+ agentEndpoints: {
1260
+ type: 'array',
1261
+ items: endpointSchema,
1262
+ description: 'The agent endpoints the run tests.',
1263
+ },
1097
1264
  metrics: {
1098
1265
  type: 'array',
1099
1266
  items: metricRefSchema,
1100
1267
  description: 'Metrics to score, by id or slug.',
1101
1268
  },
1102
- flows: { type: 'array', items: flowAttachmentSchema },
1103
- maxSimulationDurationSeconds: { type: 'number', description: 'Per-call cap, in seconds.' },
1269
+ flows: {
1270
+ type: 'array',
1271
+ items: flowAttachmentSchema,
1272
+ description: 'Customer flows to run, and which of their happy paths and edge cases.',
1273
+ },
1274
+ maxSimulationDurationSeconds: {
1275
+ type: 'number',
1276
+ description: 'Longest one simulated call may last, in seconds.',
1277
+ },
1104
1278
  iterationCount: {
1105
1279
  type: 'number',
1106
- description: 'Repeats of each test case. The API default is 1.',
1280
+ description: 'Times each test case runs. When omitted, 1.',
1107
1281
  },
1108
1282
  maxConcurrentJobs: {
1109
1283
  type: 'number',
1110
- description: 'How many calls run at once. The API default is 5.',
1284
+ description: 'How many calls run at once. When omitted, 5.',
1111
1285
  },
1112
1286
  executionMode: {
1113
1287
  type: 'string',
1114
1288
  enum: ['PARALLEL', 'SEQUENTIAL_SAME_RUN_PLAN', 'SEQUENTIAL_PROJECT'],
1289
+ description:
1290
+ 'When the run starts relative to other runs. PARALLEL starts it at once. SEQUENTIAL_SAME_RUN_PLAN queues it while another run of the same plan is active. SEQUENTIAL_PROJECT queues it while any run in the project is active. When omitted, PARALLEL.',
1115
1291
  },
1116
1292
  },
1117
1293
  required: ['agentEndpoints', 'direction', 'maxSimulationDurationSeconds'],
1118
1294
  },
1119
1295
  template: {
1120
1296
  type: 'string',
1121
- description: 'Built-in template name, as listed by the simulation template API.',
1297
+ description:
1298
+ 'Name of a built-in Roark template, such as health-check. GET /v1/simulation/template lists them.',
1122
1299
  },
1123
1300
  agentEndpoints: {
1124
1301
  type: 'array',
1125
1302
  items: endpointSchema,
1126
- description: 'Required with template. The endpoints the template calls.',
1303
+ description: 'For a template run: the agent endpoints it tests. A template run fails without it.',
1304
+ },
1305
+ direction: {
1306
+ type: 'string',
1307
+ enum: [...DIRECTIONS],
1308
+ description: `For a template run, where it is required. ${directionDescription}`,
1127
1309
  },
1128
- direction: { type: 'string', enum: [...DIRECTIONS], description: 'Required with template.' },
1129
1310
  flows: {
1130
1311
  type: 'array',
1131
1312
  items: flowAttachmentSchema,
1132
- description: 'Flows for a template that does not supply its own.',
1313
+ description:
1314
+ 'For a template run: the flows to run. Needed when the template has no flows of its own; otherwise they replace its flows.',
1315
+ },
1316
+ iterationCount: {
1317
+ type: 'number',
1318
+ description:
1319
+ "For a template run: times each test case runs. When omitted, 1, or the template's own count for a template that sweeps a property.",
1320
+ },
1321
+ maxSimulationDurationSeconds: {
1322
+ type: 'number',
1323
+ description:
1324
+ "For a template run: longest one simulated call may last, in seconds. When omitted, the template's default.",
1133
1325
  },
1134
- iterationCount: { type: 'number' },
1135
- maxSimulationDurationSeconds: { type: 'number' },
1136
1326
  saveAsPlan: {
1137
1327
  type: 'boolean',
1138
1328
  description:
@@ -1141,7 +1331,7 @@ export function directoryTools(): McpTool[] {
1141
1331
  variables: {
1142
1332
  type: ['object', 'array'],
1143
1333
  description:
1144
- 'Placeholder values for the run. An object of name to string value applies to the whole run. An array applies values per flow (flowId, optionally narrowed by edgeCaseId or happyPath) or per scenario (scenarioId).',
1334
+ 'Values for the {{variables}} the run resolves. An object of name to string value applies to the whole run. An array applies values per flow (flowId, optionally narrowed by edgeCaseId or happyPath).',
1145
1335
  additionalProperties: { type: 'string' },
1146
1336
  items: {
1147
1337
  type: 'object',
@@ -1151,15 +1341,17 @@ export function directoryTools(): McpTool[] {
1151
1341
  happyPath: { type: 'boolean', description: "Narrow to the flow's happy path." },
1152
1342
  scenarioId: {
1153
1343
  type: 'string',
1154
- description: 'Scenario id the values apply to, instead of flowId.',
1344
+ description:
1345
+ 'Deprecated. Scenario id the values apply to, for a saved plan built from scenarios rather than flows. Use flowId otherwise. Template runs refuse it.',
1155
1346
  },
1156
- variables: stringMapSchema('The values to apply.'),
1347
+ variables: stringMapSchema('The values to apply, as variable name to string value.'),
1157
1348
  },
1158
1349
  required: ['variables'],
1159
1350
  },
1160
1351
  },
1161
1352
  }),
1162
- writeAnnotations('Run simulation'),
1353
+ directoryOutputSchemas.runSimulation,
1354
+ writeAnnotations('Run simulation', { openWorld: true }),
1163
1355
  writeMeta('simulation', '/v1/simulation/run'),
1164
1356
  async (reqContext, args) => scopedClient(reqContext, args).simulation.run(buildRunBody(args)),
1165
1357
  ),