-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtest-uuid-tag.js
More file actions
52 lines (42 loc) · 1.34 KB
/
test-uuid-tag.js
File metadata and controls
52 lines (42 loc) · 1.34 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
#!/usr/bin/env node
const axios = require('axios');
const crypto = require('crypto');
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 test() {
try {
// Use UUID for 100% uniqueness
const tagName = `Test${crypto.randomUUID().substring(0, 8)}`;
console.error(`[INFO] Creating tag with UUID: ${tagName}`);
const result = await callTool('create_tag', { name: tagName });
const tag = JSON.parse(result.content[0].text);
console.error('[SUCCESS] Tag created!');
console.error(JSON.stringify(tag, null, 2));
// Clean up
console.error(`\n[INFO] Deleting tag: ${tag.id}`);
await callTool('delete_tag', { id: tag.id });
console.error('[SUCCESS] Tag deleted');
} catch (error) {
console.error('[ERROR]', error.message);
}
}
test();