-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathdebug-tags.js
More file actions
66 lines (55 loc) · 1.91 KB
/
debug-tags.js
File metadata and controls
66 lines (55 loc) · 1.91 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
#!/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 debug() {
try {
// List all tags
console.error('[INFO] Fetching all tags...');
const result = await callTool('get_tags', { limit: 100 });
const data = JSON.parse(result.content[0].text);
console.error('\n[INFO] All tags in system:');
console.error(JSON.stringify(data, null, 2));
// Try to create a test tag
console.error('\n[INFO] Attempting to create a test tag...');
const tagName = `TagTest_${Date.now()}_${Math.random().toString(36).substring(7)}`;
console.error(`[INFO] Tag name: ${tagName}`);
try {
const createResult = await callTool('create_tag', { name: tagName });
const tag = JSON.parse(createResult.content[0].text);
console.error('[SUCCESS] Tag created successfully!');
console.error(JSON.stringify(tag, null, 2));
// Clean up
console.error('\n[INFO] Cleaning up test tag...');
await callTool('delete_tag', { id: tag.id });
console.error('[SUCCESS] Test tag deleted');
} catch (error) {
console.error('[ERROR] Failed to create tag:');
console.error(error.message);
console.error('\nFull error:', error);
}
} catch (error) {
console.error(`[ERROR] Debug failed: ${error.message}`);
process.exit(1);
}
}
debug();