From 271f42dd71f0d27493cad709ae98057470349f48 Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Mon, 26 May 2025 00:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2MCP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/tool/KnowledgeBase.cs | 24 ++++++++++++++++++++++++ host/McpServerList.cs | 7 +++++++ resource/DocDb.cs | 5 +++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/client/tool/KnowledgeBase.cs b/client/tool/KnowledgeBase.cs index 9d2b162..38fe949 100644 --- a/client/tool/KnowledgeBase.cs +++ b/client/tool/KnowledgeBase.cs @@ -22,4 +22,28 @@ public class KnowledgeBase }; return result; } + + [McpServerTool, Description("查询ArcGIS Pro调用工具的标准调用名和参数要求知识库")] + public static async Task QueryArcgisToolDoc(string query) + { + DocDb docDb = new DocDb("sk-db177155677e438f832860e7f4da6afc", DocDb.KnowledgeBase.ArcGISProToolDoc); + KnowledgeResult knowledgeResult = await docDb.Retrieve(query); + JsonRpcResultEntity result = new JsonRpcSuccessEntity() + { + Result = JsonConvert.SerializeObject(knowledgeResult.ChunkList), + }; + return result; + } + + [McpServerTool, Description("查询使用ArcGIS Pro进行任务规划和解决实际问题的案例知识库")] + public static async Task QueryArcgisExampleDoc(string query) + { + DocDb docDb = new DocDb("sk-db177155677e438f832860e7f4da6afc", DocDb.KnowledgeBase.ArcGISProApplicantExample); + KnowledgeResult knowledgeResult = await docDb.Retrieve(query); + JsonRpcResultEntity result = new JsonRpcSuccessEntity() + { + Result = JsonConvert.SerializeObject(knowledgeResult.ChunkList), + }; + return result; + } } \ No newline at end of file diff --git a/host/McpServerList.cs b/host/McpServerList.cs index 2c03a41..68f83b4 100644 --- a/host/McpServerList.cs +++ b/host/McpServerList.cs @@ -28,6 +28,13 @@ public class McpServerList Description = "可以调用arcgis的地理处理工具或执行python代码等", IsActive = true }); + servers.Add("KnowledgeBase", new InnerMcpServer + { + Name = "KnowledgeBase", + Type = "inner", + Description = "可以调用进行查询知识库,获取相关参考信息。", + IsActive = true + }); } public McpServer GetServer(string name) diff --git a/resource/DocDb.cs b/resource/DocDb.cs index 1487b5e..f4937fe 100644 --- a/resource/DocDb.cs +++ b/resource/DocDb.cs @@ -21,13 +21,14 @@ public class DocDb { ArcGISProHelpDoc, ArcGISProToolDoc, - TaskPlanningDoc, ArcGISProApplicantExample } public Dictionary knowledgeBase = new Dictionary { - {KnowledgeBase.ArcGISProHelpDoc,"6a77c5a68de64f469b79fcdcde9d5001"} + {KnowledgeBase.ArcGISProHelpDoc,"6a77c5a68de64f469b79fcdcde9d5001"}, + {KnowledgeBase.ArcGISProToolDoc,"080f8925318247ea822a9e12db5cb5cd"}, + {KnowledgeBase.ArcGISProApplicantExample,"eef60f7c879b4e8597138c261578d2a5"} }; public async Task Retrieve(string query)