@roarkanalytics/sdk-mcp 5.18.0 → 5.19.0

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 +7 -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 +282 -109
  19. package/directory-tools.js.map +1 -1
  20. package/directory-tools.mjs +281 -108
  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 +322 -93
  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,26 +490,79 @@ 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
 
501
+ // A {{variable}} name to value map. The API takes string values only.
502
+ const stringMapSchema = (description: string) => ({
503
+ type: 'object' as const,
504
+ description,
505
+ additionalProperties: { type: 'string' as const },
506
+ });
507
+
470
508
  const flowAttachmentSchema = {
471
509
  type: 'object' as const,
472
- description:
473
- '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.',
474
511
  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.' },
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
+ },
478
526
  edgeCases: {
479
- description: 'ALL runs every edge case. An array runs only the named edge case ids.',
527
+ type: ['string', 'array'] as const,
528
+ description:
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.',
530
+ items: {
531
+ type: 'object' as const,
532
+ properties: {
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
+ },
542
+ personaOverrideId: {
543
+ type: 'string' as const,
544
+ description:
545
+ 'Persona id, from list_personas, to run this edge case as instead of its own persona.',
546
+ },
547
+ variables: stringMapSchema(
548
+ 'Values for the {{variables}} in this edge case only, as variable name to string value.',
549
+ ),
550
+ },
551
+ },
552
+ },
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.',
480
557
  },
481
- personaOverrideId: { type: 'string' as const, description: 'Persona id to use for this attachment.' },
482
558
  },
483
559
  };
484
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
+
485
566
  const buildRunBody = (args: Record<string, unknown>): SimulationRunParams => {
486
567
  const hasPlanId = args['planId'] !== undefined;
487
568
  const hasPlan = args['plan'] !== undefined;
@@ -643,6 +724,7 @@ export function directoryTools(): McpTool[] {
643
724
  'List projects',
644
725
  'Lists the Roark projects this credential can use, with the permissions it holds in each. Returns each project id, name, slug, and organization.',
645
726
  objectSchema({}),
727
+ directoryOutputSchemas.listProjects,
646
728
  readAnnotations('List projects'),
647
729
  readMeta('project', '/v1/projects'),
648
730
  async (reqContext) => reqContext.client.project.list(),
@@ -650,12 +732,17 @@ export function directoryTools(): McpTool[] {
650
732
  defineTool(
651
733
  'list_agents',
652
734
  'List agents',
653
- '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.',
654
736
  objectSchema({
655
737
  project: projectProperty,
656
- 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
+ },
657
743
  ...pagingProperties,
658
744
  }),
745
+ directoryOutputSchemas.listAgents,
659
746
  readAnnotations('List agents'),
660
747
  readMeta('agent', '/v1/agent'),
661
748
  async (reqContext, args) =>
@@ -670,13 +757,22 @@ export function directoryTools(): McpTool[] {
670
757
  defineTool(
671
758
  'list_agent_endpoints',
672
759
  '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.',
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.',
674
761
  objectSchema({
675
762
  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.' },
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
+ },
678
773
  ...pagingProperties,
679
774
  }),
775
+ directoryOutputSchemas.listAgentEndpoints,
680
776
  readAnnotations('List agent endpoints'),
681
777
  readMeta('agentEndpoint', '/v1/agent/endpoint'),
682
778
  async (reqContext, args) =>
@@ -692,32 +788,37 @@ export function directoryTools(): McpTool[] {
692
788
  defineTool(
693
789
  'list_calls',
694
790
  '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.',
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.',
700
792
  objectSchema({
701
793
  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.' },
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
+ },
704
804
  agentId: {
705
805
  type: 'string',
806
+ pattern: AGENT_IDS_PATTERN,
706
807
  description:
707
- '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.',
708
809
  },
709
810
  properties: {
710
811
  type: 'object',
711
812
  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.",
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.",
713
814
  additionalProperties: {
714
815
  type: 'object',
715
- description: 'Exactly one of eq or exists.',
816
+ description: 'One filter: eq or exists.',
716
817
  properties: {
717
- eq: { type: 'string', description: 'Case-insensitive exact match.' },
818
+ eq: { type: 'string', description: 'Value the property must equal, ignoring case.' },
718
819
  exists: {
719
820
  type: 'boolean',
720
- 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.',
721
822
  },
722
823
  },
723
824
  },
@@ -725,20 +826,24 @@ export function directoryTools(): McpTool[] {
725
826
  sortBy: {
726
827
  type: 'string',
727
828
  enum: [...CALL_SORT_FIELDS],
829
+ default: 'createdAt',
728
830
  description:
729
- '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.',
730
832
  },
731
833
  sortDirection: {
732
834
  type: 'string',
733
835
  enum: [...SORT_DIRECTIONS],
734
- 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.',
735
838
  },
736
839
  simulationRunPlanJobId: {
737
840
  type: 'string',
738
- 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.',
739
843
  },
740
844
  ...pagingProperties,
741
845
  }),
846
+ directoryOutputSchemas.listCalls,
742
847
  readAnnotations('List calls'),
743
848
  readMeta('call', '/v1/call'),
744
849
  async (reqContext, args) => scopedClient(reqContext, args).call.list(callListQuery(args)),
@@ -750,10 +855,11 @@ export function directoryTools(): McpTool[] {
750
855
  objectSchema(
751
856
  {
752
857
  project: projectProperty,
753
- callId: { type: 'string', description: 'Call id.' },
858
+ callId: { type: 'string', description: callIdDescription },
754
859
  },
755
860
  ['callId'],
756
861
  ),
862
+ directoryOutputSchemas.getCall,
757
863
  readAnnotations('Get call'),
758
864
  readMeta('call', '/v1/call/{callId}'),
759
865
  async (reqContext, args) => scopedClient(reqContext, args).call.getByID(requireString(args, 'callId')),
@@ -761,20 +867,21 @@ export function directoryTools(): McpTool[] {
761
867
  defineTool(
762
868
  'get_call_transcript',
763
869
  'Get call transcript',
764
- '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.',
765
871
  objectSchema(
766
872
  {
767
873
  project: projectProperty,
768
- callId: { type: 'string', description: 'Call id.' },
874
+ callId: { type: 'string', description: callIdDescription },
769
875
  source: {
770
876
  type: 'string',
771
877
  enum: [...TRANSCRIPT_SOURCES],
772
878
  description:
773
- '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.',
774
880
  },
775
881
  },
776
882
  ['callId'],
777
883
  ),
884
+ directoryOutputSchemas.getCallTranscript,
778
885
  readAnnotations('Get call transcript'),
779
886
  readMeta('call', '/v1/call/{callId}/transcript'),
780
887
  async (reqContext, args) =>
@@ -786,11 +893,11 @@ export function directoryTools(): McpTool[] {
786
893
  defineTool(
787
894
  'list_call_metrics',
788
895
  '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.',
896
+ 'Returns the metric scores recorded for one call in a Roark project, grouped by metric unless flatten is true.',
790
897
  objectSchema(
791
898
  {
792
899
  project: projectProperty,
793
- callId: { type: 'string', description: 'Call id.' },
900
+ callId: { type: 'string', description: callIdDescription },
794
901
  flatten: {
795
902
  type: 'string',
796
903
  description:
@@ -799,11 +906,13 @@ export function directoryTools(): McpTool[] {
799
906
  status: {
800
907
  type: 'string',
801
908
  enum: ['success', 'all'],
802
- 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.',
803
911
  },
804
912
  },
805
913
  ['callId'],
806
914
  ),
915
+ directoryOutputSchemas.listCallMetrics,
807
916
  readAnnotations('List call metrics'),
808
917
  readMeta('call', '/v1/call/{callId}/metrics'),
809
918
  async (reqContext, args) =>
@@ -819,7 +928,8 @@ export function directoryTools(): McpTool[] {
819
928
  'list_metric_definitions',
820
929
  'List metric definitions',
821
930
  '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 }),
931
+ objectSchema({ project: projectProperty, ...paging(500) }),
932
+ directoryOutputSchemas.listMetricDefinitions,
823
933
  readAnnotations('List metric definitions'),
824
934
  readMeta('metric', '/v1/metric/definitions'),
825
935
  async (reqContext, args) =>
@@ -846,6 +956,7 @@ export function directoryTools(): McpTool[] {
846
956
  },
847
957
  ['jobId'],
848
958
  ),
959
+ directoryOutputSchemas.getSimulationResults,
849
960
  readAnnotations('Get simulation results'),
850
961
  readMeta('simulationRunPlanJob', '/v1/simulation/plan/job/{jobId}/results'),
851
962
  async (reqContext, args) =>
@@ -857,12 +968,17 @@ export function directoryTools(): McpTool[] {
857
968
  defineTool(
858
969
  'list_personas',
859
970
  'List personas',
860
- '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.',
861
972
  objectSchema({
862
973
  project: projectProperty,
863
- 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
+ },
864
979
  ...pagingProperties,
865
980
  }),
981
+ directoryOutputSchemas.listPersonas,
866
982
  readAnnotations('List personas'),
867
983
  readMeta('simulationPersona', '/v1/persona'),
868
984
  async (reqContext, args) =>
@@ -877,18 +993,28 @@ export function directoryTools(): McpTool[] {
877
993
  defineTool(
878
994
  'list_customer_flows',
879
995
  '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.',
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.',
881
997
  objectSchema({
882
998
  project: projectProperty,
883
- searchText: { type: 'string', description: 'Match against flow title.' },
884
- 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
+ },
885
1009
  includeSystem: {
886
1010
  type: 'string',
887
1011
  enum: ['true', 'false'],
888
- 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.',
889
1014
  },
890
1015
  ...pagingProperties,
891
1016
  }),
1017
+ directoryOutputSchemas.listCustomerFlows,
892
1018
  readAnnotations('List customer flows'),
893
1019
  readMeta('customerFlow', '/v1/customer-flow'),
894
1020
  async (reqContext, args) =>
@@ -907,6 +1033,7 @@ export function directoryTools(): McpTool[] {
907
1033
  'List simulation environments',
908
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.',
909
1035
  objectSchema({ project: projectProperty, ...pagingProperties }),
1036
+ directoryOutputSchemas.listSimulationEnvironments,
910
1037
  readAnnotations('List simulation environments'),
911
1038
  readMeta('simulationEnvironment', '/v1/simulation/environment'),
912
1039
  async (reqContext, args) =>
@@ -917,16 +1044,24 @@ export function directoryTools(): McpTool[] {
917
1044
  defineTool(
918
1045
  'create_agent',
919
1046
  '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.',
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.',
921
1048
  objectSchema(
922
1049
  {
923
1050
  project: projectProperty,
924
- 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
+ },
925
1055
  description: { type: 'string', description: 'What the agent does.' },
926
- 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
+ },
927
1061
  },
928
1062
  ['name'],
929
1063
  ),
1064
+ directoryOutputSchemas.createAgent,
930
1065
  writeAnnotations('Create agent'),
931
1066
  writeMeta('agent', '/v1/agent'),
932
1067
  async (reqContext, args) =>
@@ -941,30 +1076,41 @@ export function directoryTools(): McpTool[] {
941
1076
  defineTool(
942
1077
  'create_agent_endpoint',
943
1078
  '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.',
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.',
945
1080
  objectSchema(
946
1081
  {
947
1082
  project: projectProperty,
948
1083
  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 +.' },
1084
+ value: {
1085
+ type: 'string',
1086
+ description: "The agent's phone number in E.164 form, such as +14155550123.",
1087
+ },
950
1088
  direction: {
951
1089
  type: 'string',
952
1090
  enum: [...ENDPOINT_DIRECTIONS],
953
- 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.',
954
1098
  },
955
- environment: { type: 'string', description: 'Environment name. The API default is production.' },
956
1099
  outboundDialType: {
957
1100
  type: 'string',
958
1101
  enum: ['NONE', 'HTTP_REQUEST'],
959
- 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.',
960
1104
  },
961
1105
  outboundDialHttpRequestDefinitionId: {
962
1106
  type: 'string',
963
- 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.',
964
1109
  },
965
1110
  },
966
1111
  ['agentId', 'value', 'direction'],
967
1112
  ),
1113
+ directoryOutputSchemas.createAgentEndpoint,
968
1114
  writeAnnotations('Create agent endpoint'),
969
1115
  writeMeta('agentEndpoint', '/v1/agent/endpoint'),
970
1116
  async (reqContext, args) =>
@@ -973,32 +1119,43 @@ export function directoryTools(): McpTool[] {
973
1119
  defineTool(
974
1120
  'create_persona',
975
1121
  '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.',
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.',
977
1123
  objectSchema(
978
1124
  {
979
1125
  project: projectProperty,
980
1126
  name: { type: 'string', description: 'Name the caller uses in conversation.' },
981
- language: { type: 'string', enum: [...LANGUAGES], description: 'Primary spoken language.' },
982
- 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.' },
983
1134
  gender: { type: 'string', enum: [...GENDERS], description: 'Gender the persona is voiced with.' },
984
1135
  age: {
985
1136
  type: 'string',
986
1137
  enum: [...AGES],
987
- description: 'How old the caller sounds. The API default is ADULT.',
1138
+ default: 'ADULT',
1139
+ description: 'How old the caller sounds.',
988
1140
  },
989
1141
  baseEmotion: {
990
1142
  type: 'string',
991
1143
  enum: [...EMOTIONS],
992
- description: 'Emotional baseline. The API default is NEUTRAL.',
1144
+ default: 'NEUTRAL',
1145
+ description: 'The emotional state the simulated caller brings to the call.',
993
1146
  },
994
1147
  backstoryPrompt: {
995
1148
  type: 'string',
996
1149
  description: 'Background and behavior the simulated caller plays.',
997
1150
  },
998
- 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
+ },
999
1155
  },
1000
1156
  ['name', 'language', 'accent', 'gender'],
1001
1157
  ),
1158
+ directoryOutputSchemas.createPersona,
1002
1159
  writeAnnotations('Create persona'),
1003
1160
  writeMeta('simulationPersona', '/v1/persona'),
1004
1161
  async (reqContext, args) =>
@@ -1007,22 +1164,29 @@ export function directoryTools(): McpTool[] {
1007
1164
  defineTool(
1008
1165
  'create_customer_flow',
1009
1166
  '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.',
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.',
1011
1168
  objectSchema(
1012
1169
  {
1013
1170
  project: projectProperty,
1014
- 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
+ },
1015
1175
  description: { type: 'string', description: 'What the conversation covers.' },
1016
1176
  agentIds: {
1017
1177
  type: 'array',
1018
1178
  items: { type: 'string' },
1019
- 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.',
1020
1181
  },
1021
1182
  happyPath: {
1022
1183
  type: 'object',
1023
1184
  description: 'The way the conversation is meant to go.',
1024
1185
  properties: {
1025
- 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
+ },
1026
1190
  prompt: { type: 'string', description: 'What the simulated caller is trying to do.' },
1027
1191
  personaOverrideId: {
1028
1192
  type: 'string',
@@ -1042,10 +1206,21 @@ export function directoryTools(): McpTool[] {
1042
1206
  items: {
1043
1207
  type: 'object',
1044
1208
  properties: {
1045
- title: { type: 'string' },
1046
- prompt: { type: 'string' },
1047
- personaOverrideId: { type: 'string' },
1048
- 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
+ },
1049
1224
  },
1050
1225
  required: ['title'],
1051
1226
  },
@@ -1053,6 +1228,7 @@ export function directoryTools(): McpTool[] {
1053
1228
  },
1054
1229
  ['title', 'agentIds', 'happyPath'],
1055
1230
  ),
1231
+ directoryOutputSchemas.createCustomerFlow,
1056
1232
  writeAnnotations('Create customer flow'),
1057
1233
  writeMeta('customerFlow', '/v1/customer-flow'),
1058
1234
  async (reqContext, args) => scopedClient(reqContext, args).customerFlow.create(buildFlowBody(args)),
@@ -1060,69 +1236,122 @@ export function directoryTools(): McpTool[] {
1060
1236
  defineTool(
1061
1237
  'run_simulation',
1062
1238
  '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.',
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.',
1064
1240
  objectSchema({
1065
1241
  project: projectProperty,
1066
- 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
+ },
1067
1247
  plan: {
1068
1248
  type: 'object',
1069
1249
  description:
1070
1250
  'Inline plan to run once. Requires agentEndpoints, direction, and maxSimulationDurationSeconds.',
1071
1251
  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 },
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
+ },
1076
1264
  metrics: {
1077
1265
  type: 'array',
1078
1266
  items: metricRefSchema,
1079
1267
  description: 'Metrics to score, by id or slug.',
1080
1268
  },
1081
- flows: { type: 'array', items: flowAttachmentSchema },
1082
- 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
+ },
1083
1278
  iterationCount: {
1084
1279
  type: 'number',
1085
- description: 'Repeats of each test case. The API default is 1.',
1280
+ description: 'Times each test case runs. When omitted, 1.',
1086
1281
  },
1087
1282
  maxConcurrentJobs: {
1088
1283
  type: 'number',
1089
- description: 'How many calls run at once. The API default is 5.',
1284
+ description: 'How many calls run at once. When omitted, 5.',
1090
1285
  },
1091
1286
  executionMode: {
1092
1287
  type: 'string',
1093
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.',
1094
1291
  },
1095
1292
  },
1096
1293
  required: ['agentEndpoints', 'direction', 'maxSimulationDurationSeconds'],
1097
1294
  },
1098
1295
  template: {
1099
1296
  type: 'string',
1100
- 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.',
1101
1299
  },
1102
1300
  agentEndpoints: {
1103
1301
  type: 'array',
1104
1302
  items: endpointSchema,
1105
- 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}`,
1106
1309
  },
1107
- direction: { type: 'string', enum: [...DIRECTIONS], description: 'Required with template.' },
1108
1310
  flows: {
1109
1311
  type: 'array',
1110
1312
  items: flowAttachmentSchema,
1111
- 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.",
1112
1325
  },
1113
- iterationCount: { type: 'number' },
1114
- maxSimulationDurationSeconds: { type: 'number' },
1115
1326
  saveAsPlan: {
1116
1327
  type: 'boolean',
1117
1328
  description:
1118
1329
  'When plan is set, true keeps the plan so it can be run again by planId. Requires plan.name.',
1119
1330
  },
1120
1331
  variables: {
1332
+ type: ['object', 'array'],
1121
1333
  description:
1122
- 'Placeholder values for the run. An object applies to the whole run. An array applies per flow.',
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).',
1335
+ additionalProperties: { type: 'string' },
1336
+ items: {
1337
+ type: 'object',
1338
+ properties: {
1339
+ flowId: { type: 'string', description: 'Customer flow id the values apply to.' },
1340
+ edgeCaseId: { type: 'string', description: 'Narrow to one edge case of that flow.' },
1341
+ happyPath: { type: 'boolean', description: "Narrow to the flow's happy path." },
1342
+ scenarioId: {
1343
+ type: 'string',
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.',
1346
+ },
1347
+ variables: stringMapSchema('The values to apply, as variable name to string value.'),
1348
+ },
1349
+ required: ['variables'],
1350
+ },
1123
1351
  },
1124
1352
  }),
1125
- writeAnnotations('Run simulation'),
1353
+ directoryOutputSchemas.runSimulation,
1354
+ writeAnnotations('Run simulation', { openWorld: true }),
1126
1355
  writeMeta('simulation', '/v1/simulation/run'),
1127
1356
  async (reqContext, args) => scopedClient(reqContext, args).simulation.run(buildRunBody(args)),
1128
1357
  ),