试图接入MCP失败
This commit is contained in:
parent
0f0f2e5a92
commit
947ea3c818
@ -101,9 +101,10 @@
|
||||
<PackageReference Include="AlibabaCloud.SDK.Bailian20231229" Version="2.0.6" />
|
||||
<PackageReference Include="log4net" Version="3.1.0-preview.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.3.25171.5" />
|
||||
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.12" />
|
||||
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.13" />
|
||||
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.13" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Text.Json" Version="10.0.0-preview.3.25171.5" />
|
||||
<PackageReference Include="System.Text.Json" Version="10.0.0-preview.4.25258.110" />
|
||||
</ItemGroup>
|
||||
<Import Project="C:\Users\PeterZhong\AppData\Local\Programs\ArcGIS\Pro\bin\Esri.ProApp.SDK.Desktop.targets" Condition="Exists('C:\Users\PeterZhong\AppData\Local\Programs\ArcGIS\Pro\bin\Esri.ProApp.SDK.Desktop.targets') AND !Exists('Esri.ArcGISPro.Extensions.targets')" />
|
||||
</Project>
|
||||
|
||||
6
client/PythonMcpClient.cs
Normal file
6
client/PythonMcpClient.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace LinkToolAddin.client;
|
||||
|
||||
public class PythonMcpClient
|
||||
{
|
||||
|
||||
}
|
||||
56
client/SseMcpClient.cs
Normal file
56
client/SseMcpClient.cs
Normal file
@ -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<string> 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<string, object>{{"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";
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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}";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user