{"record":{"id":"12458e1b25671a74","repo":"alibaba/spring-ai-alibaba","slug":"mcpservernotfound","errorCode":"MCPServerNotFound","errorMessage":"MCPServer can not be found.","messagePattern":"MCPServer can not be found\\.","errorType":"error_code","errorClass":"BizException","httpStatus":404,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/McpServerServiceImpl.java","lineNumber":137,"sourceCode":"\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new BizException(ErrorCode.CREATE_MCP_ERROR.toError(\"fail parse InstallConfig\"), e);\n\t\t}\n\n\t}\n\n\t/**\n\t * Updates an existing MCP server configuration\n\t * @param detail Updated server configuration\n\t */\n\t@Override\n\tpublic void updateMcp(McpServerDetail detail) {\n\t\ttry {\n\t\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\t\tString serverCode = detail.getServerCode();\n\t\t\tMcpServerEntity entity = getMcpByCode(context.getWorkspaceId(), serverCode, null);\n\t\t\tif (entity == null) {\n\t\t\t\tthrow new BizException(MCP_NOT_FOUND.toError());\n\t\t\t}\n\t\t\tentity.setName(detail.getName());\n\t\t\tentity.setGmtModified(new Date());\n\t\t\tResult<String> checkResult = mcpManager.processInstallConfig(detail.getDeployConfig(),\n\t\t\t\t\tdetail.getInstallType());\n\t\t\tif (!checkResult.isSuccess()) {\n\t\t\t\tthrow new Exception(String.valueOf(checkResult.getMessage()));\n\t\t\t}\n\t\t\tentity.setDeployConfig(checkResult.getData());\n\t\t\tentity.setHost(fetchHost(checkResult.getData()));\n\t\t\tentity.setDetailConfig(detail.getDetailConfig());\n\t\t\tentity.setDescription(detail.getDescription());\n\t\t\tentity.setStatus(detail.getStatus());\n\t\t\tentity.setBizType(detail.getBizType());\n\t\t\tentity.setInstallType(detail.getInstallType());\n\t\t\tentity.setDeployEnv(detail.getDeployEnv());\n\t\t\tentity.setSource(detail.getSource());\n\t\t\tentity.setType(detail.getType() == null ? McpServerTypeEnum.CUSTOMER.name() : detail.getType());","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/McpServerServiceImpl.java#L119-L155","documentation":"Thrown by McpServerServiceImpl.updateMcp when getMcpByCode(workspaceId, serverCode, null) returns null — no MCP server with the given serverCode exists in the caller's workspace. It is raised as MCP_NOT_FOUND before any update is applied.","triggerScenarios":"Calling updateMcp(detail) with a serverCode that does not exist, was deleted, or belongs to a different workspace.","commonSituations":"Editing a server after it was deleted elsewhere, stale client-side cache of server codes, cross-workspace references, or Redis cache inconsistency masking the real lookup.","solutions":["List MCP servers in the workspace and confirm the serverCode before updating.","Check RequestContext workspaceId matches the workspace owning the server.","If the server was deleted, recreate it instead of updating."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"McpServerEntity existing = mcpService.getMcpByCode(workspaceId, serverCode, null);\nif (existing == null) { throw new IllegalStateException(\"MCP server \" + serverCode + \" not found\"); }","typeGuard":"boolean serverExists(McpServerEntity e) { return e != null && e.getServerCode() != null; }","tryCatchPattern":"try {\n    mcpService.updateMcp(detail);\n} catch (BizException e) {\n    if (\"MCPServerNotFound\".equals(e.getCode())) {\n        // re-fetch server list, inform user the server is gone\n    } else { throw e; }\n}","preventionTips":["Fetch the current server list before updating","Do not update after deletion; recreate instead","Keep workspaceId consistent with where the server was created"],"tags":["mcp","not-found","update"],"backgroundTag":"record-not-found","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}