-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathcleanup-validtest-tags.js
More file actions
65 lines (53 loc) · 1.78 KB
/
cleanup-validtest-tags.js
File metadata and controls
65 lines (53 loc) · 1.78 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
#!/usr/bin/env node
const axios = require('axios');
const mcpServerUrl = 'http://localhost:3456/mcp';
let requestId = 1;
async function sendMcpRequest(method, params = {}) {
const response = await axios.post(mcpServerUrl, {
jsonrpc: '2.0',
id: requestId++,
method,
params
});
return response.data.result;
}
async function callTool(name, args = {}) {
const result = await sendMcpRequest('tools/call', { name, arguments: args });
if (result.isError) {
const errorMessage = result.content && result.content[0] && result.content[0].text
? result.content[0].text
: 'Unknown error';
throw new Error(errorMessage);
}
return result;
}
async function cleanup() {
try {
console.error('[INFO] Fetching all tags...');
const result = await callTool('get_tags', { limit: 100 });
const data = JSON.parse(result.content[0].text);
const tags = data.data || [];
console.error(`[INFO] Found ${tags.length} total tags`);
const validTestTags = tags.filter(tag => tag.name.startsWith('ValidTest'));
console.error(`[INFO] Found ${validTestTags.length} ValidTest tags to delete`);
if (validTestTags.length === 0) {
console.error('[INFO] No ValidTest tags to clean up');
return;
}
let deleted = 0;
for (const tag of validTestTags) {
try {
await callTool('delete_tag', { id: tag.id });
deleted++;
console.error(`[SUCCESS] Deleted tag: ${tag.name} (${tag.id})`);
} catch (error) {
console.error(`[ERROR] Failed to delete tag ${tag.name}: ${error.message}`);
}
}
console.error(`[SUCCESS] Cleaned up ${deleted}/${validTestTags.length} ValidTest tags`);
} catch (error) {
console.error(`[ERROR] Cleanup failed: ${error.message}`);
process.exit(1);
}
}
cleanup();