phinix_experience 0.0.1
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/.claude/settings.local.json +9 -0
- package/README.md +149 -0
- package/debug-client.js +55 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +60 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/searchExperience.d.ts +20 -0
- package/dist/tools/searchExperience.d.ts.map +1 -0
- package/dist/tools/searchExperience.js +133 -0
- package/dist/tools/searchExperience.js.map +1 -0
- package/mcp-config.json +10 -0
- package/package.json +44 -0
- package/quick-test.js +61 -0
- package/remote-install.sh +572 -0
- package/src/index.js +4 -0
- package/src/server.js +85 -0
- package/src/tools/index.js +7 -0
- package/src/tools/searchExperience.js +148 -0
- package/test-mcp.sh +13 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// 跳过内网 TLS 证书验证
|
|
4
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
5
|
+
|
|
6
|
+
const API_URL = "https://giti.lydaas.com/api/ai/exp/rag";
|
|
7
|
+
const APP_ID = process.env.APP_ID;
|
|
8
|
+
const DETAIL_BASE_URL = "https://giti.lydaas.com/api/ai/exp/detail";
|
|
9
|
+
|
|
10
|
+
export const searchExperienceListSchema = {
|
|
11
|
+
query: z.string().describe("搜索查询词,描述当前任务或问题"),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function searchExperienceList(params) {
|
|
15
|
+
try {
|
|
16
|
+
const { query } = params;
|
|
17
|
+
|
|
18
|
+
const response = await fetch(API_URL, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
appId: APP_ID,
|
|
25
|
+
query,
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
|
|
35
|
+
if (data.code !== 200 || !data.data) {
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: "text",
|
|
40
|
+
text: data.message || `未找到与「${query}」相关的经验记录。`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const text = data.data.output?.text;
|
|
47
|
+
|
|
48
|
+
let output = [];
|
|
49
|
+
try {
|
|
50
|
+
output = JSON.parse(text);
|
|
51
|
+
} catch {
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: `未找到与「${query}」相关的经验记录。`,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!Array.isArray(output) || output.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: `未找到与「${query}」相关的经验记录。`,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: "text",
|
|
77
|
+
text: JSON.stringify(output),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: `经验检索失败: ${error.message}`,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const searchExperienceDetailSchema = {
|
|
94
|
+
id: z.number().describe("经验的唯一ID"),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export async function searchExperienceDetail(params) {
|
|
98
|
+
try {
|
|
99
|
+
const { id } = params;
|
|
100
|
+
|
|
101
|
+
const response = await fetch(`${DETAIL_BASE_URL}/${id}`);
|
|
102
|
+
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
if (response.status === 404) {
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: `未找到 id=${id} 的经验`,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const result = await response.json();
|
|
118
|
+
|
|
119
|
+
if (result.code !== 200 || !result.data) {
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: result.message || `未找到 id=${id} 的经验`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
content: [
|
|
132
|
+
{
|
|
133
|
+
type: "text",
|
|
134
|
+
text: JSON.stringify(result.data),
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return {
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: "text",
|
|
143
|
+
text: `经验详情获取失败: ${error.message}`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
package/test-mcp.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
echo "测试 phinix_experience MCP服务器..."
|
|
4
|
+
|
|
5
|
+
# 启动服务器并测试
|
|
6
|
+
echo "1. 测试获取工具列表:"
|
|
7
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | node src/index.js
|
|
8
|
+
|
|
9
|
+
echo -e "\n\n2. 测试经验检索:"
|
|
10
|
+
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_experience_list","arguments":{"query":"scss 样式"}}}' | node src/index.js
|
|
11
|
+
|
|
12
|
+
echo -e "\n\n3. 测试经验详情:"
|
|
13
|
+
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"search_experience_detail","arguments":{"id":1}}}' | node src/index.js
|