alibaba/spring-ai-alibaba · error · BizException
MCPServerNotFound
MCPServerNotFound
Error message
MCPServer can not be found.
What it means
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.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/McpServerServiceImpl.java:137
}
catch (Exception e) {
throw new BizException(ErrorCode.CREATE_MCP_ERROR.toError("fail parse InstallConfig"), e);
}
}
/**
* Updates an existing MCP server configuration
* @param detail Updated server configuration
*/
@Override
public void updateMcp(McpServerDetail detail) {
try {
RequestContext context = RequestContextHolder.getRequestContext();
String serverCode = detail.getServerCode();
McpServerEntity entity = getMcpByCode(context.getWorkspaceId(), serverCode, null);
if (entity == null) {
throw new BizException(MCP_NOT_FOUND.toError());
}
entity.setName(detail.getName());
entity.setGmtModified(new Date());
Result<String> checkResult = mcpManager.processInstallConfig(detail.getDeployConfig(),
detail.getInstallType());
if (!checkResult.isSuccess()) {
throw new Exception(String.valueOf(checkResult.getMessage()));
}
entity.setDeployConfig(checkResult.getData());
entity.setHost(fetchHost(checkResult.getData()));
entity.setDetailConfig(detail.getDetailConfig());
entity.setDescription(detail.getDescription());
entity.setStatus(detail.getStatus());
entity.setBizType(detail.getBizType());
entity.setInstallType(detail.getInstallType());
entity.setDeployEnv(detail.getDeployEnv());
entity.setSource(detail.getSource());
entity.setType(detail.getType() == null ? McpServerTypeEnum.CUSTOMER.name() : detail.getType());View on GitHub (pinned to f82da0b50f)
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.
Defensive patterns
Strategy: validation
Validate before calling
McpServerEntity existing = mcpService.getMcpByCode(workspaceId, serverCode, null);
if (existing == null) { throw new IllegalStateException("MCP server " + serverCode + " not found"); } Type guard
boolean serverExists(McpServerEntity e) { return e != null && e.getServerCode() != null; } Try / catch
try {
mcpService.updateMcp(detail);
} catch (BizException e) {
if ("MCPServerNotFound".equals(e.getCode())) {
// re-fetch server list, inform user the server is gone
} else { throw e; }
} Prevention
- Fetch the current server list before updating
- Do not update after deletion; recreate instead
- Keep workspaceId consistent with where the server was created
When it happens
Trigger: Calling updateMcp(detail) with a serverCode that does not exist, was deleted, or belongs to a different workspace.
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- ApiKeyNotFound
- UpdateMCPServerError
- MCP Server [${serverCode}] not found!
- 评估器版本不存在
- Checkpoint with id %s not found!
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/12458e1b25671a74.
Report an issue: GitHub.