alibaba/spring-ai-alibaba · error · BizException
DeleteMCPServerError
DeleteMCPServerError
Error message
Failed to delete MCPServer.
What it means
Thrown by McpServerServiceImpl.deleteMcp when any exception occurs while deleting an MCP server. The service updates the DB entity, then writes/evicts the Redis cache entry keyed by workspace+serverCode; any failure in those persistence or cache operations is wrapped as BizException with code DeleteMCPServerError.
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:186
* @param serverCode Unique identifier of the server
*/
@Override
public void deleteMcp(String serverCode) {
try {
RequestContext context = RequestContextHolder.getRequestContext();
McpServerEntity entity = getMcpByCode(context.getWorkspaceId(), serverCode, null);
if (entity == null) {
throw new BizException(MCP_NOT_FOUND.toError());
}
entity.setGmtModified(new Date());
entity.setStatus(McpServerStatusEnum.Deleted.getCode());
this.updateById(entity);
String key = getMcpCacheKey(context.getWorkspaceId(), serverCode);
redisManager.put(key, entity);
}
catch (Exception e) {
throw new BizException(ErrorCode.DELETE_MCP_ERROR.toError(), e);
}
}
/**
* Retrieves MCP server details by server code
* @param serverCode Unique identifier of the server
* @param needTools Whether to include tool information
* @return Server details
*/
@Override
public McpServerDetail getMcp(String serverCode, boolean needTools) {
RequestContext context = RequestContextHolder.getRequestContext();
McpServerEntity entity = getMcpByCode(context.getWorkspaceId(), serverCode, null);
if (entity == null) {
throw new BizException(MCP_NOT_FOUND.toError());
}
McpServerDetail mcpServerDTO = toMcpServerDTO(entity);
if (needTools) {View on GitHub (pinned to f82da0b50f)
Solutions
- Check Redis and database connectivity from the admin-server-core service
- Inspect the wrapped cause 'e' in logs for the real failure (SQL error, Redis timeout)
- Retry the delete after resolving transient infra issues
- Clear the stale Redis cache key (workspace:serverCode) if the delete partially succeeded
Example fix
// before
try {
this.updateById(entity);
redisManager.put(key, entity);
} catch (Exception e) {
throw new BizException(ErrorCode.DELETE_MCP_ERROR.toError(), e);
}
// after
try {
this.updateById(entity);
} catch (DataAccessException e) {
log.error("DB delete failed for MCP {}", serverCode, e);
throw new BizException(ErrorCode.DELETE_MCP_ERROR.toError(), e);
}
try {
redisManager.delete(key);
} catch (Exception e) {
log.warn("Cache evict failed for MCP {}", serverCode, e); // non-fatal
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check server exists and infra is reachable
McpServerEntity e = mcpServerService.getMcpByCode(workspaceId, serverCode, null);
if (e == null) throw new IllegalStateException("MCP server not found: " + serverCode); Try / catch
try {
mcpServerService.deleteMcp(serverCode);
} catch (BizException e) {
if (e.getCause() instanceof DataAccessException dae) {
// retry or alert: DB-side failure
} else if (e.getCause() instanceof RedisException re) {
// evict cache manually and retry
}
log.error("Delete failed for {}", serverCode, e.getCause());
} Prevention
- Monitor Redis health from admin-server-core
- Avoid concurrent deletes of the same MCP server
- Always log the wrapped cause to identify the failing subsystem
- Evict cache keys explicitly after schema changes
When it happens
Trigger: Calling deleteMcp(serverCode) when the database update or the redisManager cache operation throws (DB connectivity loss, Redis down, serialization failure, optimistic-lock conflict).
Common situations: Redis connection pool exhausted; database deadlocks on concurrent deletes; entity state changed by another request between load and updateById; cache serialization errors after schema changes to McpServerEntity.
Related errors
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/5e60f1cd2d941e68.
Report an issue: GitHub.