mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 03:55:09 +08:00
fix(mcp): clear stale MCP connection errors
Update MCP server status with an explicit wrapper so successful reconnects can persist lastError=null while keeping updateTime refreshed.
This commit is contained in:
parent
f5d845ff31
commit
1aa7787ced
@ -2,6 +2,7 @@ package vip.mate.tool.mcp.service;
|
|||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -313,15 +314,16 @@ public class McpServerService {
|
|||||||
|
|
||||||
private void updateStatus(Long id, String status, String error, int toolCount) {
|
private void updateStatus(Long id, String status, String error, int toolCount) {
|
||||||
try {
|
try {
|
||||||
McpServerEntity update = new McpServerEntity();
|
LambdaUpdateWrapper<McpServerEntity> wrapper = new LambdaUpdateWrapper<>();
|
||||||
update.setId(id);
|
wrapper.eq(McpServerEntity::getId, id);
|
||||||
update.setLastStatus(status);
|
wrapper.set(McpServerEntity::getLastStatus, status);
|
||||||
update.setLastError(error);
|
wrapper.set(McpServerEntity::getLastError, error);
|
||||||
update.setToolCount(toolCount);
|
wrapper.set(McpServerEntity::getToolCount, toolCount);
|
||||||
if ("connected".equals(status)) {
|
if ("connected".equals(status)) {
|
||||||
update.setLastConnectedTime(LocalDateTime.now());
|
wrapper.set(McpServerEntity::getLastConnectedTime, LocalDateTime.now());
|
||||||
}
|
}
|
||||||
mcpServerMapper.updateById(update);
|
wrapper.set(McpServerEntity::getUpdateTime, LocalDateTime.now());
|
||||||
|
mcpServerMapper.update(null, wrapper);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to update MCP server status: {}", e.getMessage());
|
log.warn("Failed to update MCP server status: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user