MCPcopy
hub / github.com/RedPlanetHQ/core / runRemoveIntegration

Function runRemoveIntegration

packages/cli/src/commands/integrations/remove.tsx:25–127  ·  view source on GitHub ↗
(integrationIdOrSlug?: string)

Source from the content-addressed store, hash-verified

23}
24
25async function runRemoveIntegration(integrationIdOrSlug?: string): Promise<{ success: boolean; error?: string }> {
26 p.intro(chalk.bgRed(chalk.white(' Remove Integration ')));
27
28 const config = getConfig();
29
30 if (!config.auth?.apiKey || !config.auth?.url) {
31 p.log.error('Not authenticated. Please run "corebrain login" first.');
32 return { success: false, error: 'Not authenticated' };
33 }
34
35 // Fetch integrations to show selection if no ID provided
36 let integrationId = integrationIdOrSlug;
37
38 if (!integrationId) {
39 const spinner = p.spinner();
40 spinner.start('Fetching integrations...');
41
42 try {
43 const response = await fetch(`${config.auth.url}/api/v1/integration_definitions`, {
44 method: 'GET',
45 headers: {
46 'Content-Type': 'application/json',
47 Authorization: `Bearer ${config.auth.apiKey}`,
48 },
49 });
50
51 if (!response.ok) {
52 throw new Error('Failed to fetch integrations');
53 }
54
55 const result = (await response.json()) as { definitions?: IntegrationDefinition[] };
56 const definitions: IntegrationDefinition[] = (result.definitions || []).filter(
57 (d: IntegrationDefinition) => d.workspaceId, // Only show workspace integrations (can't delete global)
58 );
59
60 spinner.stop('');
61
62 if (definitions.length === 0) {
63 p.log.info('No workspace integrations to remove.');
64 return { success: true };
65 }
66
67 const selected = await p.select({
68 message: 'Select integration to remove',
69 options: definitions.map((d) => ({
70 value: d.id,
71 label: `${d.name} (${d.slug})`,
72 hint: d.description,
73 })),
74 });
75
76 if (p.isCancel(selected)) {
77 p.cancel('Cancelled');
78 return { success: false, error: 'Cancelled' };
79 }
80
81 integrationId = selected as string;
82 } catch (error) {

Callers 1

IntegrationsRemoveFunction · 0.85

Calls 7

getConfigFunction · 0.90
filterMethod · 0.80
stopMethod · 0.80
infoMethod · 0.80
errorMethod · 0.45
startMethod · 0.45
confirmMethod · 0.45

Tested by

no test coverage detected