Skip to content

Commit bf5d12c

Browse files
authored
fix(app,tui): hide MCP integrations from the connect menu (#60675)
1 parent 6700dd8 commit bf5d12c

6 files changed

Lines changed: 112 additions & 55 deletions

File tree

‎packages/app/e2e/regression/settings.spec.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,13 @@ test.describe("pages open before slow data", () => {
885885
{ name: "stripe", integrationID: "stripe-oauth", status: { status: "needs_auth", error: "Sign in required" } },
886886
],
887887
integrations: [
888-
{ id: "stripe-oauth", name: "Stripe", methods: [{ id: "oauth", type: "oauth" }], connections: [] },
888+
{
889+
id: "stripe-oauth",
890+
name: "Stripe",
891+
methods: [{ id: "oauth", type: "oauth" }],
892+
connections: [],
893+
metadata: { source: "mcp" },
894+
},
889895
],
890896
onIntegrationOAuth: (input) => {
891897
signIns.push(input.integrationID)
@@ -1369,6 +1375,13 @@ test("providers: the connect dialog lists connected providers and manages their
13691375
connections: accounts.toSorted((a, b) => Number(b.id === state.active) - Number(a.id === state.active)),
13701376
},
13711377
{ id: "anthropic", name: "Anthropic", methods: [{ type: "key", label: "API key" }], connections: [] },
1378+
{
1379+
id: "linear",
1380+
name: "Linear",
1381+
methods: [{ id: "oauth", type: "oauth", label: "Sign in" }],
1382+
connections: [],
1383+
metadata: { source: "mcp" },
1384+
},
13721385
],
13731386
onCredentialActivate: (credentialID) => {
13741387
activated.push(credentialID)
@@ -1389,6 +1402,9 @@ test("providers: the connect dialog lists connected providers and manages their
13891402
await expect(
13901403
dialog.locator('[data-provider-id="anthropic"]').locator('[data-slot="provider-connected"]'),
13911404
).toHaveCount(0)
1405+
// MCP servers connect from the MCPs dialog and settings, not here.
1406+
await expect(dialog.locator('[data-provider-id="linear"]')).toHaveCount(0)
1407+
await expect(dialog.getByText("MCP", { exact: true })).toHaveCount(0)
13921408
const container = page.locator('[data-slot="dialog-container"]')
13931409
await expect.poll(async () => (await container.boundingBox())?.height).toBe(512)
13941410
const picker = await container.boundingBox()

‎packages/app/src/providers/connect/dialog.tsx‎

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@ const POPULAR = ["opencode", "opencode-go", "openai", "github-copilot", "anthrop
278278
function ProviderPicker(props: { directory?: string; onSelect: (provider: string) => void; onPrepare?: () => void }) {
279279
const integrations = useIntegrations(() => props.directory)
280280
const language = useLanguage()
281-
const data = useData()
282-
const location = () => (props.directory ? { directory: props.directory } : undefined)
283-
const mcpServers = () => data.location.mcp.server.list(location()) ?? []
284-
285-
createEffect(() => void data.location.mcp.server.sync(location()).catch(() => undefined))
286281

287282
const [store, setStore] = createStore<{
288283
filter: string
@@ -291,30 +286,23 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
291286
filter: "",
292287
})
293288

289+
// MCP servers are connected and managed from the MCP dialog, not here.
294290
const all = createMemo(() => {
295291
const query = store.filter.trim().toLowerCase()
296292

297-
if (!query) return integrations.list()
298-
299-
return integrations.list().filter((row) => `${row.id} ${row.name}`.toLowerCase().includes(query))
293+
return integrations
294+
.list()
295+
.filter((row) => row.metadata?.source !== "mcp")
296+
.filter((row) => !query || `${row.id} ${row.name}`.toLowerCase().includes(query))
300297
})
301298

302-
// MCP servers keep their own group whether or not they are signed in.
303-
const providers = createMemo(() => all().filter((row) => row.metadata?.source !== "mcp"))
304-
305299
const connected = createMemo(() =>
306-
providers()
300+
all()
307301
.filter((row) => row.connections.length > 0)
308302
.toSorted((a, b) => a.name.localeCompare(b.name)),
309303
)
310304

311-
const unconnected = createMemo(() => providers().filter((row) => row.connections.length === 0))
312-
313-
const mcp = createMemo(() =>
314-
all()
315-
.filter((row) => row.metadata?.source === "mcp")
316-
.toSorted((a, b) => a.name.localeCompare(b.name)),
317-
)
305+
const unconnected = createMemo(() => all().filter((row) => row.connections.length === 0))
318306

319307
const popular = createMemo(() =>
320308
unconnected()
@@ -330,15 +318,14 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
330318

331319
const groups = () => [
332320
{ title: language.t("dialog.provider.connected"), items: connected },
333-
{ title: language.t("dialog.provider.group.mcp"), items: mcp },
334321
{ title: language.t("dialog.provider.group.popular"), items: popular },
335322
{ title: language.t("dialog.provider.group.services"), items: services },
336323
]
337324

338325
// An integration that only reads environment variables has nothing to connect from here.
339326
const disabled = (row: IntegrationInfo) => connectMethods(row).length === 0 && providerAccounts(row).length === 0
340327

341-
const rows = createMemo(() => [...connected(), ...mcp(), ...popular(), ...services()].filter((row) => !disabled(row)))
328+
const rows = createMemo(() => [...connected(), ...popular(), ...services()].filter((row) => !disabled(row)))
342329

343330
let picker: HTMLDivElement | undefined
344331
let search: HTMLInputElement | undefined
@@ -400,21 +387,13 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
400387
</div>
401388
<For each={group.items()}>
402389
{(provider) => {
403-
const mcp = provider.metadata?.source === "mcp"
404390
const connection = () => provider.connections[0]
405391

406-
const needsSignIn = () =>
407-
!!connection()?.status ||
408-
(mcp &&
409-
mcpServers().some(
410-
(server) => server.integrationID === provider.id && server.status.status === "needs_auth",
411-
))
412-
413392
// The server lists the active account first.
414393
const account = () => {
415394
const current = connection()
416395

417-
if (mcp || !current) return
396+
if (!current) return
418397

419398
return current.type === "credential" ? current.label : `$${current.name}`
420399
}
@@ -454,7 +433,7 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
454433
</Badge>
455434
)}
456435
</Show>
457-
<Show when={needsSignIn()}>
436+
<Show when={!!connection()?.status}>
458437
<span
459438
data-slot="provider-status"
460439
class="ms-auto shrink-0 pe-1 font-[440] text-[var(--v2-state-fg-warning)]"
@@ -559,9 +538,6 @@ function ProviderConnection(props: {
559538

560539
const showAccounts = () => !!props.accounts && !state.adding && accounts().length > 0
561540

562-
const mcp = () =>
563-
integrations.list().find((integration) => integration.id === props.provider)?.metadata?.source === "mcp"
564-
565541
const controller = createProviderConnectionController({
566542
provider: () => integrationID,
567543
directory,
@@ -603,8 +579,7 @@ function ProviderConnection(props: {
603579
})
604580

605581
// Like the TUI, every connection continues to that provider's models, not just the first.
606-
// MCP servers have no models, so they close instead.
607-
const first = mcp() ? undefined : connectionGroups()[0]?.models[0]
582+
const first = connectionGroups()[0]?.models[0]
608583

609584
if (first) {
610585
setState({ models: true, selectedModel: modelKey(first) })

‎packages/app/src/runtime/i18n/en.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export const dict = {
135135
"dialog.provider.search.placeholder": "Search providers",
136136
"dialog.provider.empty": "No providers found",
137137
"dialog.provider.group.popular": "Popular",
138-
"dialog.provider.group.mcp": "MCP",
139138
"dialog.provider.group.services": "Services",
140139
"dialog.provider.environmentOnly": "Environment only",
141140
"dialog.provider.signInRequired": "Sign in required →",

‎packages/tui/src/component/dialog-integration.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const OAUTH_CODE = /[A-Z0-9]{4}-[A-Z0-9]{4,5}/
6969
export function integrationOptions(list: IntegrationInfo[]) {
7070
return list.toSorted(
7171
(a, b) =>
72-
Number(b.metadata?.source === "mcp") - Number(a.metadata?.source === "mcp") ||
7372
(INTEGRATION_PRIORITY[a.id] ?? 99) - (INTEGRATION_PRIORITY[b.id] ?? 99) ||
7473
a.name.localeCompare(b.name) ||
7574
a.id.localeCompare(b.id),
@@ -105,9 +104,12 @@ export function DialogIntegration(
105104
const dialog = useDialog()
106105
const theme = useTheme().surface("dialog")
107106
const location = currentLocation.ref ?? data.location.default()
107+
// The MCP dialog signs its servers in through `integrationID`; the connect menu leaves them to it.
108108
const integrations = createMemo(() =>
109-
integrationOptions(data.location.integration.list(location) ?? []).filter(
110-
(integration) => props.integrationID === undefined || integration.id === props.integrationID,
109+
integrationOptions(data.location.integration.list(location) ?? []).filter((integration) =>
110+
props.integrationID === undefined
111+
? integration.metadata?.source !== "mcp"
112+
: integration.id === props.integrationID,
111113
),
112114
)
113115

@@ -129,7 +131,6 @@ export function DialogIntegration(
129131
const credentials = credentialConnections(integration)
130132
let category = "Services"
131133
if (integration.id in INTEGRATION_PRIORITY) category = "Popular"
132-
if (integration.metadata?.source === "mcp") category = "MCP"
133134
const status = integration.connections[0]?.status
134135
return {
135136
title: integration.name,
@@ -1262,7 +1263,7 @@ async function connected(
12621263
data.location.provider.sync(location),
12631264
])
12641265
toast.show({ variant: "success", message: `Connected ${integration.name}` })
1265-
if (onConnected && integration.metadata?.source !== "mcp") {
1266+
if (onConnected) {
12661267
onConnected(providerID(data, location, integration.id))
12671268
return
12681269
}

‎packages/tui/test/cli/cmd/tui/integration-options.test.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ describe("integrationOptions", () => {
2626
]).map((item) => item.id),
2727
).toEqual(["opencode", "opencode-go", "openai", "anthropic", "mistral", "custom-z"])
2828
})
29-
30-
test("keeps MCP integrations above popular integrations without relying on their IDs", () => {
31-
expect(
32-
integrationOptions([
33-
integration({ id: "openai", name: "OpenAI" }),
34-
integration({ id: "linear", name: "Linear", metadata: { source: "mcp" } }),
35-
integration({ id: "github", name: "GitHub", metadata: { source: "mcp" } }),
36-
integration({ id: "opencode", name: "OpenCode Zen" }),
37-
integration({ id: "opencode-go", name: "OpenCode Go" }),
38-
]).map((item) => item.id),
39-
).toEqual(["github", "linear", "opencode", "opencode-go", "openai"])
40-
})
4129
})
4230

4331
describe("connectMethods", () => {

‎packages/tui/test/cli/tui/dialog-integration.test.tsx‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,84 @@ test("uses the active location for integration data without scoping credential r
247247
}
248248
})
249249

250+
test("leaves MCP integrations out of the connect menu", async () => {
251+
await using fixture = await renderMenu()
252+
await fixture.app.waitForFrame((frame) => frame.includes("OpenAI"))
253+
254+
const frame = fixture.app.captureCharFrame()
255+
expect(frame).not.toContain("Linear")
256+
expect(frame).not.toContain("MCP")
257+
})
258+
259+
test("still offers an MCP integration when the MCP dialog asks for it", async () => {
260+
await using fixture = await renderMenu("linear")
261+
await fixture.app.waitForFrame((frame) => frame.includes("Linear"))
262+
263+
expect(fixture.app.captureCharFrame()).not.toContain("OpenAI")
264+
})
265+
266+
async function renderMenu(integrationID?: string) {
267+
const calls = createFetch(async (url, request) => {
268+
if (url.pathname !== "/api/integration") return undefined
269+
const directory = decodeURIComponent(request.headers.get("x-opencode-directory") ?? process.cwd())
270+
return json({
271+
location: { directory, project: { id: "proj_test", directory, canonical: directory } },
272+
data: [
273+
{ id: "openai", name: "OpenAI", methods: [{ type: "key", label: "API key" }], connections: [] },
274+
{
275+
id: "linear",
276+
name: "Linear",
277+
methods: [{ type: "oauth", id: "mcp", label: "Sign in" }],
278+
connections: [],
279+
metadata: { source: "mcp" },
280+
},
281+
],
282+
})
283+
})
284+
285+
function Probe() {
286+
const data = useData()
287+
const dialog = useDialog()
288+
onMount(() => {
289+
void data.location.integration
290+
.sync()
291+
.then(() => dialog.replace(() => <DialogIntegration integrationID={integrationID} />))
292+
})
293+
return null
294+
}
295+
296+
const app = await testRender(
297+
() => (
298+
<TestTuiContexts>
299+
<ConfigProvider config={createTuiResolvedConfig()}>
300+
<Keymap.Provider>
301+
<ToastProvider>
302+
<ClientProvider api={createApi(calls.fetch)}>
303+
<DataProvider directory={process.cwd()}>
304+
<LocationProvider>
305+
<ThemeProvider mode="dark" source={emptyThemeSource}>
306+
<DialogProvider>
307+
<Probe />
308+
</DialogProvider>
309+
</ThemeProvider>
310+
</LocationProvider>
311+
</DataProvider>
312+
</ClientProvider>
313+
</ToastProvider>
314+
</Keymap.Provider>
315+
</ConfigProvider>
316+
</TestTuiContexts>
317+
),
318+
{ width: 100, height: 30, kittyKeyboard: true },
319+
)
320+
app.renderer.start()
321+
322+
return {
323+
app,
324+
[Symbol.asyncDispose]: async () => app.renderer.destroy(),
325+
}
326+
}
327+
250328
async function renderIntegration(activeLocation?: LocationRef, form?: FormFields) {
251329
const events = createEventStream()
252330
const requests: Array<{ method: string; path: string; body?: unknown }> = []

0 commit comments

Comments
 (0)