- 新增 runtime MCP 声明、ClientFactory、Toolkit 适配与工具别名映射 - 增加 MCP 环境检测与 stdio 环境变量透传 - 补齐 MCP 工具事件、审批与生命周期释放测试
125 lines
2.5 KiB
Java
125 lines
2.5 KiB
Java
/*
|
|
* Copyright (c) 2023-2026, Easy-Agents (fuhai999@gmail.com).
|
|
* <p>
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
*/
|
|
package com.easyagents.mcp.client;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 单个 MCP Server 的检测结果。
|
|
*/
|
|
public class McpServerCheckResult {
|
|
|
|
private String serverName;
|
|
private String transport;
|
|
private McpCheckStatus status = McpCheckStatus.SUCCESS;
|
|
private int toolCount;
|
|
private List<McpCheckItem> checks = new ArrayList<>();
|
|
|
|
/**
|
|
* 添加检测项并刷新整体状态。
|
|
*
|
|
* @param item 检测项
|
|
*/
|
|
public void addCheck(McpCheckItem item) {
|
|
if (item == null) {
|
|
return;
|
|
}
|
|
this.checks.add(item);
|
|
this.status = McpEnvironmentCheckResult.mergeStatus(this.status, item.getStatus());
|
|
}
|
|
|
|
/**
|
|
* 获取 Server 名称。
|
|
*
|
|
* @return Server 名称
|
|
*/
|
|
public String getServerName() {
|
|
return serverName;
|
|
}
|
|
|
|
/**
|
|
* 设置 Server 名称。
|
|
*
|
|
* @param serverName Server 名称
|
|
*/
|
|
public void setServerName(String serverName) {
|
|
this.serverName = serverName;
|
|
}
|
|
|
|
/**
|
|
* 获取传输类型。
|
|
*
|
|
* @return 传输类型
|
|
*/
|
|
public String getTransport() {
|
|
return transport;
|
|
}
|
|
|
|
/**
|
|
* 设置传输类型。
|
|
*
|
|
* @param transport 传输类型
|
|
*/
|
|
public void setTransport(String transport) {
|
|
this.transport = transport;
|
|
}
|
|
|
|
/**
|
|
* 获取检测状态。
|
|
*
|
|
* @return 检测状态
|
|
*/
|
|
public McpCheckStatus getStatus() {
|
|
return status;
|
|
}
|
|
|
|
/**
|
|
* 设置检测状态。
|
|
*
|
|
* @param status 检测状态
|
|
*/
|
|
public void setStatus(McpCheckStatus status) {
|
|
this.status = status == null ? McpCheckStatus.SUCCESS : status;
|
|
}
|
|
|
|
/**
|
|
* 获取工具数量。
|
|
*
|
|
* @return 工具数量
|
|
*/
|
|
public int getToolCount() {
|
|
return toolCount;
|
|
}
|
|
|
|
/**
|
|
* 设置工具数量。
|
|
*
|
|
* @param toolCount 工具数量
|
|
*/
|
|
public void setToolCount(int toolCount) {
|
|
this.toolCount = Math.max(toolCount, 0);
|
|
}
|
|
|
|
/**
|
|
* 获取检测项。
|
|
*
|
|
* @return 检测项
|
|
*/
|
|
public List<McpCheckItem> getChecks() {
|
|
return checks;
|
|
}
|
|
|
|
/**
|
|
* 设置检测项。
|
|
*
|
|
* @param checks 检测项
|
|
*/
|
|
public void setChecks(List<McpCheckItem> checks) {
|
|
this.checks = checks == null ? new ArrayList<>() : new ArrayList<>(checks);
|
|
}
|
|
}
|