UNPKG

@wonderwhy-er/desktop-commander

Version:

MCP server for terminal operations and file editing

23 lines (22 loc) 962 B
import { configManager } from '../config-manager.js'; /** * Whether tools advertise interactive MCP UI widgets. Shown by default; a * boolean showMcpUI config value is an explicit user override. Any non-boolean * value (unset, or a stringly-typed "false") means the default applies. */ export function mcpUiEnabledFor(userOverride) { return typeof userOverride === 'boolean' ? userOverride : true; } // Decided once per server process: a session must render consistently. Flipping // tool UI _meta mid-session confuses hosts (open widgets / other threads sharing // this server see tools lose their UI), so config changes made while the server // is running take effect on the next restart. let sessionDecision = null; export async function shouldShowMcpUi() { if (!sessionDecision) { sessionDecision = configManager.getValue('showMcpUI') .then(mcpUiEnabledFor) .catch(() => true); } return sessionDecision; }