A desktop coding agent with free access to frontier models.
TypeScript
fix: MCP settings and tool labels
Samrat Talukdar165f454ab939
diff --git a/apps/app/src/lib/capability-call.ts b/apps/app/src/lib/capability-call.tsindex 1bf4ef43..0f10ad1a 100644--- a/apps/app/src/lib/capability-call.ts+++ b/apps/app/src/lib/capability-call.ts@@ -135,6 +135,30 @@ function verbPhrase(action: string, tense: "present" | "past"): string {return `${prefix} ${humanize(action)}`}+// Supported MCP servers (the account's list) by id, with their titles. The+// engine names their tools `<id>_<tool>`; those calls read "Used <title>: <tool>".+const mcpServerTitles = new Map<string, string>()++/** Remember the titles of supported MCP servers (from GET /workspace/:id/mcp). */+export function registerMcpServerTitles(entries: ReadonlyArray<{ id?: string | null; title?: string | null }>): void {+ for (const entry of entries) {+ const id = entry.id?.trim()+ const title = entry.title?.trim()+ if (id && title) mcpServerTitles.set(id, title)+ }+}++function listedMcpServer(toolName: string): { title: string; tool: string } | null {+ let best: { title: string; tool: string; length: number } | null = null+ for (const [id, title] of mcpServerTitles) {+ const prefix = `${id.replace(/[^a-zA-Z0-9_-]/g, "_")}_`+ if (toolName.startsWith(prefix) && toolName.length > prefix.length && (!best || prefix.length > best.length)) {+ best = { title, tool: toolName.slice(prefix.length), length: prefix.length }+ }+ }+ return best ? { title: best.title, tool: best.tool } : null+}+/*** Build the human sentence for a dynamic (MCP / capability) tool call.* Tool names follow "{connection}_{tool}", e.g.@@ -227,6 +251,17 @@ export function getCapabilityCallSentence(}}+ // A supported MCP server's tool: its title and the tool's own name.+ const listed = listedMcpServer(toolName)+ if (listed) {+ const suffix = quoted ? ` —${quoted}` : ""+ return {+ service: listed.title,+ present: `Using ${listed.title}: ${listed.tool}${suffix}`,+ past: `Used ${listed.title}: ${listed.tool}${suffix}`,+ }+ }+// Generic "{connection}_{tool}" MCP tools.const underscore = toolName.indexOf("_")if (underscore > 0) {diff --git a/apps/app/src/react-app/domains/connections/modals/add-mcp-modal.tsx b/apps/app/src/react-app/domains/connections/modals/add-mcp-modal.tsxindex e99d9c8f..efeecd75 100644--- a/apps/app/src/react-app/domains/connections/modals/add-mcp-modal.tsx+++ b/apps/app/src/react-app/domains/connections/modals/add-mcp-modal.tsx@@ -1,5 +1,5 @@/** @jsxImportSource react */-import { useReducer } from "react";+import { useEffect, useReducer } from "react";import { Loader2, Plus } from "lucide-react";import {@@ -25,6 +25,10 @@ export type AddMcpModalProps = {onAdd: (entry: McpDirectoryInfo) => Promise<McpConnectResult>;busy: boolean;isRemoteWorkspace: boolean;+ /** Local (command) servers only, e.g. when only the account's supported servers start. */+ localOnly?: boolean;+ /** A short note under the title (what will happen to the server). */+ note?: string | null;};type AddMcpState = {@@ -60,6 +64,9 @@ function addMcpReducer(state: AddMcpState, patch: Partial<AddMcpState> | "reset"export function AddMcpModal(props: AddMcpModalProps) {const [state, dispatch] = useReducer(addMcpReducer, initialAddMcpState);+ useEffect(() => {+ if (props.open && props.localOnly && state.serverType !== "local") dispatch({ serverType: "local" });+ }, [props.open, props.localOnly, state.serverType]);const reset = () => {dispatch("reset");@@ -168,7 +175,7 @@ export function AddMcpModal(props: AddMcpModalProps) {{t("mcp.add_modal_title")}</DialogTitle><DialogDescription>- {t("mcp.add_modal_subtitle")}+ {props.note ?? t("mcp.add_modal_subtitle")}</DialogDescription></DialogHeader>@@ -180,7 +187,7 @@ export function AddMcpModal(props: AddMcpModalProps) {onChange={(event) => dispatch({ name: event.currentTarget.value })}/>- <div>+ {props.localOnly ? null : <div><div className="mb-1 text-xs font-medium text-dls-secondary">{t("mcp.server_type")}</div>@@ -217,7 +224,7 @@ export function AddMcpModal(props: AddMcpModalProps) {{t("mcp.remote_workspace_url_hint")}</div>) : null}- </div>+ </div>}{state.serverType === "remote" ? (<div className="space-y-3">diff --git a/apps/app/src/react-app/domains/connections/store.ts b/apps/app/src/react-app/domains/connections/store.tsindex 6dc52329..218037a2 100644--- a/apps/app/src/react-app/domains/connections/store.ts+++ b/apps/app/src/react-app/domains/connections/store.ts@@ -33,6 +33,7 @@ import {removeMcpFromConfig,validateMcpServerName,} from "../../../app/mcp";+import { registerMcpServerTitles } from "@/lib/capability-call";import {buildOmniRushWorkspaceBaseUrl,type OmniRushMcpPolicyView,@@ -487,6 +488,7 @@ export function createConnectionsStore(options: {}}}+ if (response.mcpPolicy) registerMcpServerTitles([...response.mcpPolicy.supported, ...response.mcpPolicy.decisions]);const next = response.items.map((entry) => ({name: entry.name,config: entry.config as McpServerEntry["config"],diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsxindex 69dbdb67..4d2ba1f9 100644--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx@@ -146,6 +146,7 @@ import {type ChatMcpReconnectScope,} from "./mcp-chat-reconnect";import { OpenTargetProvider, type OpenTargetOptions } from "@/lib/target-provider";+import { registerMcpServerTitles } from "@/lib/capability-call";import type { ThreadStatus } from "@/lib/messages";import {EnvironmentVariableProvider,@@ -2844,6 +2845,15 @@ export function SessionSurface(props: SessionSurfaceProps) {return next;}, [props.client, props.workspaceId]);+ // Chat labels for supported MCP servers' tools use their titles (lib/capability-call.ts).+ useEffect(() => {+ let current = true;+ void props.client.listMcp(props.workspaceId).then((response) => {+ if (current && response.mcpPolicy) registerMcpServerTitles([...response.mcpPolicy.supported, ...response.mcpPolicy.decisions]);+ }).catch(() => undefined);+ return () => { current = false; };+ }, [props.client, props.workspaceId]);+const listMcp = useCallback(async (): Promise<{ servers: McpServerEntry[]; statuses: McpStatusMap; status: string | null }> => {if (props.mcpDisabled === true) {const status = "This project's MCP servers are listed in Settings > MCP.";diff --git a/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx b/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsxindex 4f3a65ca..5ef211db 100644--- a/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx+++ b/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx@@ -17,16 +17,32 @@ export const MCP_REMOTE_NOT_SUPPORTED =export const MCP_ENGINE_V2_NOTE ="MCP servers are off while the preview engine runs chats. Turn the preview engine off to use them.";+/** What to do about a blocked server, by decision code (the reason says why). */+export const MCP_BLOCKED_HINTS: Record<string, string> = {+ denied: "Not on the supported list.",+ not_allowed: "Not on the supported list.",+ remote: "Remote servers are not supported.",+ unknown_command: "Start it with npx or uvx.",+ outside_project: "Point it at a folder or file inside the project.",+ version: "Leave the version out to use the supported one.",+};+export type McpServerState =| { kind: "on"; detail: string }- | { kind: "blocked"; reason: string }+ | { kind: "blocked"; reason: string; hint: string | null }| { kind: "off" }| { kind: "pending" };/** The line a configured server shows, from the plugin's decision. */export function mcpServerState(entry: Pick<McpServerEntry, "name" | "config">, decision: OmniRushMcpDecision | null | undefined): McpServerState {if (!decision) return { kind: "pending" };- if (decision.status === "blocked") return { kind: "blocked", reason: decision.reason?.trim() || "This MCP server is not supported." };+ if (decision.status === "blocked") {+ const reason = decision.reason?.trim() || "This MCP server is not supported.";+ const hint = MCP_BLOCKED_HINTS[decision.code] ?? null;+ // No hint that only repeats what the reason already says.+ const said = (text: string) => text.toLowerCase().replace(/\bmcp /g, "").replace(/\.$/, "");+ return { kind: "blocked", reason, hint: hint && !said(reason).includes(said(hint)) ? hint : null };+ }if ((entry.config as { enabled?: unknown } | undefined)?.enabled === false) return { kind: "off" };const parts = [decision.package && decision.version ? `${decision.package}@${decision.version}` : null,@@ -36,6 +52,19 @@ export function mcpServerState(entry: Pick<McpServerEntry, "name" | "config">, dreturn { kind: "on", detail: parts.join(" · ") };}+/** Server text with `code` spans: the backticked parts as inline code, the rest as plain text. */+export function PlainText(props: { text: string }) {+ const parts = props.text.split("`");+ if (parts.length < 3) return <>{props.text.replace(/`/g, "")}</>;+ return (+ <>+ {parts.map((part, index) => (index % 2 === 1 && index < parts.length - 1+ ? <code key={index} className="rounded bg-dls-hover px-1 font-mono text-[11px]">{part}</code>+ : <span key={index}>{part}</span>))}+ </>+ );+}+/** The command a preset adds, as one line. */export function presetCommandLine(preset: Pick<OmniRushMcpPreset, "command">): string {return preset.command.map((word) => (/^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, "'\\''")}'`)).join(" ");@@ -101,7 +130,7 @@ export function McpSupportedPanel(props: {</p>) : state.kind === "blocked" ? (<p className="mt-0.5 text-xs text-dls-secondary">- <span className="font-medium text-foreground">Blocked</span>{` · ${state.reason}`}+ <span className="font-medium text-amber-11">Blocked</span>{` · ${state.reason}${state.hint ? ` ${state.hint}` : ""}`}</p>) : state.kind === "off" ? (<p className="mt-0.5 text-xs text-dls-secondary">Off</p>@@ -135,7 +164,7 @@ export function McpSupportedPanel(props: {<li key={preset.id} data-testid={`mcp-preset-${preset.id}`} className="flex items-start justify-between gap-3 px-4 py-3"><div className="min-w-0"><p className="text-sm font-medium text-foreground">{preset.title}</p>- {preset.why ? <p className="mt-0.5 text-xs text-dls-secondary">{preset.why}</p> : null}+ {preset.why ? <p className="mt-0.5 text-xs text-dls-secondary"><PlainText text={preset.why} /></p> : null}<code className="mt-1 block truncate rounded-md bg-dls-hover px-2 py-1 font-mono text-[11px] text-dls-secondary" title={presetCommandLine(preset)}>{presetCommandLine(preset)}</code>diff --git a/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx b/apps/app/src/react-app/domains/settings/pages/mcp-view.tsxindex 5a82350b..2d6eb883 100644--- a/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx+++ b/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx@@ -550,6 +550,8 @@ export function McpView(props: McpViewProps) {const availableConnectMcpServers: McpServerEntry[] = [];const installedPlugins = (props.installedPlugins ?? []).filter((plugin) => !plugin.files.some((file) => file.objectType === "mcp"));const orgMcpItems: ExtensionItem[] = [];+ // The supported-servers panel stands for the MCP part of the library.+ const mcpPanelShown = Boolean(mcpPolicy) && (filter === "all" || filter === "mcp") && inventoryState === "all";const addSupportedMcp = async (preset: OmniRushMcpPreset) => {const result = await props.connectMcp({id: preset.id,@@ -1421,25 +1423,6 @@ export function McpView(props: McpViewProps) {return (<section className="w-full max-w-3xl animate-in fade-in duration-300">- {(filter === "all" || filter === "mcp") && inventoryState === "all" ? (- mcpPolicy ? (- <McpSupportedPanel- policy={mcpPolicy}- servers={props.mcpServers.filter((entry) => !isConnectDirectMcpServerName(entry.name) && entry.name !== "omnirush-cloud")}- canAdd={props.allowManageExtensions && !props.isRemoteWorkspace && mcpPolicy.engineV2 !== true}- busy={props.busy}- addPreset={addSupportedMcp}- removeServer={props.allowManageExtensions ? (name) => {- setRemoveTarget(name);- setRemoveOpen(true);- } : undefined}- />- ) : mcpDisabled ? (- <p data-testid="mcp-disabled-policy-notice" className="mb-5 text-sm text-dls-secondary">- MCP servers are turned off for this account.- </p>- ) : null- ) : null}{props.builtInExtensionsDisabled && props.allowManageExtensions ? (<div className="mb-5 rounded-xl border border-amber-6 bg-amber-2 px-4 py-3 text-xs text-amber-11">Built-in omnirush.ai extensions are disabled by your organization. Use Show hidden to review blocked built-ins.@@ -1534,6 +1517,25 @@ export function McpView(props: McpViewProps) {</div></div>+ {(filter === "all" || filter === "mcp") && inventoryState === "all" ? (+ mcpPolicy ? (+ <McpSupportedPanel+ policy={mcpPolicy}+ servers={props.mcpServers.filter((entry) => !isConnectDirectMcpServerName(entry.name) && entry.name !== "omnirush-cloud")}+ canAdd={props.allowManageExtensions && !props.isRemoteWorkspace && mcpPolicy.engineV2 !== true}+ busy={props.busy}+ addPreset={addSupportedMcp}+ removeServer={props.allowManageExtensions ? (name) => {+ setRemoveTarget(name);+ setRemoveOpen(true);+ } : undefined}+ />+ ) : mcpDisabled ? (+ <p data-testid="mcp-disabled-policy-notice" className="mb-5 text-sm text-dls-secondary">+ MCP servers are turned off for this account.+ </p>+ ) : null+ ) : null}{/* Async refresh status must not move the Add button or filter controls. */}{props.mcpStatus ? (<div className="mb-5 whitespace-pre-wrap wrap-break-word rounded-xl border border-dls-border bg-dls-hover px-4 py-3 text-xs text-dls-secondary">@@ -1541,7 +1543,8 @@ export function McpView(props: McpViewProps) {</div>) : null}- <McpQuickConnectSection+ {mcpPanelShown && filter === "mcp" ? null : <McpQuickConnectSection+ hideEmpty={mcpPanelShown}skillCount={skillCount}entries={quickConnectList.filter((entry) => {@@ -1657,7 +1660,7 @@ export function McpView(props: McpViewProps) {orgMcpDisconnectingId={props.orgMcpDisconnectingId ?? null}disconnectOrgMcp={props.disconnectOrgMcp}filtersActive={Boolean(search.trim()) || filter !== "all" || inventoryState !== "all"}- />+ />}{visibleMcpServers.length > 0 ? (<McpConfiguredServersSection@@ -1745,6 +1748,8 @@ export function McpView(props: McpViewProps) {onAdd={props.connectMcp}busy={props.busy}isRemoteWorkspace={props.isRemoteWorkspace}+ localOnly={Boolean(mcpPolicy)}+ note={mcpPolicy ? "Only servers on the supported list start: a local server started with npx or uvx, working on files inside this project. Anything else is refused with the reason." : null}/> : null}<AddLibraryItemModal@@ -1943,6 +1948,8 @@ function ExtensionLayoutToggle(props: {}function McpQuickConnectSection(props: {+ /** Leave out the empty state (the MCP panel above already fills the page). */+ hideEmpty?: boolean;skillCount: number;entries: McpDirectoryInfo[];installedSkills?: SkillItem[];@@ -2213,7 +2220,7 @@ function McpQuickConnectSection(props: {/>))}</div>- ) : !hasCards ? (+ ) : !hasCards && props.hideEmpty ? null : !hasCards ? (<div className="rounded-[10px] border border-dashed border-dls-border bg-dls-surface px-6 py-12 text-center"><p className="text-[15px] font-medium text-dls-text">{props.filtersActive ? t("extensions.empty_filtered_title") : t("extensions.empty_title")}diff --git a/apps/app/tests/capability-call-sentence.test.ts b/apps/app/tests/capability-call-sentence.test.tsindex d77cd591..aea88457 100644--- a/apps/app/tests/capability-call-sentence.test.ts+++ b/apps/app/tests/capability-call-sentence.test.ts@@ -1,7 +1,7 @@import { describe, expect, test } from "bun:test";import type { DynamicToolUIPart } from "ai";-import { getCapabilityCallQuote, getCapabilityCallSentence } from "@/lib/capability-call";+import { getCapabilityCallQuote, getCapabilityCallSentence, registerMcpServerTitles } from "@/lib/capability-call";function executeCapability(input: unknown): DynamicToolUIPart {return {@@ -60,4 +60,14 @@ describe("capability call sentences", () => {test("falls back to a generic sentence only when the name is unusable", () => {expect(getCapabilityCallSentence(executeCapability({})).past).toBe("Ran a capability");});++ test("a supported MCP server's tool reads with the server's title and the tool's name", () => {+ registerMcpServerTitles([{ id: "sqlite", title: "SQLite" }, { id: "sequential-thinking", title: "Sequential thinking" }]);+ const call = (toolName: string): DynamicToolUIPart => ({ type: "dynamic-tool", toolName, toolCallId: "c", state: "output-available", input: {}, output: "ok" } as DynamicToolUIPart);+ expect(getCapabilityCallSentence(call("sqlite_write_query"))).toMatchObject({ service: "SQLite", past: "Used SQLite: write_query", present: "Using SQLite: write_query" });+ expect(getCapabilityCallSentence(call("sqlite_read_query")).past).toBe("Used SQLite: read_query");+ expect(getCapabilityCallSentence(call("sequential-thinking_sequentialthinking")).past).toBe("Used Sequential thinking: sequentialthinking");+ // Other MCP tools keep their sentences.+ expect(getCapabilityCallSentence(call("granola_list_meetings")).past).toBe("Listed meetings · Granola");+ });});diff --git a/apps/app/tests/mcp-supported-panel.test.tsx b/apps/app/tests/mcp-supported-panel.test.tsxindex e59dfc13..d643a155 100644--- a/apps/app/tests/mcp-supported-panel.test.tsx+++ b/apps/app/tests/mcp-supported-panel.test.tsx@@ -4,6 +4,7 @@ import { renderToStaticMarkup } from "react-dom/server";import type { OmniRushMcpPolicyView, OmniRushMcpPreset } from "../src/app/lib/omnirush-server";import type { McpServerEntry } from "../src/app/types";import {+ MCP_BLOCKED_HINTS,MCP_ENGINE_V2_NOTE,MCP_REMOTE_NOT_SUPPORTED,McpSupportedPanel,@@ -76,6 +77,9 @@ describe("Settings > MCP: supported servers", () => {expect(html).toContain("Checked when the project's next chat starts.");expect(html).toContain("From the project's opencode.json");expect(html).not.toContain("text-red-11");+ // Blocked reads as a warning, not an error, and the remote hint is not said twice.+ expect(html).toContain('text-amber-11">Blocked');+ expect(html).not.toContain(MCP_BLOCKED_HINTS.remote);// The configured preset says Added instead of offering it again.expect(html).toMatch(/data-testid="mcp-preset-filesystem".*Added/s);});@@ -86,6 +90,24 @@ describe("Settings > MCP: supported servers", () => {expect(html).not.toContain(">Add<");});+ test("a blocked row says why and what to do", () => {+ expect(mcpServerState(server("gh"), { name: "gh", status: "blocked", code: "denied", reason: "The GitHub server works on your GitHub account." }))+ .toEqual({ kind: "blocked", reason: "The GitHub server works on your GitHub account.", hint: "Not on the supported list." });+ expect(mcpServerState(server("x"), { name: "x", status: "blocked", code: "not_allowed", reason: "This MCP server is not on the supported list." }))+ .toMatchObject({ hint: null });+ expect(mcpServerState(server("x"), { name: "x", status: "blocked", code: "unknown_command", reason: "The app cannot tell which MCP server this is." }))+ .toMatchObject({ hint: "Start it with npx or uvx." });+ expect(mcpServerState(server("x"), { name: "x", status: "blocked", code: "outside_project", reason: "This MCP server may only use files inside the project folder. (/etc)" }))+ .toMatchObject({ hint: "Point it at a folder or file inside the project." });+ });++ test("backticks in a preset's description show as inline code", () => {+ const html = render({ policy: policy({ supported: [{ ...filesystem, why: "Answers `now` in any time zone." }] }) });+ expect(html).toContain("<code");+ expect(html).toContain(">now</code>");+ expect(html).not.toContain("`");+ });+test("helpers", () => {expect(presetCommandLine({ command: ["uvx", "mcp-server-git", "--repository", "my repo"] })).toBe("uvx mcp-server-git --repository 'my repo'");expect(presetConfigured(filesystem, [], [{ name: "files", status: "allowed", code: "allowed", id: "filesystem" }])).toBe(true);