forked from MackDing/CodexClaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcpSkill.test.js
More file actions
92 lines (82 loc) · 2.19 KB
/
Copy pathmcpSkill.test.js
File metadata and controls
92 lines (82 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import test from "node:test";
import assert from "node:assert/strict";
import { McpSkill } from "../src/orchestrator/skills/mcpSkill.js";
function createSkill() {
return new McpSkill({
mcpClient: {
hasServers: () => true,
listServers: () => [
{
name: "context7",
enabled: true,
connected: true,
command: "npx",
args: ["-y", "@upstash/context7-mcp"],
cwd: process.cwd()
}
],
reconnectServer: async (name) => ({
name,
enabled: true,
connected: true
}),
enableServer: async (name) => ({
name,
enabled: true,
connected: true
}),
disableServer: async (name) => ({
name,
enabled: false,
connected: false
}),
listTools: async () => [],
callTool: async () => ""
}
});
}
test("mcp skill suggests the closest subcommand for small typos", async () => {
const skill = createSkill();
const result = await skill.execute({
text: "/mcp ststus"
});
assert.match(result.text, /\/mcp status/);
});
test("mcp skill returns expanded help text when no subcommand is provided", async () => {
const skill = createSkill();
const result = await skill.execute({
text: "/mcp"
});
assert.match(result.text, /\/mcp list/);
assert.match(result.text, /\/mcp status \[server\]/);
});
test("mcp skill returns idempotent enable feedback", async () => {
const skill = new McpSkill({
mcpClient: {
hasServers: () => true,
listServers: () => [],
reconnectServer: async () => null,
enableServer: async (name) => ({
name,
enabled: true,
connected: true,
changed: false
}),
disableServer: async () => null,
listTools: async () => [],
callTool: async () => ""
}
});
const result = await skill.execute({
text: "/mcp enable context7"
});
assert.match(result.text, /already enabled/);
});
test("mcp skill localizes output when locale is zh", async () => {
const skill = createSkill();
const result = await skill.execute({
text: "/mcp",
locale: "zh"
});
assert.match(result.text, /MCP 指令示例/);
});