@roarkanalytics/sdk-mcp 4.44.1 → 4.44.4

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