{"record":{"id":"2a6d6212f97ca356","repo":"bytedance/deer-flow","slug":"failed-to-update-mcp-server","errorCode":null,"errorMessage":"Failed to update MCP server","messagePattern":"Failed to update MCP server","errorType":"exception","errorClass":"MCPConfigRequestError","httpStatus":null,"severity":"error","filePath":"frontend/src/core/mcp/api.ts","lineNumber":71,"sourceCode":"  return response.json();\n}\n\nexport async function updateMCPServerState(\n  serverName: string,\n  enabled: boolean,\n) {\n  const response = await fetch(`${getBackendBaseURL()}/api/mcp/config`, {\n    method: \"PATCH\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n      server_name: serverName,\n      enabled,\n    }),\n  });\n  if (!response.ok) {\n    throw new MCPConfigRequestError(\n      response.status,\n      await readErrorDetail(response, \"Failed to update MCP server\"),\n    );\n  }\n  return response.json() as Promise<MCPConfig>;\n}\n","sourceCodeStart":53,"sourceCodeEnd":78,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/frontend/src/core/mcp/api.ts#L53-L78","documentation":"Thrown when PATCH /api/mcp/config with {server_name, enabled} fails. This is the toggle used to enable/disable one MCP server. The backend resolves server_name against the loaded config; unknown names yield 404, and validation/IO problems yield 4xx/5xx.","triggerScenarios":"Toggling a server that was renamed or deleted in another session (404); toggling while the config file is being rewritten (rare 409/500); PATCHing a name with leading/trailing whitespace copied from the UI.","commonSituations":"Two browser tabs open on MCP settings where one removed a server and the other still shows its toggle; config edited by hand or via API between page load and click; stale UI after a Gateway restart with a different config.","solutions":["On 404, reload the config (loadMCPConfig) and refresh the server list before retrying","Ensure server_name is passed exactly as it appears as a key of the config's mcp servers map","Check Gateway logs for file-write errors if status is 5xx","Retry the toggle once after refreshing to rule out a transient reload window"],"exampleFix":"// before\nawait updateMCPServerState(name, enabled);\n\n// after\ntry {\n  await updateMCPServerState(name, enabled);\n} catch (e) {\n  if (e instanceof MCPConfigRequestError && e.status === 404) {\n    await refreshServers(); // server was removed elsewhere\n    return;\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"function serverExists(config: MCPConfig, name: string): boolean {\n  return Object.prototype.hasOwnProperty.call(config.mcpServers ?? {}, name);\n}","typeGuard":"export function isMCPConfigRequestError(e: unknown): e is MCPConfigRequestError {\n  return e instanceof MCPConfigRequestError;\n}","tryCatchPattern":"try {\n  await updateMCPServerState(name, enabled);\n} catch (e) {\n  if (isMCPConfigRequestError(e) && e.status === 404) {\n    await reloadConfigAndRefreshList();\n    return;\n  }\n  throw e;\n}","preventionTips":["Refresh the config before toggling after long idle","Avoid two tabs editing MCP settings simultaneously","Pass server_name exactly as the config key"],"tags":["mcp","config","http","frontend"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}