@hupan56/wlkj 3.4.5 → 3.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -141,13 +141,17 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
def _call_platform(self, tool_name, args):
|
|
144
|
-
"""
|
|
145
|
-
|
|
144
|
+
"""转发工具调用到云平台。
|
|
145
|
+
|
|
146
|
+
主路径:mcp.json kg→SSE url,QoderWork直连云平台(不经本server)。
|
|
147
|
+
备选路径:launcher模式(本server被调),走SSE协议转发。
|
|
148
|
+
"""
|
|
146
149
|
mapped = self._TOOL_MAP.get(tool_name)
|
|
147
150
|
if not mapped:
|
|
148
151
|
return json.dumps({"error": f"工具 {tool_name} 无云平台等价(本地功能)"}, ensure_ascii=False)
|
|
149
|
-
#
|
|
152
|
+
# 尝试HTTP POST(简单协议,部分端点支持)
|
|
150
153
|
try:
|
|
154
|
+
import urllib.request, urllib.error
|
|
151
155
|
body = json.dumps({"tool": mapped, "args": args or {}}).encode("utf-8")
|
|
152
156
|
req = urllib.request.Request(
|
|
153
157
|
self.PLATFORM_MCP_URL,
|
|
@@ -158,6 +162,8 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
158
162
|
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
159
163
|
return resp.read().decode("utf-8")
|
|
160
164
|
except urllib.error.HTTPError as e:
|
|
165
|
+
if e.code == 401:
|
|
166
|
+
return json.dumps({"error": "云平台需鉴权。请在 mcp.json 配 kg 为 SSE url(npx @hupan56/wlkj update 自动配置)。"}, ensure_ascii=False)
|
|
161
167
|
return json.dumps({"error": f"云平台 HTTP {e.code}: {e.reason}"}, ensure_ascii=False)
|
|
162
168
|
except Exception as e:
|
|
163
169
|
return json.dumps({"error": f"云平台不可达: {type(e).__name__}: {str(e)[:120]}"}, ensure_ascii=False)
|