diff --git a/LinkToolAddin.csproj b/LinkToolAddin.csproj index 710c8a5..84f4b43 100644 --- a/LinkToolAddin.csproj +++ b/LinkToolAddin.csproj @@ -101,9 +101,10 @@ - + + - + diff --git a/client/PythonMcpClient.cs b/client/PythonMcpClient.cs new file mode 100644 index 0000000..e25e7d8 --- /dev/null +++ b/client/PythonMcpClient.cs @@ -0,0 +1,6 @@ +namespace LinkToolAddin.client; + +public class PythonMcpClient +{ + +} \ No newline at end of file diff --git a/client/SseMcpClient.cs b/client/SseMcpClient.cs new file mode 100644 index 0000000..2218e54 --- /dev/null +++ b/client/SseMcpClient.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using ModelContextProtocol.Client; +using ModelContextProtocol.Protocol.Transport; +using Newtonsoft.Json; + +namespace LinkToolAddin.client; + +public class SseMcpClient +{ + public static async Task testGaodeMcp() + { + Console.WriteLine("Connecting to 高德 MCP Server via SSE..."); + + // 创建 MCP Server 配置 + SseClientTransportOptions options = new SseClientTransportOptions + { + Endpoint = new Uri("https://mcp.amap.com/v1/sse"), + }; + + IClientTransport transport = new SseClientTransport(options);; + + // 创建 MCP Client + var client = await McpClientFactory.CreateAsync(transport); + Console.WriteLine("Connected to 高德 MCP Server"); + + try + { + // 获取可用工具列表 + var tools = await client.ListToolsAsync(); + Console.WriteLine("\nAvailable Tools:"); + foreach (var tool in tools) + { + Console.WriteLine($"- {tool.Name}: {tool.Description}"); + } + + // 示例调用:获取当前定位 + var result = await client.CallToolAsync("amap.maps_weather", new Dictionary{{"city","北京"}}); + Console.WriteLine("\n[amap.get_location] Result:"); + Console.WriteLine(result); + return JsonConvert.SerializeObject(result); + } + catch (Exception ex) + { + Console.WriteLine($"Error occurred: {ex.Message}"); + } + finally + { + await client.DisposeAsync(); + } + + Console.WriteLine("Client closed."); + return "failed"; + } +} \ No newline at end of file diff --git a/host/llm/entity/KnowldgeResult.cs b/host/llm/entity/KnowldgeResult.cs index 6480853..0937e30 100644 --- a/host/llm/entity/KnowldgeResult.cs +++ b/host/llm/entity/KnowldgeResult.cs @@ -36,7 +36,7 @@ namespace LinkToolAddin.host.llm.entity [JsonProperty("content", NullValueHandling = NullValueHandling.Ignore)] public string Content { get; set; } - [JsonProperty("conten_score_with_weight:0.6082842946052551\n【\ue000正\ue000文\ue000】\ue000:输\ue000出\ue000数\ue000据\ue000集\ue000将\ue000包\ue000含\ue000一\ue000个\ue000 BUFF_DIST 字\ue000段\ue000,\ue000该\ue000字\ue000段\ue000包\ue000含\ue000用\ue000于\ue000缓\ue000冲\ue000各\ue000要\ue000素\ue000的\ue000缓\ue000冲\ue000距\ue000离\ue000(\ue000使\ue000用\ue000输\ue000入\ue000要\ue000素\ue000坐\ue000标\ue000系\ue000的\ue000线\ue000性\ue000单\ue000位\ue000)\ue000。\ue000 如\ue000果\ue000已\ue000设\ue000置\ue000输\ue000出\ue000坐\ue000标\ue000系\ue000,\ue000则\ue000 BUFF_DIST 单\ue000位\ue000将\ue000位\ue000于\ue000该\ue000坐\ue000标\ue000系\ue000当\ue000中\ue000。\ue000输\ue000出\ue000ST 单\ue000位\ue000将\ue000位\ue000于\ue000该\ue000坐\ue000标\ue000系\ue000当\ue000中\ue000。\ue000 如\ue000果\ue000字\ue000段\ue000在\ue000输\ue000出\ue000中\ue000已\ue000存\ue000在\ue000,\ue000系\ue000统\ue000会\ue000在\ue000字\ue000段\ue000名\ue000称\ue000的\ue000结\ue000尾\ue000追\ue000加\ue000一\ue000个\ue000数\ue000字\ue000以\ue000确\ue000保\ue000其\ue000唯\ue000一\ue000性\ue000(\ue000例\ue000如\ue000,\ue000BUFF_DIST1)\ue000。\ue000您\ue000可\ue000以\ue000执\ue000行\ue000以\ue000下\ue000一\ue000项\ue000或\ue000多\ue000项\ue000操\ue000作\ue000来\ue000提\ue000高\ue000创\ue000建\ue000缓\ue000冲\ue000区\ue000工\ue000具\ue000的\ue000性\ue000能\ue000。\ue000设\ue000置\ue000范\ue000围\ue000环\ue000境\ue000,\ue000以\ue000便\ue000仅\ue000分\ue000析\ue000感\ue000兴\ue000趣\ue000的\ue000数\ue000据\ue000。\ue000使\ue000分\ue000析\ue000运\ue000行\ue000的\ue000位\ue000置\ue000。\ue000此\ue000地\ue000理\ue000处理工具由 ArcGIS GeoAnalytics Server 作为支持。 GeoAnalytics Server 上的分析已完成,结果将存储在 ArcGIS Enterprise 的内容中。当运行 GeoAnalytics Server 工具时,GeoAnalytics Server 上的分析已完成。entName", NullValueHandling = NullValueHandling.Ignore)] - public string ContenScoreWithWeight06082842946052551正文输出数据集将包含一个BuffDist字段该字段包含用于缓冲各要素的缓冲距离使用输入要素坐标系的线性单位如果已设置输出坐标系则BuffDist单位将位于该坐标系当中输出St单位将位于该坐标系当中如果字段在输出中已存在系统会在字段名称的结尾追加一个数字以确保其唯一性例如BuffDist1您可以执行以下一项或多项操作来提高创建缓冲区工具的性能设置范围环境以便仅分析感兴趣的数据使分析运行的位置此地理处理工具由ArcGisGeoAnalyticsServer作为支持GeoAnalyticsServer上的分析已完成结果将存储在ArcGisEnterprise的内容中当运行GeoAnalyticsServer工具时GeoAnalyticsServer上的分析已完成EntName { get; set; } + [JsonProperty("conten_score_with_weight", NullValueHandling = NullValueHandling.Ignore)] + public string ContenScoreWithWeight { get; set; } } } diff --git a/ui/dockpane/DialogDockpane.xaml.cs b/ui/dockpane/DialogDockpane.xaml.cs index 2e2d6b6..a939189 100644 --- a/ui/dockpane/DialogDockpane.xaml.cs +++ b/ui/dockpane/DialogDockpane.xaml.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging; using System.Text.Json; using System.Threading; using ArcGIS.Desktop.Core.Geoprocessing; +using LinkToolAddin.client; using LinkToolAddin.host.llm; using LinkToolAddin.host.llm.entity; using LinkToolAddin.resource; @@ -43,6 +44,13 @@ namespace LinkToolAddin.ui.dockpane } private async void TestServer_OnClick(object sender, RoutedEventArgs e) + { + log.Info("TestServer Clicked"); + string res = await SseMcpClient.testGaodeMcp(); + log.Info(res); + } + + private async void Retrieve_Test() { log.Info("TestServer Clicked"); // string jsonRpcString = @"{""jsonrpc"":""2.0"",""method"":""CallArcGISPro.CallArcGISProTool"",""params"":{""toolName"":""analysis.Buffer"",""toolParams"":""[\""D:/01_Development/02_ArcGIS_Pro_Project/20250319_GisAi/Test.gdb/河流\"",\""D:/01_Development/02_ArcGIS_Pro_Project/20250319_GisAi/Test.gdb/河流buffer\"",\""100\""]""},""id"":1}";