@burdenoff/mcp-libs 2026.703.1 → 2026.703.3
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/modules/atheletebridge/index.cjs +4 -4
- package/dist/modules/atheletebridge/index.cjs.map +1 -1
- package/dist/modules/atheletebridge/index.js +4 -4
- package/dist/modules/atheletebridge/index.js.map +1 -1
- package/dist/modules/integrations/index.cjs +43 -9
- package/dist/modules/integrations/index.cjs.map +1 -1
- package/dist/modules/integrations/index.js +43 -9
- package/dist/modules/integrations/index.js.map +1 -1
- package/dist/modules/scheduler/index.cjs +5 -5
- package/dist/modules/scheduler/index.cjs.map +1 -1
- package/dist/modules/scheduler/index.js +5 -5
- package/dist/modules/scheduler/index.js.map +1 -1
- package/dist/modules/vibecontrols/index.cjs +848 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -1
- package/dist/modules/vibecontrols/index.js +634 -1
- package/dist/modules/vibecontrols/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -101,6 +101,14 @@ var GET_INTEGRATION_LOGS = `
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
`;
|
|
104
|
+
var GET_CONNECTION_LOGS = `
|
|
105
|
+
query GetConnectionLogs($connectionId: ID!, $pagination: IntegrationsPaginationInput) {
|
|
106
|
+
getConnectionLogs(connectionId: $connectionId, pagination: $pagination) {
|
|
107
|
+
items { id action level message createdAt }
|
|
108
|
+
total hasMore
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
104
112
|
var UPDATE_CONNECTION = `
|
|
105
113
|
mutation UpdateConnection($id: ID!, $input: UpdateConnectionInput!) {
|
|
106
114
|
updateConnection(id: $id, input: $input) { id name status }
|
|
@@ -440,7 +448,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
440
448
|
}
|
|
441
449
|
);
|
|
442
450
|
server.registerTool(
|
|
443
|
-
track(mcpToolName(ctx.productName, "
|
|
451
|
+
track(mcpToolName(ctx.productName, "integrations_connections_link_to_channel")),
|
|
444
452
|
{
|
|
445
453
|
title: "Link Connection to Channel",
|
|
446
454
|
description: "Link an integration connection to a channel for DM/notification routing.",
|
|
@@ -547,7 +555,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
547
555
|
}
|
|
548
556
|
);
|
|
549
557
|
server.registerTool(
|
|
550
|
-
track(mcpToolName(ctx.productName, "
|
|
558
|
+
track(mcpToolName(ctx.productName, "integrations_auth_oauth_initiate")),
|
|
551
559
|
{
|
|
552
560
|
title: "Initiate OAuth Flow",
|
|
553
561
|
description: "Start an OAuth flow; returns redirectUrl + state for the client to use.",
|
|
@@ -641,7 +649,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
641
649
|
}
|
|
642
650
|
);
|
|
643
651
|
server.registerTool(
|
|
644
|
-
track(mcpToolName(ctx.productName, "
|
|
652
|
+
track(mcpToolName(ctx.productName, "integrations_providers_by_provider")),
|
|
645
653
|
{
|
|
646
654
|
title: "Connections By Provider",
|
|
647
655
|
description: "List all connections that belong to a given provider.",
|
|
@@ -707,7 +715,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
707
715
|
}
|
|
708
716
|
);
|
|
709
717
|
server.registerTool(
|
|
710
|
-
track(mcpToolName(ctx.productName, "
|
|
718
|
+
track(mcpToolName(ctx.productName, "integrations_tags_add")),
|
|
711
719
|
{
|
|
712
720
|
title: "Tag Connection",
|
|
713
721
|
description: "Add a tag assignment to a connection.",
|
|
@@ -735,7 +743,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
735
743
|
}
|
|
736
744
|
);
|
|
737
745
|
server.registerTool(
|
|
738
|
-
track(mcpToolName(ctx.productName, "
|
|
746
|
+
track(mcpToolName(ctx.productName, "integrations_tags_remove")),
|
|
739
747
|
{
|
|
740
748
|
title: "Untag Connection",
|
|
741
749
|
description: "Remove a tag assignment from a connection.",
|
|
@@ -757,7 +765,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
757
765
|
}
|
|
758
766
|
);
|
|
759
767
|
server.registerTool(
|
|
760
|
-
track(mcpToolName(ctx.productName, "
|
|
768
|
+
track(mcpToolName(ctx.productName, "integrations_tags_replace")),
|
|
761
769
|
{
|
|
762
770
|
title: "Replace Connection Tags",
|
|
763
771
|
description: "Replace all tag assignments on a connection.",
|
|
@@ -779,7 +787,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
779
787
|
}
|
|
780
788
|
);
|
|
781
789
|
server.registerTool(
|
|
782
|
-
track(mcpToolName(ctx.productName, "
|
|
790
|
+
track(mcpToolName(ctx.productName, "integrations_tags_list")),
|
|
783
791
|
{
|
|
784
792
|
title: "List Connection Tags",
|
|
785
793
|
description: "List tag assignments on a connection.",
|
|
@@ -801,7 +809,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
801
809
|
}
|
|
802
810
|
);
|
|
803
811
|
server.registerTool(
|
|
804
|
-
track(mcpToolName(ctx.productName, "
|
|
812
|
+
track(mcpToolName(ctx.productName, "integrations_integration_logs")),
|
|
805
813
|
{
|
|
806
814
|
title: "Integration Audit Logs",
|
|
807
815
|
description: "List integration audit logs with optional filters.",
|
|
@@ -822,13 +830,39 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
822
830
|
});
|
|
823
831
|
return jsonResult(data.getIntegrationLogs);
|
|
824
832
|
} catch (error) {
|
|
825
|
-
ctx.logger.error("
|
|
833
|
+
ctx.logger.error("integrations_integration_logs failed", { error: String(error) });
|
|
826
834
|
return errorResult(
|
|
827
835
|
`Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`
|
|
828
836
|
);
|
|
829
837
|
}
|
|
830
838
|
}
|
|
831
839
|
);
|
|
840
|
+
server.registerTool(
|
|
841
|
+
track(mcpToolName(ctx.productName, "integrations_logs")),
|
|
842
|
+
{
|
|
843
|
+
title: "Connection Audit Logs",
|
|
844
|
+
description: "List audit logs for a specific integration connection.",
|
|
845
|
+
inputSchema: {
|
|
846
|
+
connection: zod.z.string().describe("Connection ID (required)"),
|
|
847
|
+
limit: zod.z.number().optional().describe("Page size (default 100)"),
|
|
848
|
+
offset: zod.z.number().optional().describe("Offset (default 0)")
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
async ({ connection, limit, offset }) => {
|
|
852
|
+
try {
|
|
853
|
+
const data = await ctx.gql.workspace.request(GET_CONNECTION_LOGS, {
|
|
854
|
+
connectionId: connection,
|
|
855
|
+
pagination: { limit: limit ?? 100, offset: offset ?? 0 }
|
|
856
|
+
});
|
|
857
|
+
return jsonResult(data.getConnectionLogs);
|
|
858
|
+
} catch (error) {
|
|
859
|
+
ctx.logger.error("integrations_logs failed", { error: String(error) });
|
|
860
|
+
return errorResult(
|
|
861
|
+
`Failed to get connection logs: ${error instanceof Error ? error.message : String(error)}`
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
);
|
|
832
866
|
}
|
|
833
867
|
|
|
834
868
|
// src/modules/integrations/index.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/integrations/operations.ts","../../../src/modules/integrations/tools.ts","../../../src/modules/integrations/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;ACCO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,SAAA,CAA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A,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,yBAAA,CAA0B,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE5C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,oBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const GET_PROVIDERS = `\n query GetProviders($filter: ProviderFilterInput, $pagination: IntegrationsPaginationInput) {\n getProviders(filter: $filter, pagination: $pagination) {\n items { id key name category authType isEnabled }\n total hasMore\n }\n }\n`;\n\nexport const GET_PROVIDER = `\n query GetProvider($id: ID!) {\n getProvider(id: $id) {\n id key name authType category connectionCount\n }\n }\n`;\n\nexport const GET_CONNECTIONS = `\n query GetConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {\n getConnections(filter: $filter, pagination: $pagination) {\n items { id name providerId status grantedScopes }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTION = `\n query GetConnection($id: ID!) {\n getConnection(id: $id) {\n id name providerId status externalAccountEmail credentialSource\n }\n }\n`;\n\nexport const CREATE_CONNECTION = `\n mutation CreateConnection($input: CreateConnectionInput!) {\n createConnection(input: $input) {\n id name status providerId\n }\n }\n`;\n\nexport const DELETE_CONNECTION = `\n mutation DeleteConnection($id: ID!, $deleteVaultSecret: Boolean) {\n deleteConnection(id: $id, deleteVaultSecret: $deleteVaultSecret)\n }\n`;\n\nexport const GET_INTEGRATION_LOGS = `\n query GetIntegrationLogs($filter: LogFilterInput, $pagination: IntegrationsPaginationInput) {\n getIntegrationLogs(filter: $filter, pagination: $pagination) {\n items { id action level message createdAt }\n total hasMore\n }\n }\n`;\n\nexport const UPDATE_CONNECTION = `\n mutation UpdateConnection($id: ID!, $input: UpdateConnectionInput!) {\n updateConnection(id: $id, input: $input) { id name status }\n }\n`;\n\nexport const REVOKE_CONNECTION = `\n mutation RevokeConnection($connectionId: ID!) {\n revokeConnection(connectionId: $connectionId) { id name status }\n }\n`;\n\nexport const TEST_CONNECTION = `\n mutation TestConnection($connectionId: ID!) {\n testConnection(connectionId: $connectionId) { success message latencyMs }\n }\n`;\n\nexport const LINK_INTEGRATION_TO_CHANNEL = `\n mutation LinkIntegrationToChannel($channelId: String!, $connectionId: ID!, $organizationId: String!) {\n linkIntegrationToChannel(channelId: $channelId, connectionId: $connectionId, organizationId: $organizationId) {\n id name status channelId organizationId\n }\n }\n`;\n\nexport const REFRESH_CONNECTION_TOKEN = `\n mutation RefreshConnectionToken($connectionId: ID!) {\n refreshConnectionToken(connectionId: $connectionId) { id status }\n }\n`;\n\nexport const AUTHENTICATE_API_KEY = `\n mutation AuthenticateWithApiKey($input: ApiKeyAuthInput!) {\n authenticateWithApiKey(input: $input) { id name status }\n }\n`;\n\nexport const AUTHENTICATE_BASIC = `\n mutation AuthenticateWithBasicAuth($input: BasicAuthInput!) {\n authenticateWithBasicAuth(input: $input) { id name status }\n }\n`;\n\nexport const AUTHENTICATE_BEARER = `\n mutation AuthenticateWithBearerToken($input: BearerTokenAuthInput!) {\n authenticateWithBearerToken(input: $input) { id name status }\n }\n`;\n\nexport const INITIATE_OAUTH = `\n mutation InitiateOAuth($input: InitiateOAuthInput!) {\n initiateOAuth(input: $input) { redirectUrl state }\n }\n`;\n\nexport const COMPLETE_OAUTH = `\n mutation CompleteOAuth($input: CompleteOAuthInput!) {\n completeOAuth(input: $input) { id name status }\n }\n`;\n\nexport const GET_PROVIDER_BY_KEY = `\n query GetProviderByKey($key: String!) {\n getProviderByKey(key: $key) { id key name authType category connectionCount isEnabled }\n }\n`;\n\nexport const GET_PROVIDER_CATALOG = `\n query GetProviderCatalog($pagination: IntegrationsPaginationInput) {\n getProviderCatalog(pagination: $pagination) {\n items { id key name category authType isEnabled }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTIONS_BY_PROVIDER = `\n query GetConnectionsByProvider($providerId: ID!, $pagination: IntegrationsPaginationInput) {\n getConnectionsByProvider(providerId: $providerId, pagination: $pagination) {\n items { id name providerId status grantedScopes }\n total hasMore\n }\n }\n`;\n\nexport const ENABLE_PROVIDER = `\n mutation EnableProvider($id: ID!) {\n enableProvider(id: $id) { id key name isEnabled }\n }\n`;\n\nexport const DISABLE_PROVIDER = `\n mutation DisableProvider($id: ID!) {\n disableProvider(id: $id) { id key name isEnabled }\n }\n`;\n\nexport const TAG_CONNECTION = `\n mutation TagConnection($input: TagConnectionInput!) {\n tagConnection(input: $input) { id entityId tagId source }\n }\n`;\n\nexport const UNTAG_CONNECTION = `\n mutation UntagConnection($input: UntagConnectionInput!) {\n untagConnection(input: $input)\n }\n`;\n\nexport const REPLACE_CONNECTION_TAGS = `\n mutation ReplaceConnectionTags($input: ReplaceConnectionTagsInput!) {\n replaceConnectionTags(input: $input) { id entityId tagId source }\n }\n`;\n\nexport const GET_CONNECTION_TAGS = `\n query GetConnectionTags($input: GetConnectionTagsInput!) {\n getConnectionTags(input: $input) { id entityId tagId source assignedAt }\n }\n`;\n","/**\n * Integrations MCP tools — providers, connections, logs.\n * Surface mirrors cli-sdk/src/modules/integrations/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface ProviderRow {\n id: string;\n key: string;\n name: string;\n category?: string;\n authType?: string;\n isEnabled?: boolean;\n}\n\ninterface ConnectionRow {\n id: string;\n name: string;\n providerId: string;\n status?: string;\n grantedScopes?: string[];\n}\n\ninterface IntegrationLog {\n id: string;\n action: string;\n level: string;\n message: string;\n createdAt: string;\n}\n\nexport function registerIntegrationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Providers ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_list')),\n {\n title: 'List Integration Providers',\n description: 'List integration providers with optional category/enabled filters.',\n inputSchema: {\n category: z.string().optional().describe('Filter by category (will be uppercased)'),\n enabled: z.boolean().optional().describe('Filter by enabled flag'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ category, enabled, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (category !== undefined) filter.category = category.toUpperCase();\n if (enabled !== undefined) filter.isEnabled = enabled;\n const data = await ctx.gql.workspace.request<{\n getProviders: { items: ProviderRow[]; total: number; hasMore: boolean };\n }>(ops.GET_PROVIDERS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getProviders);\n } catch (error) {\n ctx.logger.error('integrations_providers_list failed', { error: String(error) });\n return errorResult(\n `Failed to list providers: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_get')),\n {\n title: 'Get Integration Provider',\n description: 'Get an integration provider by ID.',\n inputSchema: { id: z.string().describe('Provider ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getProvider: ProviderRow | null }>(\n ops.GET_PROVIDER,\n { id },\n );\n if (!data.getProvider) return errorResult(`Provider ${id} not found`);\n return jsonResult(data.getProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_get failed', { error: String(error) });\n return errorResult(\n `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connections ─────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_list')),\n {\n title: 'List Connections',\n description: 'List provider connections (OAuth + credential).',\n inputSchema: {\n provider: z.string().optional().describe('Filter by provider ID'),\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ provider, status, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (provider !== undefined) filter.providerId = provider;\n if (status !== undefined) filter.status = status.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getConnections: { items: ConnectionRow[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTIONS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getConnections);\n } catch (error) {\n ctx.logger.error('integrations_connections_list failed', { error: String(error) });\n return errorResult(\n `Failed to list connections: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_get')),\n {\n title: 'Get Connection',\n description: 'Get a connection by ID.',\n inputSchema: { id: z.string().describe('Connection ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getConnection: ConnectionRow | null }>(\n ops.GET_CONNECTION,\n { id },\n );\n if (!data.getConnection) return errorResult(`Connection ${id} not found`);\n return jsonResult(data.getConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_get failed', { error: String(error) });\n return errorResult(\n `Failed to get connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_add')),\n {\n title: 'Create Connection',\n description: 'Create a connection (provider id required; credentials stored in vault).',\n inputSchema: {\n name: z.string().describe('Connection name'),\n provider: z.string().describe('Provider ID'),\n scopes: z.array(z.string()).optional().describe('Granted scopes'),\n },\n },\n async ({ name, provider, scopes }) => {\n try {\n const input: Record<string, unknown> = { name, providerId: provider };\n if (scopes !== undefined) input.grantedScopes = scopes;\n const data = await ctx.gql.workspace.request<{ createConnection: ConnectionRow }>(\n ops.CREATE_CONNECTION,\n { input },\n );\n return jsonResult(data.createConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_add failed', { error: String(error) });\n return errorResult(\n `Failed to create connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_delete')),\n {\n title: 'Delete Connection',\n description: 'Delete a connection. Use keepSecret=true to retain the vault secret.',\n inputSchema: {\n id: z.string().describe('Connection ID'),\n keepSecret: z.boolean().optional().describe('Keep vault secret (default false)'),\n },\n },\n async ({ id, keepSecret }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteConnection: boolean }>(\n ops.DELETE_CONNECTION,\n { id, deleteVaultSecret: !keepSecret },\n );\n return jsonResult({ deleted: data.deleteConnection, connectionId: id });\n } catch (error) {\n ctx.logger.error('integrations_connections_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connections (extras) ────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_update')),\n {\n title: 'Update Connection',\n description: 'Update a connection (name, description, config JSON object).',\n inputSchema: {\n id: z.string().describe('Connection ID'),\n name: z.string().optional(),\n description: z.string().optional(),\n config: z.record(z.string(), z.unknown()).optional(),\n },\n },\n async ({ id, name, description, config }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (config !== undefined) input.config = config;\n if (Object.keys(input).length === 0) {\n return errorResult('Provide at least one of name, description, config');\n }\n const data = await ctx.gql.workspace.request<{ updateConnection: ConnectionRow }>(\n ops.UPDATE_CONNECTION,\n { id, input },\n );\n return jsonResult(data.updateConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_update failed', { error: String(error) });\n return errorResult(\n `Failed to update connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_revoke')),\n {\n title: 'Revoke Connection',\n description: 'Revoke a connection — invalidates tokens and marks as REVOKED.',\n inputSchema: { connectionId: z.string().describe('Connection ID') },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ revokeConnection: ConnectionRow }>(\n ops.REVOKE_CONNECTION,\n { connectionId },\n );\n return jsonResult(data.revokeConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_test')),\n {\n title: 'Test Connection',\n description: 'Health/auth probe for a connection; returns success/message/latencyMs.',\n inputSchema: { connectionId: z.string().describe('Connection ID') },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n testConnection: { success: boolean; message: string; latencyMs?: number };\n }>(ops.TEST_CONNECTION, { connectionId });\n return jsonResult(data.testConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_test failed', { error: String(error) });\n return errorResult(\n `Failed to test connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_link_channel')),\n {\n title: 'Link Connection to Channel',\n description: 'Link an integration connection to a channel for DM/notification routing.',\n inputSchema: {\n channelId: z.string(),\n connectionId: z.string(),\n organizationId: z.string(),\n },\n },\n async ({ channelId, connectionId, organizationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n linkIntegrationToChannel: ConnectionRow;\n }>(ops.LINK_INTEGRATION_TO_CHANNEL, { channelId, connectionId, organizationId });\n return jsonResult(data.linkIntegrationToChannel);\n } catch (error) {\n ctx.logger.error('integrations_connections_link_channel failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to link connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_refresh_token')),\n {\n title: 'Refresh Connection Token',\n description: 'Force a token refresh for an OAuth connection.',\n inputSchema: { connectionId: z.string() },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n refreshConnectionToken: ConnectionRow;\n }>(ops.REFRESH_CONNECTION_TOKEN, { connectionId });\n return jsonResult(data.refreshConnectionToken);\n } catch (error) {\n ctx.logger.error('integrations_connections_refresh_token failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to refresh token: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Auth flows ──────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_api_key')),\n {\n title: 'Authenticate Connection (API Key)',\n description: 'Attach an API key to an existing connection.',\n inputSchema: { connectionId: z.string(), apiKey: z.string() },\n },\n async ({ connectionId, apiKey }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithApiKey: ConnectionRow;\n }>(ops.AUTHENTICATE_API_KEY, { input: { connectionId, apiKey } });\n return jsonResult(data.authenticateWithApiKey);\n } catch (error) {\n ctx.logger.error('integrations_auth_api_key failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_basic')),\n {\n title: 'Authenticate Connection (Basic Auth)',\n description: 'Attach Basic Auth credentials to an existing connection.',\n inputSchema: {\n connectionId: z.string(),\n username: z.string(),\n password: z.string(),\n },\n },\n async ({ connectionId, username, password }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithBasicAuth: ConnectionRow;\n }>(ops.AUTHENTICATE_BASIC, { input: { connectionId, username, password } });\n return jsonResult(data.authenticateWithBasicAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_basic failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_bearer')),\n {\n title: 'Authenticate Connection (Bearer Token)',\n description: 'Attach a Bearer token to an existing connection.',\n inputSchema: { connectionId: z.string(), token: z.string() },\n },\n async ({ connectionId, token }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithBearerToken: ConnectionRow;\n }>(ops.AUTHENTICATE_BEARER, { input: { connectionId, token } });\n return jsonResult(data.authenticateWithBearerToken);\n } catch (error) {\n ctx.logger.error('integrations_auth_bearer failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_oauth_start')),\n {\n title: 'Initiate OAuth Flow',\n description: 'Start an OAuth flow; returns redirectUrl + state for the client to use.',\n inputSchema: {\n connectionId: z.string(),\n redirectUri: z.string(),\n scopes: z.array(z.string()).optional(),\n },\n },\n async ({ connectionId, redirectUri, scopes }) => {\n try {\n const input: Record<string, unknown> = { connectionId, redirectUri };\n if (scopes !== undefined) input.scopes = scopes;\n const data = await ctx.gql.workspace.request<{\n initiateOAuth: { redirectUrl: string; state: string };\n }>(ops.INITIATE_OAUTH, { input });\n return jsonResult(data.initiateOAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_oauth_start failed', { error: String(error) });\n return errorResult(\n `Failed to initiate OAuth: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_oauth_complete')),\n {\n title: 'Complete OAuth Flow',\n description: 'Complete an OAuth flow with code+state returned by the IdP.',\n inputSchema: {\n connectionId: z.string(),\n code: z.string(),\n redirectUri: z.string(),\n state: z.string(),\n },\n },\n async ({ connectionId, code, redirectUri, state }) => {\n try {\n const data = await ctx.gql.workspace.request<{ completeOAuth: ConnectionRow }>(\n ops.COMPLETE_OAUTH,\n { input: { connectionId, code, redirectUri, state } },\n );\n return jsonResult(data.completeOAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_oauth_complete failed', { error: String(error) });\n return errorResult(\n `Failed to complete OAuth: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Providers (extras) ──────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_get_by_key')),\n {\n title: 'Get Provider By Key',\n description: 'Look up an integration provider by its string key (e.g. github, slack).',\n inputSchema: { key: z.string() },\n },\n async ({ key }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getProviderByKey: ProviderRow | null }>(\n ops.GET_PROVIDER_BY_KEY,\n { key },\n );\n if (!data.getProviderByKey) return errorResult(`Provider ${key} not found`);\n return jsonResult(data.getProviderByKey);\n } catch (error) {\n ctx.logger.error('integrations_providers_get_by_key failed', { error: String(error) });\n return errorResult(\n `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_catalog')),\n {\n title: 'Provider Catalog',\n description: 'Browseable catalog of integration providers (paginated).',\n inputSchema: { limit: z.number().optional() },\n },\n async ({ limit }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getProviderCatalog: { items: ProviderRow[]; total: number; hasMore: boolean };\n }>(ops.GET_PROVIDER_CATALOG, { pagination: { limit: limit ?? 100, offset: 0 } });\n return jsonResult(data.getProviderCatalog);\n } catch (error) {\n ctx.logger.error('integrations_providers_catalog failed', { error: String(error) });\n return errorResult(\n `Failed to get catalog: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_connections')),\n {\n title: 'Connections By Provider',\n description: 'List all connections that belong to a given provider.',\n inputSchema: { providerId: z.string(), limit: z.number().optional() },\n },\n async ({ providerId, limit }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getConnectionsByProvider: { items: ConnectionRow[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTIONS_BY_PROVIDER, {\n providerId,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getConnectionsByProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_connections failed', { error: String(error) });\n return errorResult(\n `Failed to list: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_enable')),\n {\n title: 'Enable Provider',\n description: 'Enable an integration provider in this workspace.',\n inputSchema: { id: z.string() },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ enableProvider: ProviderRow }>(\n ops.ENABLE_PROVIDER,\n { id },\n );\n return jsonResult(data.enableProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_enable failed', { error: String(error) });\n return errorResult(\n `Failed to enable: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_disable')),\n {\n title: 'Disable Provider',\n description: 'Disable an integration provider in this workspace.',\n inputSchema: { id: z.string() },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ disableProvider: ProviderRow }>(\n ops.DISABLE_PROVIDER,\n { id },\n );\n return jsonResult(data.disableProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_disable failed', { error: String(error) });\n return errorResult(\n `Failed to disable: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connection tags ─────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_tag_add')),\n {\n title: 'Tag Connection',\n description: 'Add a tag assignment to a connection.',\n inputSchema: {\n entityId: z.string(),\n tagId: z.string(),\n source: z.string().optional(),\n },\n },\n async ({ entityId, tagId, source }) => {\n try {\n const input: Record<string, unknown> = { entityId, tagId };\n if (source !== undefined) input.source = source;\n const data = await ctx.gql.workspace.request<{ tagConnection: unknown }>(\n ops.TAG_CONNECTION,\n { input },\n );\n return jsonResult(data.tagConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_add failed', { error: String(error) });\n return errorResult(\n `Failed to tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_tag_remove')),\n {\n title: 'Untag Connection',\n description: 'Remove a tag assignment from a connection.',\n inputSchema: { entityId: z.string(), tagId: z.string() },\n },\n async ({ entityId, tagId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ untagConnection: boolean }>(\n ops.UNTAG_CONNECTION,\n { input: { entityId, tagId } },\n );\n return jsonResult({ removed: data.untagConnection });\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_remove failed', { error: String(error) });\n return errorResult(\n `Failed to untag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_tag_replace')),\n {\n title: 'Replace Connection Tags',\n description: 'Replace all tag assignments on a connection.',\n inputSchema: { entityId: z.string(), tagIds: z.array(z.string()) },\n },\n async ({ entityId, tagIds }) => {\n try {\n const data = await ctx.gql.workspace.request<{ replaceConnectionTags: unknown }>(\n ops.REPLACE_CONNECTION_TAGS,\n { input: { entityId, tagIds } },\n );\n return jsonResult(data.replaceConnectionTags);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_replace failed', { error: String(error) });\n return errorResult(\n `Failed to replace tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_tag_list')),\n {\n title: 'List Connection Tags',\n description: 'List tag assignments on a connection.',\n inputSchema: { entityId: z.string() },\n },\n async ({ entityId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getConnectionTags: unknown }>(\n ops.GET_CONNECTION_TAGS,\n { input: { entityId } },\n );\n return jsonResult(data.getConnectionTags);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Logs ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_logs')),\n {\n title: 'Integration Audit Logs',\n description: 'List integration audit logs with optional filters.',\n inputSchema: {\n connection: z.string().optional().describe('Filter by connection ID'),\n level: z.string().optional().describe('INFO|WARN|ERROR (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ connection, level, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (connection !== undefined) filter.connectionId = connection;\n if (level !== undefined) filter.level = level.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getIntegrationLogs: { items: IntegrationLog[]; total: number; hasMore: boolean };\n }>(ops.GET_INTEGRATION_LOGS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getIntegrationLogs);\n } catch (error) {\n ctx.logger.error('integrations_logs failed', { error: String(error) });\n return errorResult(\n `Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Integrations module — providers, connections, audit logs.\n * Surface mirrors cli-sdk/src/modules/integrations/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerIntegrationsTools } from './tools.js';\n\nconst integrationsModule: McpModule = {\n id: 'integrations',\n version: '0.0.1',\n displayName: 'Integrations',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerIntegrationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default integrationsModule;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/integrations/operations.ts","../../../src/modules/integrations/tools.ts","../../../src/modules/integrations/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;ACCO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,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AW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,yBAAA,CAA0B,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE5C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,oBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const GET_PROVIDERS = `\n query GetProviders($filter: ProviderFilterInput, $pagination: IntegrationsPaginationInput) {\n getProviders(filter: $filter, pagination: $pagination) {\n items { id key name category authType isEnabled }\n total hasMore\n }\n }\n`;\n\nexport const GET_PROVIDER = `\n query GetProvider($id: ID!) {\n getProvider(id: $id) {\n id key name authType category connectionCount\n }\n }\n`;\n\nexport const GET_CONNECTIONS = `\n query GetConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {\n getConnections(filter: $filter, pagination: $pagination) {\n items { id name providerId status grantedScopes }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTION = `\n query GetConnection($id: ID!) {\n getConnection(id: $id) {\n id name providerId status externalAccountEmail credentialSource\n }\n }\n`;\n\nexport const CREATE_CONNECTION = `\n mutation CreateConnection($input: CreateConnectionInput!) {\n createConnection(input: $input) {\n id name status providerId\n }\n }\n`;\n\nexport const DELETE_CONNECTION = `\n mutation DeleteConnection($id: ID!, $deleteVaultSecret: Boolean) {\n deleteConnection(id: $id, deleteVaultSecret: $deleteVaultSecret)\n }\n`;\n\nexport const GET_INTEGRATION_LOGS = `\n query GetIntegrationLogs($filter: LogFilterInput, $pagination: IntegrationsPaginationInput) {\n getIntegrationLogs(filter: $filter, pagination: $pagination) {\n items { id action level message createdAt }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTION_LOGS = `\n query GetConnectionLogs($connectionId: ID!, $pagination: IntegrationsPaginationInput) {\n getConnectionLogs(connectionId: $connectionId, pagination: $pagination) {\n items { id action level message createdAt }\n total hasMore\n }\n }\n`;\n\nexport const UPDATE_CONNECTION = `\n mutation UpdateConnection($id: ID!, $input: UpdateConnectionInput!) {\n updateConnection(id: $id, input: $input) { id name status }\n }\n`;\n\nexport const REVOKE_CONNECTION = `\n mutation RevokeConnection($connectionId: ID!) {\n revokeConnection(connectionId: $connectionId) { id name status }\n }\n`;\n\nexport const TEST_CONNECTION = `\n mutation TestConnection($connectionId: ID!) {\n testConnection(connectionId: $connectionId) { success message latencyMs }\n }\n`;\n\nexport const LINK_INTEGRATION_TO_CHANNEL = `\n mutation LinkIntegrationToChannel($channelId: String!, $connectionId: ID!, $organizationId: String!) {\n linkIntegrationToChannel(channelId: $channelId, connectionId: $connectionId, organizationId: $organizationId) {\n id name status channelId organizationId\n }\n }\n`;\n\nexport const REFRESH_CONNECTION_TOKEN = `\n mutation RefreshConnectionToken($connectionId: ID!) {\n refreshConnectionToken(connectionId: $connectionId) { id status }\n }\n`;\n\nexport const AUTHENTICATE_API_KEY = `\n mutation AuthenticateWithApiKey($input: ApiKeyAuthInput!) {\n authenticateWithApiKey(input: $input) { id name status }\n }\n`;\n\nexport const AUTHENTICATE_BASIC = `\n mutation AuthenticateWithBasicAuth($input: BasicAuthInput!) {\n authenticateWithBasicAuth(input: $input) { id name status }\n }\n`;\n\nexport const AUTHENTICATE_BEARER = `\n mutation AuthenticateWithBearerToken($input: BearerTokenAuthInput!) {\n authenticateWithBearerToken(input: $input) { id name status }\n }\n`;\n\nexport const INITIATE_OAUTH = `\n mutation InitiateOAuth($input: InitiateOAuthInput!) {\n initiateOAuth(input: $input) { redirectUrl state }\n }\n`;\n\nexport const COMPLETE_OAUTH = `\n mutation CompleteOAuth($input: CompleteOAuthInput!) {\n completeOAuth(input: $input) { id name status }\n }\n`;\n\nexport const GET_PROVIDER_BY_KEY = `\n query GetProviderByKey($key: String!) {\n getProviderByKey(key: $key) { id key name authType category connectionCount isEnabled }\n }\n`;\n\nexport const GET_PROVIDER_CATALOG = `\n query GetProviderCatalog($pagination: IntegrationsPaginationInput) {\n getProviderCatalog(pagination: $pagination) {\n items { id key name category authType isEnabled }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTIONS_BY_PROVIDER = `\n query GetConnectionsByProvider($providerId: ID!, $pagination: IntegrationsPaginationInput) {\n getConnectionsByProvider(providerId: $providerId, pagination: $pagination) {\n items { id name providerId status grantedScopes }\n total hasMore\n }\n }\n`;\n\nexport const ENABLE_PROVIDER = `\n mutation EnableProvider($id: ID!) {\n enableProvider(id: $id) { id key name isEnabled }\n }\n`;\n\nexport const DISABLE_PROVIDER = `\n mutation DisableProvider($id: ID!) {\n disableProvider(id: $id) { id key name isEnabled }\n }\n`;\n\nexport const TAG_CONNECTION = `\n mutation TagConnection($input: TagConnectionInput!) {\n tagConnection(input: $input) { id entityId tagId source }\n }\n`;\n\nexport const UNTAG_CONNECTION = `\n mutation UntagConnection($input: UntagConnectionInput!) {\n untagConnection(input: $input)\n }\n`;\n\nexport const REPLACE_CONNECTION_TAGS = `\n mutation ReplaceConnectionTags($input: ReplaceConnectionTagsInput!) {\n replaceConnectionTags(input: $input) { id entityId tagId source }\n }\n`;\n\nexport const GET_CONNECTION_TAGS = `\n query GetConnectionTags($input: GetConnectionTagsInput!) {\n getConnectionTags(input: $input) { id entityId tagId source assignedAt }\n }\n`;\n","/**\n * Integrations MCP tools — providers, connections, logs.\n * Surface mirrors cli-sdk/src/modules/integrations/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface ProviderRow {\n id: string;\n key: string;\n name: string;\n category?: string;\n authType?: string;\n isEnabled?: boolean;\n}\n\ninterface ConnectionRow {\n id: string;\n name: string;\n providerId: string;\n status?: string;\n grantedScopes?: string[];\n}\n\ninterface IntegrationLog {\n id: string;\n action: string;\n level: string;\n message: string;\n createdAt: string;\n}\n\nexport function registerIntegrationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Providers ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_list')),\n {\n title: 'List Integration Providers',\n description: 'List integration providers with optional category/enabled filters.',\n inputSchema: {\n category: z.string().optional().describe('Filter by category (will be uppercased)'),\n enabled: z.boolean().optional().describe('Filter by enabled flag'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ category, enabled, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (category !== undefined) filter.category = category.toUpperCase();\n if (enabled !== undefined) filter.isEnabled = enabled;\n const data = await ctx.gql.workspace.request<{\n getProviders: { items: ProviderRow[]; total: number; hasMore: boolean };\n }>(ops.GET_PROVIDERS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getProviders);\n } catch (error) {\n ctx.logger.error('integrations_providers_list failed', { error: String(error) });\n return errorResult(\n `Failed to list providers: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_get')),\n {\n title: 'Get Integration Provider',\n description: 'Get an integration provider by ID.',\n inputSchema: { id: z.string().describe('Provider ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getProvider: ProviderRow | null }>(\n ops.GET_PROVIDER,\n { id },\n );\n if (!data.getProvider) return errorResult(`Provider ${id} not found`);\n return jsonResult(data.getProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_get failed', { error: String(error) });\n return errorResult(\n `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connections ─────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_list')),\n {\n title: 'List Connections',\n description: 'List provider connections (OAuth + credential).',\n inputSchema: {\n provider: z.string().optional().describe('Filter by provider ID'),\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ provider, status, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (provider !== undefined) filter.providerId = provider;\n if (status !== undefined) filter.status = status.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getConnections: { items: ConnectionRow[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTIONS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getConnections);\n } catch (error) {\n ctx.logger.error('integrations_connections_list failed', { error: String(error) });\n return errorResult(\n `Failed to list connections: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_get')),\n {\n title: 'Get Connection',\n description: 'Get a connection by ID.',\n inputSchema: { id: z.string().describe('Connection ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getConnection: ConnectionRow | null }>(\n ops.GET_CONNECTION,\n { id },\n );\n if (!data.getConnection) return errorResult(`Connection ${id} not found`);\n return jsonResult(data.getConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_get failed', { error: String(error) });\n return errorResult(\n `Failed to get connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_add')),\n {\n title: 'Create Connection',\n description: 'Create a connection (provider id required; credentials stored in vault).',\n inputSchema: {\n name: z.string().describe('Connection name'),\n provider: z.string().describe('Provider ID'),\n scopes: z.array(z.string()).optional().describe('Granted scopes'),\n },\n },\n async ({ name, provider, scopes }) => {\n try {\n const input: Record<string, unknown> = { name, providerId: provider };\n if (scopes !== undefined) input.grantedScopes = scopes;\n const data = await ctx.gql.workspace.request<{ createConnection: ConnectionRow }>(\n ops.CREATE_CONNECTION,\n { input },\n );\n return jsonResult(data.createConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_add failed', { error: String(error) });\n return errorResult(\n `Failed to create connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_delete')),\n {\n title: 'Delete Connection',\n description: 'Delete a connection. Use keepSecret=true to retain the vault secret.',\n inputSchema: {\n id: z.string().describe('Connection ID'),\n keepSecret: z.boolean().optional().describe('Keep vault secret (default false)'),\n },\n },\n async ({ id, keepSecret }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteConnection: boolean }>(\n ops.DELETE_CONNECTION,\n { id, deleteVaultSecret: !keepSecret },\n );\n return jsonResult({ deleted: data.deleteConnection, connectionId: id });\n } catch (error) {\n ctx.logger.error('integrations_connections_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connections (extras) ────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_update')),\n {\n title: 'Update Connection',\n description: 'Update a connection (name, description, config JSON object).',\n inputSchema: {\n id: z.string().describe('Connection ID'),\n name: z.string().optional(),\n description: z.string().optional(),\n config: z.record(z.string(), z.unknown()).optional(),\n },\n },\n async ({ id, name, description, config }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (config !== undefined) input.config = config;\n if (Object.keys(input).length === 0) {\n return errorResult('Provide at least one of name, description, config');\n }\n const data = await ctx.gql.workspace.request<{ updateConnection: ConnectionRow }>(\n ops.UPDATE_CONNECTION,\n { id, input },\n );\n return jsonResult(data.updateConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_update failed', { error: String(error) });\n return errorResult(\n `Failed to update connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_revoke')),\n {\n title: 'Revoke Connection',\n description: 'Revoke a connection — invalidates tokens and marks as REVOKED.',\n inputSchema: { connectionId: z.string().describe('Connection ID') },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ revokeConnection: ConnectionRow }>(\n ops.REVOKE_CONNECTION,\n { connectionId },\n );\n return jsonResult(data.revokeConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_test')),\n {\n title: 'Test Connection',\n description: 'Health/auth probe for a connection; returns success/message/latencyMs.',\n inputSchema: { connectionId: z.string().describe('Connection ID') },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n testConnection: { success: boolean; message: string; latencyMs?: number };\n }>(ops.TEST_CONNECTION, { connectionId });\n return jsonResult(data.testConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_test failed', { error: String(error) });\n return errorResult(\n `Failed to test connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_link_to_channel')),\n {\n title: 'Link Connection to Channel',\n description: 'Link an integration connection to a channel for DM/notification routing.',\n inputSchema: {\n channelId: z.string(),\n connectionId: z.string(),\n organizationId: z.string(),\n },\n },\n async ({ channelId, connectionId, organizationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n linkIntegrationToChannel: ConnectionRow;\n }>(ops.LINK_INTEGRATION_TO_CHANNEL, { channelId, connectionId, organizationId });\n return jsonResult(data.linkIntegrationToChannel);\n } catch (error) {\n ctx.logger.error('integrations_connections_link_channel failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to link connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_refresh_token')),\n {\n title: 'Refresh Connection Token',\n description: 'Force a token refresh for an OAuth connection.',\n inputSchema: { connectionId: z.string() },\n },\n async ({ connectionId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n refreshConnectionToken: ConnectionRow;\n }>(ops.REFRESH_CONNECTION_TOKEN, { connectionId });\n return jsonResult(data.refreshConnectionToken);\n } catch (error) {\n ctx.logger.error('integrations_connections_refresh_token failed', {\n error: String(error),\n });\n return errorResult(\n `Failed to refresh token: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Auth flows ──────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_api_key')),\n {\n title: 'Authenticate Connection (API Key)',\n description: 'Attach an API key to an existing connection.',\n inputSchema: { connectionId: z.string(), apiKey: z.string() },\n },\n async ({ connectionId, apiKey }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithApiKey: ConnectionRow;\n }>(ops.AUTHENTICATE_API_KEY, { input: { connectionId, apiKey } });\n return jsonResult(data.authenticateWithApiKey);\n } catch (error) {\n ctx.logger.error('integrations_auth_api_key failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_basic')),\n {\n title: 'Authenticate Connection (Basic Auth)',\n description: 'Attach Basic Auth credentials to an existing connection.',\n inputSchema: {\n connectionId: z.string(),\n username: z.string(),\n password: z.string(),\n },\n },\n async ({ connectionId, username, password }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithBasicAuth: ConnectionRow;\n }>(ops.AUTHENTICATE_BASIC, { input: { connectionId, username, password } });\n return jsonResult(data.authenticateWithBasicAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_basic failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_bearer')),\n {\n title: 'Authenticate Connection (Bearer Token)',\n description: 'Attach a Bearer token to an existing connection.',\n inputSchema: { connectionId: z.string(), token: z.string() },\n },\n async ({ connectionId, token }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n authenticateWithBearerToken: ConnectionRow;\n }>(ops.AUTHENTICATE_BEARER, { input: { connectionId, token } });\n return jsonResult(data.authenticateWithBearerToken);\n } catch (error) {\n ctx.logger.error('integrations_auth_bearer failed', { error: String(error) });\n return errorResult(\n `Failed to authenticate: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_oauth_initiate')),\n {\n title: 'Initiate OAuth Flow',\n description: 'Start an OAuth flow; returns redirectUrl + state for the client to use.',\n inputSchema: {\n connectionId: z.string(),\n redirectUri: z.string(),\n scopes: z.array(z.string()).optional(),\n },\n },\n async ({ connectionId, redirectUri, scopes }) => {\n try {\n const input: Record<string, unknown> = { connectionId, redirectUri };\n if (scopes !== undefined) input.scopes = scopes;\n const data = await ctx.gql.workspace.request<{\n initiateOAuth: { redirectUrl: string; state: string };\n }>(ops.INITIATE_OAUTH, { input });\n return jsonResult(data.initiateOAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_oauth_start failed', { error: String(error) });\n return errorResult(\n `Failed to initiate OAuth: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_auth_oauth_complete')),\n {\n title: 'Complete OAuth Flow',\n description: 'Complete an OAuth flow with code+state returned by the IdP.',\n inputSchema: {\n connectionId: z.string(),\n code: z.string(),\n redirectUri: z.string(),\n state: z.string(),\n },\n },\n async ({ connectionId, code, redirectUri, state }) => {\n try {\n const data = await ctx.gql.workspace.request<{ completeOAuth: ConnectionRow }>(\n ops.COMPLETE_OAUTH,\n { input: { connectionId, code, redirectUri, state } },\n );\n return jsonResult(data.completeOAuth);\n } catch (error) {\n ctx.logger.error('integrations_auth_oauth_complete failed', { error: String(error) });\n return errorResult(\n `Failed to complete OAuth: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Providers (extras) ──────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_get_by_key')),\n {\n title: 'Get Provider By Key',\n description: 'Look up an integration provider by its string key (e.g. github, slack).',\n inputSchema: { key: z.string() },\n },\n async ({ key }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getProviderByKey: ProviderRow | null }>(\n ops.GET_PROVIDER_BY_KEY,\n { key },\n );\n if (!data.getProviderByKey) return errorResult(`Provider ${key} not found`);\n return jsonResult(data.getProviderByKey);\n } catch (error) {\n ctx.logger.error('integrations_providers_get_by_key failed', { error: String(error) });\n return errorResult(\n `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_catalog')),\n {\n title: 'Provider Catalog',\n description: 'Browseable catalog of integration providers (paginated).',\n inputSchema: { limit: z.number().optional() },\n },\n async ({ limit }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getProviderCatalog: { items: ProviderRow[]; total: number; hasMore: boolean };\n }>(ops.GET_PROVIDER_CATALOG, { pagination: { limit: limit ?? 100, offset: 0 } });\n return jsonResult(data.getProviderCatalog);\n } catch (error) {\n ctx.logger.error('integrations_providers_catalog failed', { error: String(error) });\n return errorResult(\n `Failed to get catalog: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_by_provider')),\n {\n title: 'Connections By Provider',\n description: 'List all connections that belong to a given provider.',\n inputSchema: { providerId: z.string(), limit: z.number().optional() },\n },\n async ({ providerId, limit }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getConnectionsByProvider: { items: ConnectionRow[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTIONS_BY_PROVIDER, {\n providerId,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getConnectionsByProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_connections failed', { error: String(error) });\n return errorResult(\n `Failed to list: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_enable')),\n {\n title: 'Enable Provider',\n description: 'Enable an integration provider in this workspace.',\n inputSchema: { id: z.string() },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ enableProvider: ProviderRow }>(\n ops.ENABLE_PROVIDER,\n { id },\n );\n return jsonResult(data.enableProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_enable failed', { error: String(error) });\n return errorResult(\n `Failed to enable: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_disable')),\n {\n title: 'Disable Provider',\n description: 'Disable an integration provider in this workspace.',\n inputSchema: { id: z.string() },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ disableProvider: ProviderRow }>(\n ops.DISABLE_PROVIDER,\n { id },\n );\n return jsonResult(data.disableProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_disable failed', { error: String(error) });\n return errorResult(\n `Failed to disable: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connection tags ─────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_tags_add')),\n {\n title: 'Tag Connection',\n description: 'Add a tag assignment to a connection.',\n inputSchema: {\n entityId: z.string(),\n tagId: z.string(),\n source: z.string().optional(),\n },\n },\n async ({ entityId, tagId, source }) => {\n try {\n const input: Record<string, unknown> = { entityId, tagId };\n if (source !== undefined) input.source = source;\n const data = await ctx.gql.workspace.request<{ tagConnection: unknown }>(\n ops.TAG_CONNECTION,\n { input },\n );\n return jsonResult(data.tagConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_add failed', { error: String(error) });\n return errorResult(\n `Failed to tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_tags_remove')),\n {\n title: 'Untag Connection',\n description: 'Remove a tag assignment from a connection.',\n inputSchema: { entityId: z.string(), tagId: z.string() },\n },\n async ({ entityId, tagId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ untagConnection: boolean }>(\n ops.UNTAG_CONNECTION,\n { input: { entityId, tagId } },\n );\n return jsonResult({ removed: data.untagConnection });\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_remove failed', { error: String(error) });\n return errorResult(\n `Failed to untag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_tags_replace')),\n {\n title: 'Replace Connection Tags',\n description: 'Replace all tag assignments on a connection.',\n inputSchema: { entityId: z.string(), tagIds: z.array(z.string()) },\n },\n async ({ entityId, tagIds }) => {\n try {\n const data = await ctx.gql.workspace.request<{ replaceConnectionTags: unknown }>(\n ops.REPLACE_CONNECTION_TAGS,\n { input: { entityId, tagIds } },\n );\n return jsonResult(data.replaceConnectionTags);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_replace failed', { error: String(error) });\n return errorResult(\n `Failed to replace tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_tags_list')),\n {\n title: 'List Connection Tags',\n description: 'List tag assignments on a connection.',\n inputSchema: { entityId: z.string() },\n },\n async ({ entityId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getConnectionTags: unknown }>(\n ops.GET_CONNECTION_TAGS,\n { input: { entityId } },\n );\n return jsonResult(data.getConnectionTags);\n } catch (error) {\n ctx.logger.error('integrations_connections_tag_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Logs ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_integration_logs')),\n {\n title: 'Integration Audit Logs',\n description: 'List integration audit logs with optional filters.',\n inputSchema: {\n connection: z.string().optional().describe('Filter by connection ID'),\n level: z.string().optional().describe('INFO|WARN|ERROR (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ connection, level, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (connection !== undefined) filter.connectionId = connection;\n if (level !== undefined) filter.level = level.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getIntegrationLogs: { items: IntegrationLog[]; total: number; hasMore: boolean };\n }>(ops.GET_INTEGRATION_LOGS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getIntegrationLogs);\n } catch (error) {\n ctx.logger.error('integrations_integration_logs failed', { error: String(error) });\n return errorResult(\n `Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_logs')),\n {\n title: 'Connection Audit Logs',\n description: 'List audit logs for a specific integration connection.',\n inputSchema: {\n connection: z.string().describe('Connection ID (required)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Offset (default 0)'),\n },\n },\n async ({ connection, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getConnectionLogs: { items: IntegrationLog[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTION_LOGS, {\n connectionId: connection,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.getConnectionLogs);\n } catch (error) {\n ctx.logger.error('integrations_logs failed', { error: String(error) });\n return errorResult(\n `Failed to get connection logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Integrations module — providers, connections, audit logs.\n * Surface mirrors cli-sdk/src/modules/integrations/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerIntegrationsTools } from './tools.js';\n\nconst integrationsModule: McpModule = {\n id: 'integrations',\n version: '0.0.1',\n displayName: 'Integrations',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerIntegrationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default integrationsModule;\n"]}
|
|
@@ -52,6 +52,14 @@ var GET_INTEGRATION_LOGS = `
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
|
+
var GET_CONNECTION_LOGS = `
|
|
56
|
+
query GetConnectionLogs($connectionId: ID!, $pagination: IntegrationsPaginationInput) {
|
|
57
|
+
getConnectionLogs(connectionId: $connectionId, pagination: $pagination) {
|
|
58
|
+
items { id action level message createdAt }
|
|
59
|
+
total hasMore
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
55
63
|
var UPDATE_CONNECTION = `
|
|
56
64
|
mutation UpdateConnection($id: ID!, $input: UpdateConnectionInput!) {
|
|
57
65
|
updateConnection(id: $id, input: $input) { id name status }
|
|
@@ -391,7 +399,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
391
399
|
}
|
|
392
400
|
);
|
|
393
401
|
server.registerTool(
|
|
394
|
-
track(mcpToolName(ctx.productName, "
|
|
402
|
+
track(mcpToolName(ctx.productName, "integrations_connections_link_to_channel")),
|
|
395
403
|
{
|
|
396
404
|
title: "Link Connection to Channel",
|
|
397
405
|
description: "Link an integration connection to a channel for DM/notification routing.",
|
|
@@ -498,7 +506,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
498
506
|
}
|
|
499
507
|
);
|
|
500
508
|
server.registerTool(
|
|
501
|
-
track(mcpToolName(ctx.productName, "
|
|
509
|
+
track(mcpToolName(ctx.productName, "integrations_auth_oauth_initiate")),
|
|
502
510
|
{
|
|
503
511
|
title: "Initiate OAuth Flow",
|
|
504
512
|
description: "Start an OAuth flow; returns redirectUrl + state for the client to use.",
|
|
@@ -592,7 +600,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
592
600
|
}
|
|
593
601
|
);
|
|
594
602
|
server.registerTool(
|
|
595
|
-
track(mcpToolName(ctx.productName, "
|
|
603
|
+
track(mcpToolName(ctx.productName, "integrations_providers_by_provider")),
|
|
596
604
|
{
|
|
597
605
|
title: "Connections By Provider",
|
|
598
606
|
description: "List all connections that belong to a given provider.",
|
|
@@ -658,7 +666,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
658
666
|
}
|
|
659
667
|
);
|
|
660
668
|
server.registerTool(
|
|
661
|
-
track(mcpToolName(ctx.productName, "
|
|
669
|
+
track(mcpToolName(ctx.productName, "integrations_tags_add")),
|
|
662
670
|
{
|
|
663
671
|
title: "Tag Connection",
|
|
664
672
|
description: "Add a tag assignment to a connection.",
|
|
@@ -686,7 +694,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
686
694
|
}
|
|
687
695
|
);
|
|
688
696
|
server.registerTool(
|
|
689
|
-
track(mcpToolName(ctx.productName, "
|
|
697
|
+
track(mcpToolName(ctx.productName, "integrations_tags_remove")),
|
|
690
698
|
{
|
|
691
699
|
title: "Untag Connection",
|
|
692
700
|
description: "Remove a tag assignment from a connection.",
|
|
@@ -708,7 +716,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
708
716
|
}
|
|
709
717
|
);
|
|
710
718
|
server.registerTool(
|
|
711
|
-
track(mcpToolName(ctx.productName, "
|
|
719
|
+
track(mcpToolName(ctx.productName, "integrations_tags_replace")),
|
|
712
720
|
{
|
|
713
721
|
title: "Replace Connection Tags",
|
|
714
722
|
description: "Replace all tag assignments on a connection.",
|
|
@@ -730,7 +738,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
730
738
|
}
|
|
731
739
|
);
|
|
732
740
|
server.registerTool(
|
|
733
|
-
track(mcpToolName(ctx.productName, "
|
|
741
|
+
track(mcpToolName(ctx.productName, "integrations_tags_list")),
|
|
734
742
|
{
|
|
735
743
|
title: "List Connection Tags",
|
|
736
744
|
description: "List tag assignments on a connection.",
|
|
@@ -752,7 +760,7 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
752
760
|
}
|
|
753
761
|
);
|
|
754
762
|
server.registerTool(
|
|
755
|
-
track(mcpToolName(ctx.productName, "
|
|
763
|
+
track(mcpToolName(ctx.productName, "integrations_integration_logs")),
|
|
756
764
|
{
|
|
757
765
|
title: "Integration Audit Logs",
|
|
758
766
|
description: "List integration audit logs with optional filters.",
|
|
@@ -773,13 +781,39 @@ function registerIntegrationsTools(server, ctx, track) {
|
|
|
773
781
|
});
|
|
774
782
|
return jsonResult(data.getIntegrationLogs);
|
|
775
783
|
} catch (error) {
|
|
776
|
-
ctx.logger.error("
|
|
784
|
+
ctx.logger.error("integrations_integration_logs failed", { error: String(error) });
|
|
777
785
|
return errorResult(
|
|
778
786
|
`Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`
|
|
779
787
|
);
|
|
780
788
|
}
|
|
781
789
|
}
|
|
782
790
|
);
|
|
791
|
+
server.registerTool(
|
|
792
|
+
track(mcpToolName(ctx.productName, "integrations_logs")),
|
|
793
|
+
{
|
|
794
|
+
title: "Connection Audit Logs",
|
|
795
|
+
description: "List audit logs for a specific integration connection.",
|
|
796
|
+
inputSchema: {
|
|
797
|
+
connection: z.string().describe("Connection ID (required)"),
|
|
798
|
+
limit: z.number().optional().describe("Page size (default 100)"),
|
|
799
|
+
offset: z.number().optional().describe("Offset (default 0)")
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
async ({ connection, limit, offset }) => {
|
|
803
|
+
try {
|
|
804
|
+
const data = await ctx.gql.workspace.request(GET_CONNECTION_LOGS, {
|
|
805
|
+
connectionId: connection,
|
|
806
|
+
pagination: { limit: limit ?? 100, offset: offset ?? 0 }
|
|
807
|
+
});
|
|
808
|
+
return jsonResult(data.getConnectionLogs);
|
|
809
|
+
} catch (error) {
|
|
810
|
+
ctx.logger.error("integrations_logs failed", { error: String(error) });
|
|
811
|
+
return errorResult(
|
|
812
|
+
`Failed to get connection logs: ${error instanceof Error ? error.message : String(error)}`
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
);
|
|
783
817
|
}
|
|
784
818
|
|
|
785
819
|
// src/modules/integrations/index.ts
|