@chronary/toolkit 1.3.0 → 1.4.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.
package/dist/mcp.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ZodRawShape } from 'zod';
2
- import { L as ListToolkit, a as ToolAnnotations, C as ChronaryToolkitConfig, T as ToolDefinition } from './base-C6QWbxc1.cjs';
2
+ import { L as ListToolkit, a as ToolAnnotations, C as ChronaryToolkitConfig, T as ToolDefinition } from './base-BM5HxeCZ.cjs';
3
3
  import '@chronary/sdk';
4
4
 
5
5
  interface McpToolDefinition {
@@ -21,12 +21,42 @@ type McpToolHandlerResult = {
21
21
  }>;
22
22
  isError?: boolean;
23
23
  };
24
+ interface McpPromptRegistrationConfig {
25
+ title?: string;
26
+ description?: string;
27
+ argsSchema?: ZodRawShape;
28
+ }
29
+ type McpPromptHandlerResult = {
30
+ messages: Array<{
31
+ role: 'user';
32
+ content: {
33
+ type: 'text';
34
+ text: string;
35
+ };
36
+ }>;
37
+ };
38
+ interface McpResourceRegistrationConfig {
39
+ title?: string;
40
+ description?: string;
41
+ mimeType?: string;
42
+ }
43
+ type McpResourceHandlerResult = {
44
+ contents: Array<{
45
+ uri: string;
46
+ mimeType: string;
47
+ text: string;
48
+ }>;
49
+ };
24
50
  /**
25
51
  * Minimal shape of the MCP SDK's `McpServer` that the toolkit depends on.
26
52
  * Matches `registerTool(name, config, handler)` from `@modelcontextprotocol/sdk` >= 1.10.
53
+ * `registerPrompt` / `registerResource` are optional so tool-only callers (and
54
+ * the test mocks) don't have to implement them.
27
55
  */
28
56
  interface McpServerLike {
29
57
  registerTool(name: string, config: McpToolRegistrationConfig, handler: (params: Record<string, unknown>) => Promise<McpToolHandlerResult>): unknown;
58
+ registerPrompt?(name: string, config: McpPromptRegistrationConfig, handler: (...args: any[]) => McpPromptHandlerResult | Promise<McpPromptHandlerResult>): unknown;
59
+ registerResource?(name: string, uri: string, config: McpResourceRegistrationConfig, handler: (...args: any[]) => McpResourceHandlerResult | Promise<McpResourceHandlerResult>): unknown;
30
60
  }
31
61
  /**
32
62
  * MCP v1.x adapter.
@@ -52,6 +82,18 @@ declare class ChronaryToolkit extends ListToolkit<McpToolDefinition> {
52
82
  * Uses `server.registerTool()` (MCP SDK v1.10+) so annotations reach the client.
53
83
  */
54
84
  registerAll(server: McpServerLike): void;
85
+ /**
86
+ * Register the reusable prompt templates (MCP `prompts` capability) on an
87
+ * McpServer. Mirrors the hosted server's four prompts so stdio and hosted
88
+ * expose the same `prompts/list`. No-op if the server can't register prompts.
89
+ */
90
+ registerPrompts(server: McpServerLike): void;
91
+ /**
92
+ * Register the static `chronary://about` resource (MCP `resources` capability)
93
+ * so stdio and hosted expose the same `resources/list`. No-op if the server
94
+ * can't register resources.
95
+ */
96
+ registerResources(server: McpServerLike): void;
55
97
  }
56
98
 
57
- export { ChronaryToolkit, type McpServerLike, type McpToolDefinition, type McpToolHandlerResult, type McpToolRegistrationConfig };
99
+ export { ChronaryToolkit, type McpPromptHandlerResult, type McpPromptRegistrationConfig, type McpResourceHandlerResult, type McpResourceRegistrationConfig, type McpServerLike, type McpToolDefinition, type McpToolHandlerResult, type McpToolRegistrationConfig };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ZodRawShape } from 'zod';
2
- import { L as ListToolkit, a as ToolAnnotations, C as ChronaryToolkitConfig, T as ToolDefinition } from './base-C6QWbxc1.js';
2
+ import { L as ListToolkit, a as ToolAnnotations, C as ChronaryToolkitConfig, T as ToolDefinition } from './base-BM5HxeCZ.js';
3
3
  import '@chronary/sdk';
4
4
 
5
5
  interface McpToolDefinition {
@@ -21,12 +21,42 @@ type McpToolHandlerResult = {
21
21
  }>;
22
22
  isError?: boolean;
23
23
  };
24
+ interface McpPromptRegistrationConfig {
25
+ title?: string;
26
+ description?: string;
27
+ argsSchema?: ZodRawShape;
28
+ }
29
+ type McpPromptHandlerResult = {
30
+ messages: Array<{
31
+ role: 'user';
32
+ content: {
33
+ type: 'text';
34
+ text: string;
35
+ };
36
+ }>;
37
+ };
38
+ interface McpResourceRegistrationConfig {
39
+ title?: string;
40
+ description?: string;
41
+ mimeType?: string;
42
+ }
43
+ type McpResourceHandlerResult = {
44
+ contents: Array<{
45
+ uri: string;
46
+ mimeType: string;
47
+ text: string;
48
+ }>;
49
+ };
24
50
  /**
25
51
  * Minimal shape of the MCP SDK's `McpServer` that the toolkit depends on.
26
52
  * Matches `registerTool(name, config, handler)` from `@modelcontextprotocol/sdk` >= 1.10.
53
+ * `registerPrompt` / `registerResource` are optional so tool-only callers (and
54
+ * the test mocks) don't have to implement them.
27
55
  */
28
56
  interface McpServerLike {
29
57
  registerTool(name: string, config: McpToolRegistrationConfig, handler: (params: Record<string, unknown>) => Promise<McpToolHandlerResult>): unknown;
58
+ registerPrompt?(name: string, config: McpPromptRegistrationConfig, handler: (...args: any[]) => McpPromptHandlerResult | Promise<McpPromptHandlerResult>): unknown;
59
+ registerResource?(name: string, uri: string, config: McpResourceRegistrationConfig, handler: (...args: any[]) => McpResourceHandlerResult | Promise<McpResourceHandlerResult>): unknown;
30
60
  }
31
61
  /**
32
62
  * MCP v1.x adapter.
@@ -52,6 +82,18 @@ declare class ChronaryToolkit extends ListToolkit<McpToolDefinition> {
52
82
  * Uses `server.registerTool()` (MCP SDK v1.10+) so annotations reach the client.
53
83
  */
54
84
  registerAll(server: McpServerLike): void;
85
+ /**
86
+ * Register the reusable prompt templates (MCP `prompts` capability) on an
87
+ * McpServer. Mirrors the hosted server's four prompts so stdio and hosted
88
+ * expose the same `prompts/list`. No-op if the server can't register prompts.
89
+ */
90
+ registerPrompts(server: McpServerLike): void;
91
+ /**
92
+ * Register the static `chronary://about` resource (MCP `resources` capability)
93
+ * so stdio and hosted expose the same `resources/list`. No-op if the server
94
+ * can't register resources.
95
+ */
96
+ registerResources(server: McpServerLike): void;
55
97
  }
56
98
 
57
- export { ChronaryToolkit, type McpServerLike, type McpToolDefinition, type McpToolHandlerResult, type McpToolRegistrationConfig };
99
+ export { ChronaryToolkit, type McpPromptHandlerResult, type McpPromptRegistrationConfig, type McpResourceHandlerResult, type McpResourceRegistrationConfig, type McpServerLike, type McpToolDefinition, type McpToolHandlerResult, type McpToolRegistrationConfig };
package/dist/mcp.js CHANGED
@@ -151,6 +151,15 @@ var FindMeetingTimeSchema = z.object({
151
151
  calendars: z.array(z.string()).optional().describe("Additional shared calendar IDs to treat as busy"),
152
152
  include_busy: z.boolean().default(false).describe("Include per-agent busy blocks in response")
153
153
  });
154
+ var CreateConnectionLinkSchema = z.object({
155
+ calendar_id: z.string().startsWith("cal_").describe("Chronary calendar whose owning agent will receive authorized availability"),
156
+ capabilities: z.array(z.enum(["availability", "publishing"])).min(1).max(2).default(["availability"]).describe("Request opaque availability and optional publishing permission"),
157
+ publication_policy: z.enum(["none", "confirmed", "confirmed_tentative"]).default("none").describe("Desired event publishing policy; a human still selects the destination")
158
+ });
159
+ var GetConnectionLinkSchema = z.object({
160
+ connection_link_id: z.string().startsWith("csl_").describe("Connection setup link ID")
161
+ });
162
+ var CancelConnectionLinkSchema = GetConnectionLinkSchema;
154
163
  var GetCalendarContextSchema = z.object({
155
164
  calendar_id: z.string().describe("Calendar ID")
156
165
  });
@@ -447,6 +456,15 @@ var findMeetingTime = safeFunc(async (ctx) => {
447
456
  include_busy: params.include_busy
448
457
  });
449
458
  });
459
+ var createConnectionLink = safeFunc(async (ctx) => {
460
+ const { calendar_id, ...params } = ctx.params;
461
+ return ctx.client.connectionLinks.create(calendar_id, params);
462
+ });
463
+ var getConnectionLink = safeFunc(async (ctx) => ctx.client.connectionLinks.get(ctx.params.connection_link_id));
464
+ var cancelConnectionLink = safeFunc(async (ctx) => {
465
+ await ctx.client.connectionLinks.cancel(ctx.params.connection_link_id);
466
+ return { cancelled: true, id: ctx.params.connection_link_id };
467
+ });
450
468
  var getCalendarContext = safeFunc(async (ctx) => {
451
469
  return ctx.client.calendars.getContext(ctx.params.calendar_id);
452
470
  });
@@ -576,6 +594,9 @@ var HOSTED_API_MCP_TOOL_NAMES = [
576
594
  "update_event",
577
595
  "get_availability",
578
596
  "find_meeting_time",
597
+ "create_connection_link",
598
+ "get_connection_link",
599
+ "cancel_connection_link",
579
600
  "cancel_event",
580
601
  "confirm_event",
581
602
  "release_event",
@@ -741,18 +762,39 @@ var TOOL_DEFINITIONS = [
741
762
  // ── Availability ───────────────────────────────────────────────
742
763
  {
743
764
  name: "get_availability",
744
- description: "Check when a single agent is free within a time range. Accepts `start`/`end` (preferred \u2014 matches the underlying availability service) or `start_time`/`end_time` (aliases that match the REST events schema).",
765
+ description: "Check when a single agent is free across Chronary and authorized human calendars. This tool is fail-closed: always inspect availability_state and warnings before using slots.",
745
766
  schema: GetAvailabilitySchema,
746
767
  annotations: { title: "Get Availability", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
747
768
  execute: createExecutor(getAvailability)
748
769
  },
749
770
  {
750
771
  name: "find_meeting_time",
751
- description: "Find time slots when multiple agents are all free simultaneously. Accepts `agents`/`start`/`end` (preferred \u2014 matches the availability service) or `agent_ids`/`start_time`/`end_time` (aliases that match the REST/scheduling-proposal naming).",
772
+ description: "Find time when multiple agents are free across Chronary and their authorized human calendars. This tool is fail-closed: always inspect availability_state and warnings before using slots.",
752
773
  schema: FindMeetingTimeSchema,
753
774
  annotations: { title: "Find Meeting Time", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
754
775
  execute: createExecutor(findMeetingTime)
755
776
  },
777
+ {
778
+ name: "create_connection_link",
779
+ description: "Request human setup of Google Calendar or Microsoft Outlook for a Chronary calendar. Give setup_url to a human; agents never receive provider credentials or event data. The secret URL is returned only once.",
780
+ schema: CreateConnectionLinkSchema,
781
+ annotations: { title: "Create Human Calendar Setup Link", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
782
+ execute: createExecutor(createConnectionLink)
783
+ },
784
+ {
785
+ name: "get_connection_link",
786
+ description: "Poll provider-neutral human-calendar setup status. The bearer setup URL and provider data are never returned by polling.",
787
+ schema: GetConnectionLinkSchema,
788
+ annotations: { title: "Get Human Calendar Setup Status", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
789
+ execute: createExecutor(getConnectionLink)
790
+ },
791
+ {
792
+ name: "cancel_connection_link",
793
+ description: "Cancel a pending human-calendar setup request and invalidate its setup URL.",
794
+ schema: CancelConnectionLinkSchema,
795
+ annotations: { title: "Cancel Human Calendar Setup Link", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
796
+ execute: createExecutor(cancelConnectionLink)
797
+ },
756
798
  // ── Calendar context ───────────────────────────────────────────
757
799
  {
758
800
  name: "get_calendar_context",
@@ -988,6 +1030,23 @@ var ListToolkit = class extends BaseToolkit {
988
1030
  };
989
1031
 
990
1032
  // src/adapters/mcp.ts
1033
+ var ABOUT_MARKDOWN = `# Chronary
1034
+
1035
+ Calendar-as-a-service for AI agents. Give an agent its own calendars and
1036
+ events, coordinate availability across agents, run multi-party scheduling
1037
+ proposals, place auto-expiring holds, manage availability rules, sync external
1038
+ iCal feeds, and receive webhooks.
1039
+
1040
+ ## Getting started
1041
+ 1. \`create_agent\` \u2014 register an agent (skip if you already have one).
1042
+ 2. \`create_calendar\` \u2014 give the agent a calendar.
1043
+ 3. \`create_event\` / \`get_availability\` / \`find_meeting_time\` \u2014 schedule and coordinate.
1044
+
1045
+ ## Keys & plans
1046
+ Org keys (\`chr_sk_\`) can use every tool; agent-scoped keys (\`chr_ak_\`) are
1047
+ limited to their own agent and cannot use org-only tools such as
1048
+ \`create_agent\` or \`find_meeting_time\`. Temporal holds, cross-agent
1049
+ availability, and scheduling proposals require a Pro plan.`;
991
1050
  var ChronaryToolkit = class extends ListToolkit {
992
1051
  constructor(config) {
993
1052
  super(config);
@@ -1024,6 +1083,126 @@ var ChronaryToolkit = class extends ListToolkit {
1024
1083
  );
1025
1084
  }
1026
1085
  }
1086
+ /**
1087
+ * Register the reusable prompt templates (MCP `prompts` capability) on an
1088
+ * McpServer. Mirrors the hosted server's four prompts so stdio and hosted
1089
+ * expose the same `prompts/list`. No-op if the server can't register prompts.
1090
+ */
1091
+ registerPrompts(server) {
1092
+ if (!server.registerPrompt) return;
1093
+ server.registerPrompt(
1094
+ "schedule_event",
1095
+ {
1096
+ title: "Schedule an event",
1097
+ description: "Create a calendar event on an agent's calendar at a specific time.",
1098
+ argsSchema: {
1099
+ calendar_id: z2.string().describe("Target calendar ID (cal_...). Run list_calendars first if unknown."),
1100
+ title: z2.string().describe("Event title"),
1101
+ start_time: z2.string().describe("Start time, ISO 8601 (e.g. 2026-07-10T15:00:00Z)"),
1102
+ end_time: z2.string().describe("End time, ISO 8601")
1103
+ }
1104
+ },
1105
+ ({ calendar_id, title, start_time, end_time }) => ({
1106
+ messages: [
1107
+ {
1108
+ role: "user",
1109
+ content: {
1110
+ type: "text",
1111
+ text: `Create an event on calendar ${calendar_id} titled "${title}" from ${start_time} to ${end_time}. Call the create_event tool with those arguments (calendar_id, title, start_time, end_time). If the calendar ID is unknown, call list_calendars first. Report the created event ID when done.`
1112
+ }
1113
+ }
1114
+ ]
1115
+ })
1116
+ );
1117
+ server.registerPrompt(
1118
+ "find_meeting_time",
1119
+ {
1120
+ title: "Find a meeting time",
1121
+ description: "Find a slot that works across several agents, then optionally book it.",
1122
+ argsSchema: {
1123
+ agent_ids: z2.string().describe("Comma-separated agent IDs to coordinate (agt_...)."),
1124
+ duration: z2.string().describe('Meeting length, e.g. "30m" or "1h".'),
1125
+ window: z2.string().optional().describe('Optional ISO 8601 range to search, e.g. "2026-07-10T09:00:00Z/2026-07-10T18:00:00Z".')
1126
+ }
1127
+ },
1128
+ ({ agent_ids, duration, window }) => ({
1129
+ messages: [
1130
+ {
1131
+ role: "user",
1132
+ content: {
1133
+ type: "text",
1134
+ text: `Find a ${duration} slot that works for all of these agents: ${agent_ids}${window ? ` within ${window}` : ""}. Call the find_meeting_time tool (agents, duration, and start/end if a window is given). Present the top few candidate slots and ask which to book before calling create_event. (find_meeting_time requires a Pro plan.)`
1135
+ }
1136
+ }
1137
+ ]
1138
+ })
1139
+ );
1140
+ server.registerPrompt(
1141
+ "daily_agenda",
1142
+ {
1143
+ title: "Summarize an agent's day",
1144
+ description: "Get an agent's current status and upcoming schedule at a glance.",
1145
+ argsSchema: {
1146
+ agent_id: z2.string().describe("Agent whose day to summarize (agt_...)."),
1147
+ date: z2.string().optional().describe("Optional ISO 8601 date to focus on (defaults to today).")
1148
+ }
1149
+ },
1150
+ ({ agent_id, date }) => ({
1151
+ messages: [
1152
+ {
1153
+ role: "user",
1154
+ content: {
1155
+ type: "text",
1156
+ text: `Summarize agent ${agent_id}'s schedule${date ? ` for ${date}` : " for today"}. Use list_calendars to find the agent's calendar(s), then get_calendar_context for the current/next/upcoming events and status. Present a concise agenda.`
1157
+ }
1158
+ }
1159
+ ]
1160
+ })
1161
+ );
1162
+ server.registerPrompt(
1163
+ "new_scheduling_proposal",
1164
+ {
1165
+ title: "Propose a multi-party meeting",
1166
+ description: "Create a scheduling proposal offering several time slots to participants.",
1167
+ argsSchema: {
1168
+ title: z2.string().describe("Proposal / meeting title"),
1169
+ organizer_agent_id: z2.string().describe("Organizer agent ID (agt_...)."),
1170
+ participant_agent_ids: z2.string().describe("Comma-separated participant agent IDs (agt_...).")
1171
+ }
1172
+ },
1173
+ ({ title, organizer_agent_id, participant_agent_ids }) => ({
1174
+ messages: [
1175
+ {
1176
+ role: "user",
1177
+ content: {
1178
+ type: "text",
1179
+ text: `Create a scheduling proposal "${title}" organized by ${organizer_agent_id} for participants ${participant_agent_ids}. First use get_availability / find_meeting_time to pick 2-3 candidate slots, then call create_proposal with those slots. Report the proposal ID. (Scheduling proposals require a Pro plan and an org-level key.)`
1180
+ }
1181
+ }
1182
+ ]
1183
+ })
1184
+ );
1185
+ }
1186
+ /**
1187
+ * Register the static `chronary://about` resource (MCP `resources` capability)
1188
+ * so stdio and hosted expose the same `resources/list`. No-op if the server
1189
+ * can't register resources.
1190
+ */
1191
+ registerResources(server) {
1192
+ if (!server.registerResource) return;
1193
+ server.registerResource(
1194
+ "about",
1195
+ "chronary://about",
1196
+ {
1197
+ title: "About Chronary",
1198
+ description: "What Chronary is and how to use its MCP tools.",
1199
+ mimeType: "text/markdown"
1200
+ },
1201
+ () => ({
1202
+ contents: [{ uri: "chronary://about", mimeType: "text/markdown", text: ABOUT_MARKDOWN }]
1203
+ })
1204
+ );
1205
+ }
1027
1206
  };
1028
1207
  export {
1029
1208
  ChronaryToolkit