解决MCP服务出错影响主程序的问题
This commit is contained in:
parent
9b600174e8
commit
544bc8cd40
@ -24,7 +24,7 @@ public class ArcGisPro
|
|||||||
[McpServerTool, Description("可以通过调用ArcGIS Pro的地理处理工具实现一些数据处理功能,传入参数必须严格遵循ArcGIS Pro调用工具的标准调用名和参数要求知识库。")]
|
[McpServerTool, Description("可以通过调用ArcGIS Pro的地理处理工具实现一些数据处理功能,传入参数必须严格遵循ArcGIS Pro调用工具的标准调用名和参数要求知识库。")]
|
||||||
public static async Task<JsonRpcResultEntity> ArcGisProTool(string toolName, List<string> toolParams)
|
public static async Task<JsonRpcResultEntity> ArcGisProTool(string toolName, List<string> toolParams)
|
||||||
{
|
{
|
||||||
IGPResult results = await Geoprocessing.ExecuteToolAsync(toolName, toolParams);
|
IGPResult results = await Geoprocessing.ExecuteToolAsync(toolName, toolParams,null,null,null,GPExecuteToolFlags.InheritGPOptions|GPExecuteToolFlags.GPThread);
|
||||||
JsonRpcResultEntity jsonRpcResultEntity;
|
JsonRpcResultEntity jsonRpcResultEntity;
|
||||||
if (results.IsFailed)
|
if (results.IsFailed)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -636,7 +636,8 @@ public class Gateway
|
|||||||
private static async Task<string> GetToolInfos(McpServerList mcpServerList)
|
private static async Task<string> GetToolInfos(McpServerList mcpServerList)
|
||||||
{
|
{
|
||||||
StringBuilder toolInfos = new StringBuilder();
|
StringBuilder toolInfos = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
List<int> failedMcp = new List<int>();
|
||||||
foreach (McpServer mcpServer in mcpServerList.GetAllServers())
|
foreach (McpServer mcpServer in mcpServerList.GetAllServers())
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@ -715,7 +716,7 @@ public class Gateway
|
|||||||
}catch (Exception e)
|
}catch (Exception e)
|
||||||
{
|
{
|
||||||
log.Error(e.Message);
|
log.Error(e.Message);
|
||||||
MessageBox.Show(e.Message, $"第{i}MCP读取错误");
|
failedMcp.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,9 +732,9 @@ public class Gateway
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.Error(e.Message);
|
log.Error(e.Message);
|
||||||
MessageBox.Show(e.Message, $"{userPrompt.Name}提示词读取错误");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MessageBox.Show($"读取失败的MCP序号:{JsonConvert.SerializeObject(failedMcp)}","MCP读取错误");
|
||||||
return toolInfos.ToString();
|
return toolInfos.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user