@opengeni/capabilities 0.1.1 → 0.2.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.
@@ -0,0 +1,58 @@
1
+ export interface IntegrationDefinitionOAuth2Authentication {
2
+ readonly kind: "oauth2";
3
+ readonly provider: "google" | "microsoft";
4
+ readonly authorizationUrl: string;
5
+ readonly tokenUrl: string;
6
+ readonly scopes: readonly string[];
7
+ readonly tokenPlacement: {
8
+ readonly carrier: "header";
9
+ readonly name: "Authorization";
10
+ readonly prefix: "Bearer ";
11
+ };
12
+ }
13
+ export type IntegrationDefinitionSource = Readonly<{
14
+ kind: "google_discovery";
15
+ url: string;
16
+ }> | Readonly<{
17
+ kind: "openapi";
18
+ url: string;
19
+ operationPathPrefixes?: readonly string[];
20
+ }>;
21
+ export interface IntegrationDefinition {
22
+ readonly id: string;
23
+ readonly name: string;
24
+ readonly summary: string;
25
+ readonly protocol: "openapi";
26
+ readonly provider: Readonly<{
27
+ id: "google" | "microsoft";
28
+ domain: string;
29
+ }>;
30
+ readonly source: IntegrationDefinitionSource;
31
+ readonly baseUrl: string;
32
+ readonly authentication: IntegrationDefinitionOAuth2Authentication;
33
+ readonly healthCheck?: Readonly<{
34
+ operationKey: string;
35
+ arguments: Readonly<Record<string, unknown>>;
36
+ }>;
37
+ readonly facets: readonly IntegrationFacetDefinition[];
38
+ }
39
+ export interface IntegrationFacetDefinition {
40
+ readonly facetKey: string;
41
+ readonly kind: "knowledge_source" | "inbound_trigger" | "delivery_destination" | "identity_link";
42
+ readonly configSchema: Readonly<Record<string, unknown>>;
43
+ readonly capabilities: Readonly<Record<string, unknown>>;
44
+ }
45
+ export declare const GOOGLE_DRIVE_INTEGRATION_DEFINITION: IntegrationDefinition;
46
+ export declare const GOOGLE_GMAIL_INTEGRATION_DEFINITION: IntegrationDefinition;
47
+ export declare const MICROSOFT_GRAPH_OPENAPI_URL = "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/openapi/v1.0/openapi.yaml";
48
+ export declare const MICROSOFT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
49
+ export declare const MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION: IntegrationDefinition;
50
+ export declare const MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION: IntegrationDefinition;
51
+ export declare const MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION: IntegrationDefinition;
52
+ export declare const MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION: IntegrationDefinition;
53
+ export declare const CORE_INTEGRATION_DEFINITIONS: readonly IntegrationDefinition[];
54
+ export declare function integrationDefinitionById(id: string): IntegrationDefinition | undefined;
55
+ export declare function integrationDefinitionProviderDomain(definition: IntegrationDefinition): string;
56
+ export declare function integrationFacetDefinitions(definitionId: string | null | undefined): readonly IntegrationFacetDefinition[];
57
+ export declare function filterOpenApiDocumentForDefinition(document: Record<string, unknown>, definition: IntegrationDefinition): Record<string, unknown>;
58
+ export declare function googleDiscoveryToOpenApi(discovery: unknown): Record<string, unknown>;
package/dist/openapi.d.ts CHANGED
@@ -22,7 +22,7 @@ export interface OpenApiOperationBinding {
22
22
  }
23
23
  export type OpenApiRevision = IntegrationRevision<OpenApiOperationBinding, "openapi">;
24
24
  export interface CompileOpenApiOptions {
25
- readonly integrationId: string;
25
+ readonly definitionId: string;
26
26
  readonly sourceUrl?: string;
27
27
  readonly baseUrl?: string;
28
28
  readonly provider?: string;
package/dist/types.d.ts CHANGED
@@ -45,7 +45,7 @@ export interface IntegrationInvocationAuthority {
45
45
  }
46
46
  export interface ResolveIntegrationCredentialRequest extends IntegrationInvocationAuthority {
47
47
  readonly protocol: Exclude<IntegrationProtocol, "mcp">;
48
- readonly integrationId: string;
48
+ readonly definitionId: string;
49
49
  readonly revisionId: string;
50
50
  readonly operationKey: string;
51
51
  readonly destinationUrl: string;
@@ -71,7 +71,7 @@ export type IntegrationRevisionSource = {
71
71
  export interface IntegrationRevision<TBinding = unknown, TProtocol extends Exclude<IntegrationProtocol, "mcp"> = Exclude<IntegrationProtocol, "mcp">> {
72
72
  readonly id: string;
73
73
  readonly protocol: TProtocol;
74
- readonly integrationId: string;
74
+ readonly definitionId: string;
75
75
  readonly contentSha256: string;
76
76
  readonly source: IntegrationRevisionSource;
77
77
  readonly title: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/capabilities",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Protocol-neutral capability integration compilers and local MCP adapters for OpenGeni.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/graphql.ts CHANGED
@@ -50,7 +50,7 @@ export interface GraphqlOperationBinding {
50
50
  export type GraphqlRevision = IntegrationRevision<GraphqlOperationBinding, "graphql">;
51
51
 
52
52
  export interface CompileGraphqlOptions {
53
- readonly integrationId: string;
53
+ readonly definitionId: string;
54
54
  readonly endpoint: string;
55
55
  readonly name?: string;
56
56
  readonly sourceUrl?: string;
@@ -170,13 +170,13 @@ export function compileGraphqlRevision(
170
170
  return {
171
171
  id,
172
172
  protocol: "graphql",
173
- integrationId: options.integrationId,
173
+ definitionId: options.definitionId,
174
174
  contentSha256,
175
175
  source: {
176
176
  url: options.sourceUrl ?? endpoint,
177
177
  ...(options.provider ? { provider: options.provider } : {}),
178
178
  },
179
- title: options.name?.trim() || options.integrationId,
179
+ title: options.name?.trim() || options.definitionId,
180
180
  tools,
181
181
  bindings,
182
182
  };
@@ -243,7 +243,7 @@ export class GraphqlMcpServer implements MCPServer {
243
243
  readonly name: string;
244
244
 
245
245
  constructor(private readonly options: GraphqlServerOptions) {
246
- this.name = `graphql:${stableToolId(options.revision.integrationId)}`;
246
+ this.name = `graphql:${stableToolId(options.revision.definitionId)}`;
247
247
  }
248
248
 
249
249
  async connect(): Promise<void> {}
@@ -330,7 +330,7 @@ export async function invokeGraphqlOperation(
330
330
  const request = { query, variables, operationName: binding.operationName };
331
331
  const firstCredential = await resolveGraphqlCredential(
332
332
  options,
333
- options.revision.integrationId,
333
+ options.revision.definitionId,
334
334
  options.revision.id,
335
335
  toolId,
336
336
  false,
@@ -339,7 +339,7 @@ export async function invokeGraphqlOperation(
339
339
  if (response.status === 401 && options.credentialResolver && options.authority.connectionRef) {
340
340
  const refreshed = await resolveGraphqlCredential(
341
341
  options,
342
- options.revision.integrationId,
342
+ options.revision.definitionId,
343
343
  options.revision.id,
344
344
  toolId,
345
345
  true,
@@ -391,7 +391,7 @@ export async function invokeGraphqlOperation(
391
391
 
392
392
  async function resolveGraphqlCredential(
393
393
  options: Omit<GraphqlServerOptions, "revision"> | GraphqlServerOptions,
394
- integrationId: string,
394
+ definitionId: string,
395
395
  revisionId: string,
396
396
  operationKey: string,
397
397
  forceRefresh: boolean,
@@ -400,7 +400,7 @@ async function resolveGraphqlCredential(
400
400
  const credential = await options.credentialResolver.resolve({
401
401
  ...options.authority,
402
402
  protocol: "graphql",
403
- integrationId,
403
+ definitionId,
404
404
  revisionId,
405
405
  operationKey,
406
406
  destinationUrl: graphqlEndpoint(options).toString(),
package/src/index.ts CHANGED
@@ -3,6 +3,6 @@ export * from "./graphql";
3
3
  export * from "./http";
4
4
  export * from "./mcp-manifest";
5
5
  export * from "./openapi";
6
- export * from "./providers";
6
+ export * from "./integration-definitions";
7
7
  export * from "./revision";
8
8
  export * from "./types";
@@ -1,6 +1,8 @@
1
1
  import { IntegrationProtocolError } from "./types";
2
2
 
3
- export interface OAuthProviderPreset {
3
+ export interface IntegrationDefinitionOAuth2Authentication {
4
+ readonly kind: "oauth2";
5
+ readonly provider: "google" | "microsoft";
4
6
  readonly authorizationUrl: string;
5
7
  readonly tokenUrl: string;
6
8
  readonly scopes: readonly string[];
@@ -11,32 +13,45 @@ export interface OAuthProviderPreset {
11
13
  };
12
14
  }
13
15
 
14
- export interface OpenApiProviderPreset {
16
+ export type IntegrationDefinitionSource =
17
+ | Readonly<{
18
+ kind: "google_discovery";
19
+ url: string;
20
+ }>
21
+ | Readonly<{
22
+ kind: "openapi";
23
+ url: string;
24
+ operationPathPrefixes?: readonly string[];
25
+ }>;
26
+
27
+ export interface IntegrationDefinition {
15
28
  readonly id: string;
16
29
  readonly name: string;
17
30
  readonly summary: string;
18
- readonly family: "google" | "microsoft";
19
- readonly sourceFormat: "google-discovery" | "openapi";
20
- readonly sourceUrl: string;
31
+ readonly protocol: "openapi";
32
+ readonly provider: Readonly<{
33
+ id: "google" | "microsoft";
34
+ domain: string;
35
+ }>;
36
+ readonly source: IntegrationDefinitionSource;
21
37
  readonly baseUrl: string;
22
- readonly oauth: OAuthProviderPreset;
23
- readonly pathPrefixes?: readonly string[];
24
- readonly healthOperation?: string;
25
- readonly healthArgs?: Readonly<Record<string, unknown>>;
26
- readonly features: readonly IntegrationFeatureDefinition[];
38
+ readonly authentication: IntegrationDefinitionOAuth2Authentication;
39
+ readonly healthCheck?: Readonly<{
40
+ operationKey: string;
41
+ arguments: Readonly<Record<string, unknown>>;
42
+ }>;
43
+ readonly facets: readonly IntegrationFacetDefinition[];
27
44
  }
28
45
 
29
- export interface IntegrationFeatureDefinition {
30
- readonly featureKey: string;
46
+ export interface IntegrationFacetDefinition {
47
+ readonly facetKey: string;
31
48
  readonly kind: "knowledge_source" | "inbound_trigger" | "delivery_destination" | "identity_link";
32
49
  readonly configSchema: Readonly<Record<string, unknown>>;
33
50
  readonly capabilities: Readonly<Record<string, unknown>>;
34
51
  }
35
52
 
36
- const accountIdentityFeature = (
37
- provider: "google" | "microsoft",
38
- ): IntegrationFeatureDefinition => ({
39
- featureKey: "account-identity",
53
+ const accountIdentityFacet = (provider: "google" | "microsoft"): IntegrationFacetDefinition => ({
54
+ facetKey: "account-identity",
40
55
  kind: "identity_link",
41
56
  configSchema: { type: "object", properties: {}, additionalProperties: false },
42
57
  capabilities: {
@@ -46,10 +61,10 @@ const accountIdentityFeature = (
46
61
  },
47
62
  });
48
63
 
49
- const driveKnowledgeFeature = (
64
+ const driveKnowledgeFacet = (
50
65
  provider: "google-drive" | "microsoft-onedrive",
51
- ): IntegrationFeatureDefinition => ({
52
- featureKey: "drive-content",
66
+ ): IntegrationFacetDefinition => ({
67
+ facetKey: "drive-content",
53
68
  kind: "knowledge_source",
54
69
  configSchema: {
55
70
  type: "object",
@@ -107,11 +122,11 @@ const driveKnowledgeFeature = (
107
122
  },
108
123
  });
109
124
 
110
- const mailboxFeatures = (
125
+ const mailboxFacets = (
111
126
  provider: "google-gmail" | "microsoft-outlook-mail",
112
- ): readonly IntegrationFeatureDefinition[] => [
127
+ ): readonly IntegrationFacetDefinition[] => [
113
128
  {
114
- featureKey: "mail-inbox",
129
+ facetKey: "mail-inbox",
115
130
  kind: "inbound_trigger",
116
131
  configSchema: {
117
132
  type: "object",
@@ -129,7 +144,7 @@ const mailboxFeatures = (
129
144
  },
130
145
  },
131
146
  {
132
- featureKey: "mail-delivery",
147
+ facetKey: "mail-delivery",
133
148
  kind: "delivery_destination",
134
149
  configSchema: {
135
150
  type: "object",
@@ -145,100 +160,114 @@ const mailboxFeatures = (
145
160
  delivery: "email",
146
161
  },
147
162
  },
148
- accountIdentityFeature(provider === "google-gmail" ? "google" : "microsoft"),
163
+ accountIdentityFacet(provider === "google-gmail" ? "google" : "microsoft"),
149
164
  ];
150
165
 
151
166
  const googleDiscoveryUrl = (service: string, version: string): string =>
152
167
  `https://www.googleapis.com/discovery/v1/apis/${service}/${version}/rest`;
153
168
 
154
- const googleOAuth = (scopes: readonly string[]): OAuthProviderPreset => ({
169
+ const googleOAuth = (scopes: readonly string[]): IntegrationDefinitionOAuth2Authentication => ({
170
+ kind: "oauth2",
171
+ provider: "google",
155
172
  authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
156
173
  tokenUrl: "https://oauth2.googleapis.com/token",
157
174
  scopes: ["openid", "email", "profile", ...scopes],
158
175
  tokenPlacement: { carrier: "header", name: "Authorization", prefix: "Bearer " },
159
176
  });
160
177
 
161
- export const GOOGLE_DRIVE_PRESET: OpenApiProviderPreset = {
178
+ export const GOOGLE_DRIVE_INTEGRATION_DEFINITION: IntegrationDefinition = {
162
179
  id: "google-drive",
163
180
  name: "Google Drive",
164
181
  summary: "Files, folders, permissions, and shared drives.",
165
- family: "google",
166
- sourceFormat: "google-discovery",
167
- sourceUrl: googleDiscoveryUrl("drive", "v3"),
182
+ protocol: "openapi",
183
+ provider: { id: "google", domain: "www.googleapis.com" },
184
+ source: { kind: "google_discovery", url: googleDiscoveryUrl("drive", "v3") },
168
185
  baseUrl: "https://www.googleapis.com/drive/v3/",
169
- oauth: googleOAuth(["https://www.googleapis.com/auth/drive"]),
170
- healthOperation: "drive.about.get",
171
- healthArgs: { query: { fields: "user" } },
172
- features: [driveKnowledgeFeature("google-drive"), accountIdentityFeature("google")],
186
+ authentication: googleOAuth(["https://www.googleapis.com/auth/drive"]),
187
+ healthCheck: {
188
+ operationKey: "drive.about.get",
189
+ arguments: { query: { fields: "user" } },
190
+ },
191
+ facets: [driveKnowledgeFacet("google-drive"), accountIdentityFacet("google")],
173
192
  };
174
193
 
175
- export const GOOGLE_GMAIL_PRESET: OpenApiProviderPreset = {
194
+ export const GOOGLE_GMAIL_INTEGRATION_DEFINITION: IntegrationDefinition = {
176
195
  id: "google-gmail",
177
196
  name: "Gmail",
178
197
  summary: "Messages, threads, labels, drafts, and sending mail.",
179
- family: "google",
180
- sourceFormat: "google-discovery",
181
- sourceUrl: googleDiscoveryUrl("gmail", "v1"),
198
+ protocol: "openapi",
199
+ provider: { id: "google", domain: "gmail.googleapis.com" },
200
+ source: { kind: "google_discovery", url: googleDiscoveryUrl("gmail", "v1") },
182
201
  baseUrl: "https://gmail.googleapis.com/",
183
- oauth: googleOAuth(["https://mail.google.com/"]),
184
- healthOperation: "gmail.users.labels.list",
185
- healthArgs: { path: { userId: "me" } },
186
- features: mailboxFeatures("google-gmail"),
202
+ authentication: googleOAuth(["https://mail.google.com/"]),
203
+ healthCheck: {
204
+ operationKey: "gmail.users.labels.list",
205
+ arguments: { path: { userId: "me" } },
206
+ },
207
+ facets: mailboxFacets("google-gmail"),
187
208
  };
188
209
 
189
210
  export const MICROSOFT_GRAPH_OPENAPI_URL =
190
211
  "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/openapi/v1.0/openapi.yaml";
191
212
  export const MICROSOFT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
192
213
 
193
- const microsoftOAuth = (scopes: readonly string[]): OAuthProviderPreset => ({
214
+ const microsoftOAuth = (scopes: readonly string[]): IntegrationDefinitionOAuth2Authentication => ({
215
+ kind: "oauth2",
216
+ provider: "microsoft",
194
217
  authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
195
218
  tokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
196
219
  scopes: ["offline_access", "User.Read", ...scopes],
197
220
  tokenPlacement: { carrier: "header", name: "Authorization", prefix: "Bearer " },
198
221
  });
199
222
 
200
- export const MICROSOFT_OUTLOOK_MAIL_PRESET: OpenApiProviderPreset = {
223
+ export const MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION: IntegrationDefinition = {
201
224
  id: "microsoft-outlook-mail",
202
225
  name: "Outlook Mail",
203
226
  summary: "Messages, folders, attachments, settings, and sending mail.",
204
- family: "microsoft",
205
- sourceFormat: "openapi",
206
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
227
+ protocol: "openapi",
228
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
229
+ source: {
230
+ kind: "openapi",
231
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
232
+ operationPathPrefixes: [
233
+ "/me/messages",
234
+ "/me/mailFolders",
235
+ "/me/sendMail",
236
+ "/me/getMailTips",
237
+ "/me/inferenceClassification",
238
+ "/me/mailboxSettings",
239
+ "/me/outlook",
240
+ ],
241
+ },
207
242
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
208
- oauth: microsoftOAuth(["Mail.ReadWrite", "Mail.Send", "MailboxSettings.ReadWrite"]),
209
- pathPrefixes: [
210
- "/me/messages",
211
- "/me/mailFolders",
212
- "/me/sendMail",
213
- "/me/getMailTips",
214
- "/me/inferenceClassification",
215
- "/me/mailboxSettings",
216
- "/me/outlook",
217
- ],
218
- features: mailboxFeatures("microsoft-outlook-mail"),
243
+ authentication: microsoftOAuth(["Mail.ReadWrite", "Mail.Send", "MailboxSettings.ReadWrite"]),
244
+ facets: mailboxFacets("microsoft-outlook-mail"),
219
245
  };
220
246
 
221
- export const MICROSOFT_OUTLOOK_CALENDAR_PRESET: OpenApiProviderPreset = {
247
+ export const MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION: IntegrationDefinition = {
222
248
  id: "microsoft-outlook-calendar",
223
249
  name: "Outlook Calendar",
224
250
  summary: "Calendars, events, availability, and scheduling.",
225
- family: "microsoft",
226
- sourceFormat: "openapi",
227
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
251
+ protocol: "openapi",
252
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
253
+ source: {
254
+ kind: "openapi",
255
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
256
+ operationPathPrefixes: [
257
+ "/me/calendar",
258
+ "/me/calendars",
259
+ "/me/calendarGroups",
260
+ "/me/calendarView",
261
+ "/me/events",
262
+ "/me/findMeetingTimes",
263
+ "/me/reminderView",
264
+ ],
265
+ },
228
266
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
229
- oauth: microsoftOAuth(["Calendars.ReadWrite"]),
230
- pathPrefixes: [
231
- "/me/calendar",
232
- "/me/calendars",
233
- "/me/calendarGroups",
234
- "/me/calendarView",
235
- "/me/events",
236
- "/me/findMeetingTimes",
237
- "/me/reminderView",
238
- ],
239
- features: [
267
+ authentication: microsoftOAuth(["Calendars.ReadWrite"]),
268
+ facets: [
240
269
  {
241
- featureKey: "calendar-events",
270
+ facetKey: "calendar-events",
242
271
  kind: "inbound_trigger",
243
272
  configSchema: {
244
273
  type: "object",
@@ -256,7 +285,7 @@ export const MICROSOFT_OUTLOOK_CALENDAR_PRESET: OpenApiProviderPreset = {
256
285
  },
257
286
  },
258
287
  {
259
- featureKey: "calendar-delivery",
288
+ facetKey: "calendar-delivery",
260
289
  kind: "delivery_destination",
261
290
  configSchema: {
262
291
  type: "object",
@@ -271,82 +300,91 @@ export const MICROSOFT_OUTLOOK_CALENDAR_PRESET: OpenApiProviderPreset = {
271
300
  delivery: "calendar_event",
272
301
  },
273
302
  },
274
- accountIdentityFeature("microsoft"),
303
+ accountIdentityFacet("microsoft"),
275
304
  ],
276
305
  };
277
306
 
278
- export const MICROSOFT_OUTLOOK_CONTACTS_PRESET: OpenApiProviderPreset = {
307
+ export const MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION: IntegrationDefinition = {
279
308
  id: "microsoft-outlook-contacts",
280
309
  name: "Outlook Contacts",
281
310
  summary: "Contacts, contact folders, and people suggestions.",
282
- family: "microsoft",
283
- sourceFormat: "openapi",
284
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
311
+ protocol: "openapi",
312
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
313
+ source: {
314
+ kind: "openapi",
315
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
316
+ operationPathPrefixes: ["/me/contacts", "/me/contactFolders", "/me/people"],
317
+ },
285
318
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
286
- oauth: microsoftOAuth(["Contacts.ReadWrite", "People.Read.All"]),
287
- pathPrefixes: ["/me/contacts", "/me/contactFolders", "/me/people"],
288
- features: [accountIdentityFeature("microsoft")],
319
+ authentication: microsoftOAuth(["Contacts.ReadWrite", "People.Read.All"]),
320
+ facets: [accountIdentityFacet("microsoft")],
289
321
  };
290
322
 
291
- export const MICROSOFT_ONEDRIVE_PRESET: OpenApiProviderPreset = {
323
+ export const MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION: IntegrationDefinition = {
292
324
  id: "microsoft-onedrive",
293
325
  name: "OneDrive",
294
326
  summary: "Drives, files, folders, sharing links, and permissions.",
295
- family: "microsoft",
296
- sourceFormat: "openapi",
297
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
327
+ protocol: "openapi",
328
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
329
+ source: {
330
+ kind: "openapi",
331
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
332
+ operationPathPrefixes: ["/me/drive", "/me/drives", "/me/followedSites", "/drives", "/shares"],
333
+ },
298
334
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
299
- oauth: microsoftOAuth(["Files.ReadWrite.All", "Sites.ReadWrite.All"]),
300
- pathPrefixes: ["/me/drive", "/me/drives", "/me/followedSites", "/drives", "/shares"],
301
- features: [driveKnowledgeFeature("microsoft-onedrive"), accountIdentityFeature("microsoft")],
335
+ authentication: microsoftOAuth(["Files.ReadWrite.All", "Sites.ReadWrite.All"]),
336
+ facets: [driveKnowledgeFacet("microsoft-onedrive"), accountIdentityFacet("microsoft")],
302
337
  };
303
338
 
304
- export const CORE_PROVIDER_PRESETS: readonly OpenApiProviderPreset[] = [
305
- GOOGLE_DRIVE_PRESET,
306
- GOOGLE_GMAIL_PRESET,
307
- MICROSOFT_OUTLOOK_MAIL_PRESET,
308
- MICROSOFT_OUTLOOK_CALENDAR_PRESET,
309
- MICROSOFT_OUTLOOK_CONTACTS_PRESET,
310
- MICROSOFT_ONEDRIVE_PRESET,
339
+ export const CORE_INTEGRATION_DEFINITIONS: readonly IntegrationDefinition[] = [
340
+ GOOGLE_DRIVE_INTEGRATION_DEFINITION,
341
+ GOOGLE_GMAIL_INTEGRATION_DEFINITION,
342
+ MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION,
343
+ MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION,
344
+ MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION,
345
+ MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION,
311
346
  ];
312
347
 
313
- export function providerPresetById(id: string): OpenApiProviderPreset | undefined {
314
- return CORE_PROVIDER_PRESETS.find((preset) => preset.id === id);
348
+ export function integrationDefinitionById(id: string): IntegrationDefinition | undefined {
349
+ return CORE_INTEGRATION_DEFINITIONS.find((definition) => definition.id === id);
315
350
  }
316
351
 
317
- export function providerDomainForPreset(preset: OpenApiProviderPreset): string {
318
- return new URL(preset.baseUrl).hostname.toLowerCase();
352
+ export function integrationDefinitionProviderDomain(definition: IntegrationDefinition): string {
353
+ return definition.provider.domain;
319
354
  }
320
355
 
321
- export function integrationFeaturesForPreset(
322
- presetId: string | null | undefined,
323
- ): readonly IntegrationFeatureDefinition[] {
324
- return presetId ? (providerPresetById(presetId)?.features ?? []) : [];
356
+ export function integrationFacetDefinitions(
357
+ definitionId: string | null | undefined,
358
+ ): readonly IntegrationFacetDefinition[] {
359
+ return definitionId ? (integrationDefinitionById(definitionId)?.facets ?? []) : [];
325
360
  }
326
361
 
327
- export function filterOpenApiDocumentForPreset(
362
+ export function filterOpenApiDocumentForDefinition(
328
363
  document: Record<string, unknown>,
329
- preset: OpenApiProviderPreset,
364
+ definition: IntegrationDefinition,
330
365
  ): Record<string, unknown> {
331
- if (!preset.pathPrefixes?.length) return document;
366
+ if (definition.source.kind !== "openapi" || !definition.source.operationPathPrefixes?.length) {
367
+ return document;
368
+ }
369
+ const operationPathPrefixes = definition.source.operationPathPrefixes;
332
370
  if (!isRecord(document.paths)) {
333
371
  throw new IntegrationProtocolError("openapi_paths", "OpenAPI document has no paths object");
334
372
  }
335
373
  const paths = Object.fromEntries(
336
374
  Object.entries(document.paths).filter(([path]) =>
337
- preset.pathPrefixes!.some((prefix) => path === prefix || path.startsWith(`${prefix}/`)),
375
+ operationPathPrefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}/`)),
338
376
  ),
339
377
  );
340
378
  if (Object.keys(paths).length === 0) {
341
379
  throw new IntegrationProtocolError(
342
- "provider_preset_empty",
343
- `${preset.name} did not match any operations in the supplied OpenAPI document`,
380
+ "integration_definition_empty",
381
+ `${definition.name} did not match any operations in the supplied OpenAPI document`,
344
382
  );
345
383
  }
346
384
  return {
347
385
  ...document,
348
386
  paths,
349
- ...(preset.baseUrl ? { servers: [{ url: preset.baseUrl }] } : {}),
387
+ servers: [{ url: definition.baseUrl }],
350
388
  };
351
389
  }
352
390
 
package/src/openapi.ts CHANGED
@@ -55,7 +55,7 @@ export interface OpenApiOperationBinding {
55
55
  export type OpenApiRevision = IntegrationRevision<OpenApiOperationBinding, "openapi">;
56
56
 
57
57
  export interface CompileOpenApiOptions {
58
- readonly integrationId: string;
58
+ readonly definitionId: string;
59
59
  readonly sourceUrl?: string;
60
60
  readonly baseUrl?: string;
61
61
  readonly provider?: string;
@@ -212,13 +212,13 @@ export function compileOpenApiRevision(
212
212
  return {
213
213
  id: revisionId,
214
214
  protocol: "openapi",
215
- integrationId: options.integrationId,
215
+ definitionId: options.definitionId,
216
216
  contentSha256,
217
217
  source: {
218
218
  ...(options.sourceUrl ? { url: options.sourceUrl } : {}),
219
219
  ...(options.provider ? { provider: options.provider } : {}),
220
220
  },
221
- title: stringValue(info.title) ?? options.integrationId,
221
+ title: stringValue(info.title) ?? options.definitionId,
222
222
  ...(stringValue(info.description) ? { description: stringValue(info.description)! } : {}),
223
223
  ...(stringValue(info.version) ? { version: stringValue(info.version)! } : {}),
224
224
  tools,
@@ -261,7 +261,7 @@ export class OpenApiMcpServer implements MCPServer {
261
261
  readonly name: string;
262
262
 
263
263
  constructor(private readonly options: OpenApiServerOptions) {
264
- this.name = `openapi:${stableToolId(options.revision.integrationId)}`;
264
+ this.name = `openapi:${stableToolId(options.revision.definitionId)}`;
265
265
  }
266
266
 
267
267
  async connect(): Promise<void> {}
@@ -395,7 +395,7 @@ async function resolveOpenApiCredential(
395
395
  const credential = await options.credentialResolver.resolve({
396
396
  ...options.authority,
397
397
  protocol: "openapi",
398
- integrationId: options.revision.integrationId,
398
+ definitionId: options.revision.definitionId,
399
399
  revisionId: options.revision.id,
400
400
  operationKey: toolId,
401
401
  destinationUrl,
package/src/types.ts CHANGED
@@ -54,7 +54,7 @@ export interface IntegrationInvocationAuthority {
54
54
 
55
55
  export interface ResolveIntegrationCredentialRequest extends IntegrationInvocationAuthority {
56
56
  readonly protocol: Exclude<IntegrationProtocol, "mcp">;
57
- readonly integrationId: string;
57
+ readonly definitionId: string;
58
58
  readonly revisionId: string;
59
59
  readonly operationKey: string;
60
60
  readonly destinationUrl: string;
@@ -90,7 +90,7 @@ export interface IntegrationRevision<
90
90
  > {
91
91
  readonly id: string;
92
92
  readonly protocol: TProtocol;
93
- readonly integrationId: string;
93
+ readonly definitionId: string;
94
94
  readonly contentSha256: string;
95
95
  readonly source: IntegrationRevisionSource;
96
96
  readonly title: string;