Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cli/ui/McpBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Box, Text } from "ink";
// biome-ignore lint/style/useImportType: tsconfig jsx=react needs React in value scope for JSX compilation
import React, { useState } from "react";
import { useKeystroke } from "./keystroke-context.js";
import { toggleMcpDisabled } from "./mcp-disable.js";
import { type ApplyAppend, kickOffMcpReconnect } from "./mcp-reconnect-kickoff.js";
import type { McpServerSummary } from "./slash/types.js";
import { COLOR } from "./theme.js";
Expand Down Expand Up @@ -41,6 +42,12 @@ export function McpBrowser({
// so the line is visible immediately.
postInfo(kickOffMcpReconnect(target, postInfo, applyAppend));
onClose();
} else if (ev.input === "d") {
const target = servers[index];
if (!target) return;
// Persist `mcpDisabled` and close — takes effect on next launch.
postInfo(toggleMcpDisabled("disable", target.label));
onClose();
}
});

Expand All @@ -66,7 +73,7 @@ export function McpBrowser({
)}
</Box>
<Box marginTop={1}>
<Text dimColor>↑↓ pick · [r] reconnect · [d] disable (TBD) · esc quit</Text>
<Text dimColor>↑↓ pick · [r] reconnect · [d] disable · esc quit</Text>
</Box>
</Box>
);
Expand Down
26 changes: 26 additions & 0 deletions src/cli/ui/mcp-disable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Persists `mcpDisabled` to ~/.reasonix/config.json — shared between `/mcp disable / enable` slash and the McpBrowser `d` keybind. */

import { readConfig, writeConfig } from "../../config.js";

export function toggleMcpDisabled(action: "disable" | "enable", name: string): string {
const trimmed = name.trim();
if (!trimmed) {
return `usage: /mcp ${action} <name> · pick a name shown in /mcp (anonymous servers can't be named-toggled).`;
}
const cfg = readConfig();
const current = new Set(cfg.mcpDisabled ?? []);
if (action === "disable") {
if (current.has(trimmed)) {
return `▸ ${trimmed} is already disabled — restart to apply, or /mcp enable ${trimmed}.`;
}
current.add(trimmed);
writeConfig({ ...cfg, mcpDisabled: [...current].sort() });
return `▸ ${trimmed} disabled — takes effect on next launch. /mcp enable ${trimmed} to revert.`;
}
if (!current.has(trimmed)) {
return `▸ ${trimmed} is not disabled.`;
}
current.delete(trimmed);
writeConfig({ ...cfg, mcpDisabled: current.size > 0 ? [...current].sort() : undefined });
return `▸ ${trimmed} re-enabled — takes effect on next launch.`;
}
21 changes: 2 additions & 19 deletions src/cli/ui/slash/handlers/mcp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readConfig, writeConfig } from "../../../../config.js";
import type { CacheFirstLoop } from "../../../../loop.js";
import { applyMcpAppend } from "../../mcp-append.js";
import { toggleMcpDisabled } from "../../mcp-disable.js";
import { kickOffMcpReconnect } from "../../mcp-reconnect-kickoff.js";
import type { SlashHandler } from "../dispatch.js";
import { appendSection } from "../helpers.js";
Expand Down Expand Up @@ -105,24 +105,7 @@ function toggleDisabled(
const list = [...known].sort().join(", ") || "(none)";
return { info: `unknown MCP server "${name}". Known: ${list}.` };
}
const cfg = readConfig();
const current = new Set(cfg.mcpDisabled ?? []);
if (action === "disable") {
if (current.has(name)) {
return { info: `▸ ${name} is already disabled — restart to apply, or /mcp enable ${name}.` };
}
current.add(name);
writeConfig({ ...cfg, mcpDisabled: [...current].sort() });
return {
info: `▸ ${name} disabled — takes effect on next launch. /mcp enable ${name} to revert.`,
};
}
if (!current.has(name)) {
return { info: `▸ ${name} is not disabled.` };
}
current.delete(name);
writeConfig({ ...cfg, mcpDisabled: current.size > 0 ? [...current].sort() : undefined });
return { info: `▸ ${name} re-enabled — takes effect on next launch.` };
return { info: toggleMcpDisabled(action, name) };
}

function parseLabelFromSpec(spec: string): string | null {
Expand Down
Loading