@roarkanalytics/sdk-mcp 4.44.2 → 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 +14 -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 +232 -111
  17. package/directory-tools.js.map +1 -1
  18. package/directory-tools.mjs +232 -111
  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 +267 -97
  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,8 +487,11 @@ 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
 
@@ -476,33 +504,58 @@ const stringMapSchema = (description: string) => ({
476
504
 
477
505
  const flowAttachmentSchema = {
478
506
  type: 'object' as const,
479
- description:
480
- '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.',
481
508
  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.' },
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.' },
485
519
  edgeCases: {
486
520
  type: ['string', 'array'] as const,
487
521
  description:
488
- 'The string ALL runs every edge case. An array runs only the listed edge cases, each named by id or slug.',
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.',
489
523
  items: {
490
524
  type: 'object' as const,
491
525
  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.' },
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
+ },
494
535
  personaOverrideId: {
495
536
  type: 'string' as const,
496
- description: 'Persona id to use for this edge case.',
537
+ description:
538
+ 'Persona id, from list_personas, to run this edge case as instead of its own persona.',
497
539
  },
498
- variables: stringMapSchema('Values for this edge case only.'),
540
+ variables: stringMapSchema(
541
+ 'Values for the {{variables}} in this edge case only, as variable name to string value.',
542
+ ),
499
543
  },
500
544
  },
501
545
  },
502
- personaOverrideId: { type: 'string' as const, description: 'Persona id to use for this attachment.' },
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.',
550
+ },
503
551
  },
504
552
  };
505
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
+
506
559
  const buildRunBody = (args: Record<string, unknown>): SimulationRunParams => {
507
560
  const hasPlanId = args['planId'] !== undefined;
508
561
  const hasPlan = args['plan'] !== undefined;
@@ -664,6 +717,7 @@ export function directoryTools(): McpTool[] {
664
717
  'List projects',
665
718
  'Lists the Roark projects this credential can use, with the permissions it holds in each. Returns each project id, name, slug, and organization.',
666
719
  objectSchema({}),
720
+ directoryOutputSchemas.listProjects,
667
721
  readAnnotations('List projects'),
668
722
  readMeta('project', '/v1/projects'),
669
723
  async (reqContext) => reqContext.client.project.list(),
@@ -671,12 +725,17 @@ export function directoryTools(): McpTool[] {
671
725
  defineTool(
672
726
  'list_agents',
673
727
  'List agents',
674
- '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.',
675
729
  objectSchema({
676
730
  project: projectProperty,
677
- 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
+ },
678
736
  ...pagingProperties,
679
737
  }),
738
+ directoryOutputSchemas.listAgents,
680
739
  readAnnotations('List agents'),
681
740
  readMeta('agent', '/v1/agent'),
682
741
  async (reqContext, args) =>
@@ -691,13 +750,22 @@ export function directoryTools(): McpTool[] {
691
750
  defineTool(
692
751
  'list_agent_endpoints',
693
752
  '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.',
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.',
695
754
  objectSchema({
696
755
  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.' },
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
+ },
699
766
  ...pagingProperties,
700
767
  }),
768
+ directoryOutputSchemas.listAgentEndpoints,
701
769
  readAnnotations('List agent endpoints'),
702
770
  readMeta('agentEndpoint', '/v1/agent/endpoint'),
703
771
  async (reqContext, args) =>
@@ -713,32 +781,36 @@ export function directoryTools(): McpTool[] {
713
781
  defineTool(
714
782
  'list_calls',
715
783
  '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.',
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.",
721
786
  objectSchema({
722
787
  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.' },
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
+ },
725
797
  agentId: {
726
798
  type: 'string',
727
799
  description:
728
- '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.',
729
801
  },
730
802
  properties: {
731
803
  type: 'object',
732
804
  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.",
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.',
734
806
  additionalProperties: {
735
807
  type: 'object',
736
- description: 'Exactly one of eq or exists.',
808
+ description: 'One filter: eq or exists.',
737
809
  properties: {
738
- eq: { type: 'string', description: 'Case-insensitive exact match.' },
810
+ eq: { type: 'string', description: 'Value the property must equal, ignoring case.' },
739
811
  exists: {
740
812
  type: 'boolean',
741
- 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.',
742
814
  },
743
815
  },
744
816
  },
@@ -746,20 +818,22 @@ export function directoryTools(): McpTool[] {
746
818
  sortBy: {
747
819
  type: 'string',
748
820
  enum: [...CALL_SORT_FIELDS],
749
- description:
750
- '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.',
751
822
  },
752
823
  sortDirection: {
753
824
  type: 'string',
754
825
  enum: [...SORT_DIRECTIONS],
755
- 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.',
756
828
  },
757
829
  simulationRunPlanJobId: {
758
830
  type: 'string',
759
- 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.',
760
833
  },
761
834
  ...pagingProperties,
762
835
  }),
836
+ directoryOutputSchemas.listCalls,
763
837
  readAnnotations('List calls'),
764
838
  readMeta('call', '/v1/call'),
765
839
  async (reqContext, args) => scopedClient(reqContext, args).call.list(callListQuery(args)),
@@ -771,10 +845,11 @@ export function directoryTools(): McpTool[] {
771
845
  objectSchema(
772
846
  {
773
847
  project: projectProperty,
774
- callId: { type: 'string', description: 'Call id.' },
848
+ callId: { type: 'string', description: callIdDescription },
775
849
  },
776
850
  ['callId'],
777
851
  ),
852
+ directoryOutputSchemas.getCall,
778
853
  readAnnotations('Get call'),
779
854
  readMeta('call', '/v1/call/{callId}'),
780
855
  async (reqContext, args) => scopedClient(reqContext, args).call.getByID(requireString(args, 'callId')),
@@ -782,20 +857,21 @@ export function directoryTools(): McpTool[] {
782
857
  defineTool(
783
858
  'get_call_transcript',
784
859
  'Get call transcript',
785
- '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.',
786
861
  objectSchema(
787
862
  {
788
863
  project: projectProperty,
789
- callId: { type: 'string', description: 'Call id.' },
864
+ callId: { type: 'string', description: callIdDescription },
790
865
  source: {
791
866
  type: 'string',
792
867
  enum: [...TRANSCRIPT_SOURCES],
793
868
  description:
794
- '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.',
795
870
  },
796
871
  },
797
872
  ['callId'],
798
873
  ),
874
+ directoryOutputSchemas.getCallTranscript,
799
875
  readAnnotations('Get call transcript'),
800
876
  readMeta('call', '/v1/call/{callId}/transcript'),
801
877
  async (reqContext, args) =>
@@ -807,11 +883,11 @@ export function directoryTools(): McpTool[] {
807
883
  defineTool(
808
884
  'list_call_metrics',
809
885
  '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.',
886
+ 'Returns the metric scores recorded for one call in a Roark project, grouped by metric unless flatten is true.',
811
887
  objectSchema(
812
888
  {
813
889
  project: projectProperty,
814
- callId: { type: 'string', description: 'Call id.' },
890
+ callId: { type: 'string', description: callIdDescription },
815
891
  flatten: {
816
892
  type: 'string',
817
893
  description:
@@ -820,11 +896,13 @@ export function directoryTools(): McpTool[] {
820
896
  status: {
821
897
  type: 'string',
822
898
  enum: ['success', 'all'],
823
- 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.',
824
901
  },
825
902
  },
826
903
  ['callId'],
827
904
  ),
905
+ directoryOutputSchemas.listCallMetrics,
828
906
  readAnnotations('List call metrics'),
829
907
  readMeta('call', '/v1/call/{callId}/metrics'),
830
908
  async (reqContext, args) =>
@@ -840,7 +918,8 @@ export function directoryTools(): McpTool[] {
840
918
  'list_metric_definitions',
841
919
  'List metric definitions',
842
920
  '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 }),
921
+ objectSchema({ project: projectProperty, ...paging(500) }),
922
+ directoryOutputSchemas.listMetricDefinitions,
844
923
  readAnnotations('List metric definitions'),
845
924
  readMeta('metric', '/v1/metric/definitions'),
846
925
  async (reqContext, args) =>
@@ -867,6 +946,7 @@ export function directoryTools(): McpTool[] {
867
946
  },
868
947
  ['jobId'],
869
948
  ),
949
+ directoryOutputSchemas.getSimulationResults,
870
950
  readAnnotations('Get simulation results'),
871
951
  readMeta('simulationRunPlanJob', '/v1/simulation/plan/job/{jobId}/results'),
872
952
  async (reqContext, args) =>
@@ -878,12 +958,17 @@ export function directoryTools(): McpTool[] {
878
958
  defineTool(
879
959
  'list_personas',
880
960
  'List personas',
881
- '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.',
882
962
  objectSchema({
883
963
  project: projectProperty,
884
- 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
+ },
885
969
  ...pagingProperties,
886
970
  }),
971
+ directoryOutputSchemas.listPersonas,
887
972
  readAnnotations('List personas'),
888
973
  readMeta('simulationPersona', '/v1/persona'),
889
974
  async (reqContext, args) =>
@@ -898,18 +983,27 @@ export function directoryTools(): McpTool[] {
898
983
  defineTool(
899
984
  'list_customer_flows',
900
985
  '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.',
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.',
902
987
  objectSchema({
903
988
  project: projectProperty,
904
- searchText: { type: 'string', description: 'Match against flow title.' },
905
- 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
+ },
906
998
  includeSystem: {
907
999
  type: 'string',
908
1000
  enum: ['true', 'false'],
909
- 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.',
910
1003
  },
911
1004
  ...pagingProperties,
912
1005
  }),
1006
+ directoryOutputSchemas.listCustomerFlows,
913
1007
  readAnnotations('List customer flows'),
914
1008
  readMeta('customerFlow', '/v1/customer-flow'),
915
1009
  async (reqContext, args) =>
@@ -928,6 +1022,7 @@ export function directoryTools(): McpTool[] {
928
1022
  'List simulation environments',
929
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.',
930
1024
  objectSchema({ project: projectProperty, ...pagingProperties }),
1025
+ directoryOutputSchemas.listSimulationEnvironments,
931
1026
  readAnnotations('List simulation environments'),
932
1027
  readMeta('simulationEnvironment', '/v1/simulation/environment'),
933
1028
  async (reqContext, args) =>
@@ -938,16 +1033,24 @@ export function directoryTools(): McpTool[] {
938
1033
  defineTool(
939
1034
  'create_agent',
940
1035
  '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.',
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.',
942
1037
  objectSchema(
943
1038
  {
944
1039
  project: projectProperty,
945
- 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
+ },
946
1044
  description: { type: 'string', description: 'What the agent does.' },
947
- 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
+ },
948
1050
  },
949
1051
  ['name'],
950
1052
  ),
1053
+ directoryOutputSchemas.createAgent,
951
1054
  writeAnnotations('Create agent'),
952
1055
  writeMeta('agent', '/v1/agent'),
953
1056
  async (reqContext, args) =>
@@ -962,30 +1065,41 @@ export function directoryTools(): McpTool[] {
962
1065
  defineTool(
963
1066
  'create_agent_endpoint',
964
1067
  '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.',
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.',
966
1069
  objectSchema(
967
1070
  {
968
1071
  project: projectProperty,
969
1072
  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 +.' },
1073
+ value: {
1074
+ type: 'string',
1075
+ description: "The agent's phone number in E.164 form, such as +14155550123.",
1076
+ },
971
1077
  direction: {
972
1078
  type: 'string',
973
1079
  enum: [...ENDPOINT_DIRECTIONS],
974
- 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.',
975
1087
  },
976
- environment: { type: 'string', description: 'Environment name. The API default is production.' },
977
1088
  outboundDialType: {
978
1089
  type: 'string',
979
1090
  enum: ['NONE', 'HTTP_REQUEST'],
980
- 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.',
981
1093
  },
982
1094
  outboundDialHttpRequestDefinitionId: {
983
1095
  type: 'string',
984
- 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.',
985
1098
  },
986
1099
  },
987
1100
  ['agentId', 'value', 'direction'],
988
1101
  ),
1102
+ directoryOutputSchemas.createAgentEndpoint,
989
1103
  writeAnnotations('Create agent endpoint'),
990
1104
  writeMeta('agentEndpoint', '/v1/agent/endpoint'),
991
1105
  async (reqContext, args) =>
@@ -994,32 +1108,36 @@ export function directoryTools(): McpTool[] {
994
1108
  defineTool(
995
1109
  'create_persona',
996
1110
  '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.',
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.',
998
1112
  objectSchema(
999
1113
  {
1000
1114
  project: projectProperty,
1001
1115
  name: { type: 'string', description: 'Name the caller uses in conversation.' },
1002
1116
  language: { type: 'string', enum: [...LANGUAGES], description: 'Primary spoken language.' },
1003
- accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the persona is voiced with.' },
1117
+ accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the caller speaks with.' },
1004
1118
  gender: { type: 'string', enum: [...GENDERS], description: 'Gender the persona is voiced with.' },
1005
1119
  age: {
1006
1120
  type: 'string',
1007
1121
  enum: [...AGES],
1008
- description: 'How old the caller sounds. The API default is ADULT.',
1122
+ description: 'How old the caller sounds. When omitted, ADULT.',
1009
1123
  },
1010
1124
  baseEmotion: {
1011
1125
  type: 'string',
1012
1126
  enum: [...EMOTIONS],
1013
- description: 'Emotional baseline. The API default is NEUTRAL.',
1127
+ description: 'Mood the caller starts the conversation in. When omitted, NEUTRAL.',
1014
1128
  },
1015
1129
  backstoryPrompt: {
1016
1130
  type: 'string',
1017
1131
  description: 'Background and behavior the simulated caller plays.',
1018
1132
  },
1019
- 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
+ },
1020
1137
  },
1021
1138
  ['name', 'language', 'accent', 'gender'],
1022
1139
  ),
1140
+ directoryOutputSchemas.createPersona,
1023
1141
  writeAnnotations('Create persona'),
1024
1142
  writeMeta('simulationPersona', '/v1/persona'),
1025
1143
  async (reqContext, args) =>
@@ -1028,22 +1146,29 @@ export function directoryTools(): McpTool[] {
1028
1146
  defineTool(
1029
1147
  'create_customer_flow',
1030
1148
  '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.',
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.',
1032
1150
  objectSchema(
1033
1151
  {
1034
1152
  project: projectProperty,
1035
- 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
+ },
1036
1157
  description: { type: 'string', description: 'What the conversation covers.' },
1037
1158
  agentIds: {
1038
1159
  type: 'array',
1039
1160
  items: { type: 'string' },
1040
- 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.',
1041
1163
  },
1042
1164
  happyPath: {
1043
1165
  type: 'object',
1044
1166
  description: 'The way the conversation is meant to go.',
1045
1167
  properties: {
1046
- 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
+ },
1047
1172
  prompt: { type: 'string', description: 'What the simulated caller is trying to do.' },
1048
1173
  personaOverrideId: {
1049
1174
  type: 'string',
@@ -1063,10 +1188,21 @@ export function directoryTools(): McpTool[] {
1063
1188
  items: {
1064
1189
  type: 'object',
1065
1190
  properties: {
1066
- title: { type: 'string' },
1067
- prompt: { type: 'string' },
1068
- personaOverrideId: { type: 'string' },
1069
- 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
+ },
1070
1206
  },
1071
1207
  required: ['title'],
1072
1208
  },
@@ -1074,6 +1210,7 @@ export function directoryTools(): McpTool[] {
1074
1210
  },
1075
1211
  ['title', 'agentIds', 'happyPath'],
1076
1212
  ),
1213
+ directoryOutputSchemas.createCustomerFlow,
1077
1214
  writeAnnotations('Create customer flow'),
1078
1215
  writeMeta('customerFlow', '/v1/customer-flow'),
1079
1216
  async (reqContext, args) => scopedClient(reqContext, args).customerFlow.create(buildFlowBody(args)),
@@ -1081,7 +1218,7 @@ export function directoryTools(): McpTool[] {
1081
1218
  defineTool(
1082
1219
  'run_simulation',
1083
1220
  '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.',
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.',
1085
1222
  objectSchema({
1086
1223
  project: projectProperty,
1087
1224
  planId: { type: 'string', description: 'Id of a saved simulation plan to run.' },
@@ -1090,49 +1227,80 @@ export function directoryTools(): McpTool[] {
1090
1227
  description:
1091
1228
  'Inline plan to run once. Requires agentEndpoints, direction, and maxSimulationDurationSeconds.',
1092
1229
  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 },
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
+ },
1097
1242
  metrics: {
1098
1243
  type: 'array',
1099
1244
  items: metricRefSchema,
1100
1245
  description: 'Metrics to score, by id or slug.',
1101
1246
  },
1102
- flows: { type: 'array', items: flowAttachmentSchema },
1103
- 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
+ },
1104
1256
  iterationCount: {
1105
1257
  type: 'number',
1106
- description: 'Repeats of each test case. The API default is 1.',
1258
+ description: 'Times each test case runs. When omitted, 1.',
1107
1259
  },
1108
1260
  maxConcurrentJobs: {
1109
1261
  type: 'number',
1110
- description: 'How many calls run at once. The API default is 5.',
1262
+ description: 'How many calls run at once. When omitted, 5.',
1111
1263
  },
1112
1264
  executionMode: {
1113
1265
  type: 'string',
1114
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.',
1115
1269
  },
1116
1270
  },
1117
1271
  required: ['agentEndpoints', 'direction', 'maxSimulationDurationSeconds'],
1118
1272
  },
1119
1273
  template: {
1120
1274
  type: 'string',
1121
- 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.',
1122
1277
  },
1123
1278
  agentEndpoints: {
1124
1279
  type: 'array',
1125
1280
  items: endpointSchema,
1126
- 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}`,
1127
1287
  },
1128
- direction: { type: 'string', enum: [...DIRECTIONS], description: 'Required with template.' },
1129
1288
  flows: {
1130
1289
  type: 'array',
1131
1290
  items: flowAttachmentSchema,
1132
- 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.",
1133
1303
  },
1134
- iterationCount: { type: 'number' },
1135
- maxSimulationDurationSeconds: { type: 'number' },
1136
1304
  saveAsPlan: {
1137
1305
  type: 'boolean',
1138
1306
  description:
@@ -1141,7 +1309,7 @@ export function directoryTools(): McpTool[] {
1141
1309
  variables: {
1142
1310
  type: ['object', 'array'],
1143
1311
  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).',
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).',
1145
1313
  additionalProperties: { type: 'string' },
1146
1314
  items: {
1147
1315
  type: 'object',
@@ -1151,15 +1319,17 @@ export function directoryTools(): McpTool[] {
1151
1319
  happyPath: { type: 'boolean', description: "Narrow to the flow's happy path." },
1152
1320
  scenarioId: {
1153
1321
  type: 'string',
1154
- description: 'Scenario id the values apply to, instead of flowId.',
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.',
1155
1324
  },
1156
- variables: stringMapSchema('The values to apply.'),
1325
+ variables: stringMapSchema('The values to apply, as variable name to string value.'),
1157
1326
  },
1158
1327
  required: ['variables'],
1159
1328
  },
1160
1329
  },
1161
1330
  }),
1162
- writeAnnotations('Run simulation'),
1331
+ directoryOutputSchemas.runSimulation,
1332
+ writeAnnotations('Run simulation', { openWorld: true }),
1163
1333
  writeMeta('simulation', '/v1/simulation/run'),
1164
1334
  async (reqContext, args) => scopedClient(reqContext, args).simulation.run(buildRunBody(args)),
1165
1335
  ),