dsh-skill-mcp 0.4.1 → 0.4.2
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/lib/client.js +3 -3
- package/lib/index.js +33 -10
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -22,8 +22,8 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
|
|
23
23
|
const INJECT = ["slots", "locale", "workspaces", "connection"];
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
const
|
|
25
|
+
/** dsh v0.1.5:浏览器侧统一走 /api 通道,endpoint 带插件前缀。 */
|
|
26
|
+
const RPC_PREFIX = "skill-mcp";
|
|
27
27
|
|
|
28
28
|
let hostCtx = null;
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ window.__ModuleLoader__.load({
|
|
|
32
32
|
* 返回的 value 保留业务形状({ok, message, ...})。
|
|
33
33
|
*/
|
|
34
34
|
async function callApi(endpoint, body = {}) {
|
|
35
|
-
const result = await hostCtx.connection.rpc.call(
|
|
35
|
+
const result = await hostCtx.connection.rpc.call("/api", `${RPC_PREFIX}/${endpoint}`, body);
|
|
36
36
|
if (result.ok) return result.value;
|
|
37
37
|
throw new Error(result.error?.message || `rpc ${endpoint} failed`);
|
|
38
38
|
}
|
package/lib/index.js
CHANGED
|
@@ -109,7 +109,7 @@ const USER_INVOCABLE_KEY = 'user-invocable'
|
|
|
109
109
|
const PIN_KEY = 'pinned'
|
|
110
110
|
|
|
111
111
|
// RPC 通道与按项目 MCP 的命名空间。
|
|
112
|
-
const
|
|
112
|
+
const RPC_PREFIX = 'skill-mcp' // 挂在 /api/<prefix>/<endpoint> 下的精确 POST 路由
|
|
113
113
|
const MCP_ENTRY_PREFIX = 'pmcp-'
|
|
114
114
|
const MCP_CLIENT_NAME = '@deepseek-ai/dsh-mcp-client'
|
|
115
115
|
|
|
@@ -879,7 +879,9 @@ async function saveMcpDisabled(disabled) {
|
|
|
879
879
|
// ---------------------------------------------------------------------------
|
|
880
880
|
|
|
881
881
|
export const name = 'dsh-skill-mcp'
|
|
882
|
-
|
|
882
|
+
// connection.rpc.handle 内部会通过本插件 ctx 访问 webServer 注册路由,
|
|
883
|
+
// 新版 cordis 对未声明 inject 的服务访问直接抛错(旧版静默 undefined)
|
|
884
|
+
export const inject = ['connection', 'loader', 'tools', 'webServer']
|
|
883
885
|
|
|
884
886
|
export function apply(ctx) {
|
|
885
887
|
// ---- MCP engine state ----
|
|
@@ -1225,15 +1227,36 @@ export function apply(ctx) {
|
|
|
1225
1227
|
},
|
|
1226
1228
|
}
|
|
1227
1229
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1230
|
+
// ---- RPC(dsh v0.1.5 新传输模型)----
|
|
1231
|
+
// 浏览器侧固定 POST /api/<endpoint>;/api 前缀路由由 core 挂载。插件用
|
|
1232
|
+
// connection.fetch.register 注册精确 POST 路由(优先于网关 interceptor,
|
|
1233
|
+
// 注册过程不碰 webServer,只需 inject connection)。信封:client-request
|
|
1234
|
+
// {rpcId,method,payload} → server-response {rpcId,result:{ok,value|error}}。
|
|
1235
|
+
const okResponse = (rpcId, result) => new Response(
|
|
1236
|
+
JSON.stringify({ type: 'server-response', rpcId, result }),
|
|
1237
|
+
{ status: 200, headers: { 'content-type': 'application/json' } },
|
|
1238
|
+
)
|
|
1239
|
+
ctx.inject(['connection'], (c) => {
|
|
1240
|
+
for (const [name, action] of Object.entries(endpoints)) {
|
|
1241
|
+
c.connection.fetch.register({
|
|
1242
|
+
path: `/api/${RPC_PREFIX}/${name}`,
|
|
1243
|
+
methods: ['POST'],
|
|
1244
|
+
requestBody: 'buffered',
|
|
1245
|
+
fetch: async (request) => {
|
|
1246
|
+
let rpcId = ''
|
|
1247
|
+
try {
|
|
1248
|
+
const msg = await request.json()
|
|
1249
|
+
rpcId = typeof msg?.rpcId === 'string' ? msg.rpcId : ''
|
|
1250
|
+
const value = await action.run(msg?.payload ?? {})
|
|
1251
|
+
return okResponse(rpcId, rpcOk(value))
|
|
1252
|
+
} catch (e) {
|
|
1253
|
+
return okResponse(rpcId, rpcFail(e?.message || String(e)))
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
})
|
|
1235
1257
|
}
|
|
1236
|
-
|
|
1258
|
+
console.log(`[dsh-skill-mcp] rpc routes ready under /api/${RPC_PREFIX} (${Object.keys(endpoints).length} endpoints)`)
|
|
1259
|
+
})
|
|
1237
1260
|
|
|
1238
1261
|
// 文件监听随插件卸载关闭。
|
|
1239
1262
|
ctx.effect(() => () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-skill-mcp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Management center: link skill directories into the user skills root (enable/disable/unlink/delete) and manage MCP servers — add/edit/delete, import from other agents (Claude Code/Codex/Cursor/Gemini CLI), auto-load each project's own MCP servers via the loader",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://github.com/LvanLa/deepseek-harness-ex/tree/master/plugins/dsh-skill-mcp",
|