@liveauth-labs/mcp-server 0.1.0 → 0.6.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/README.md +184 -46
- package/TEST_SUMMARY.md +95 -0
- package/dist/index.js +281 -64
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +372 -0
- package/dist/index.test.js.map +1 -0
- package/package.json +8 -3
- package/src/index.test.ts +437 -0
- package/src/index.ts +375 -90
- package/test/manual-test.md +78 -0
- package/test/test-flow.js +126 -0
- package/test/test-server.js +125 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Start the MCP server
|
|
11
|
+
const serverPath = join(__dirname, '../dist/index.js');
|
|
12
|
+
const server = spawn('node', [serverPath], {
|
|
13
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
|
+
env: { ...process.env }
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
let responses = [];
|
|
18
|
+
|
|
19
|
+
server.stdout.on('data', (data) => {
|
|
20
|
+
const lines = data.toString().split('\n').filter(l => l.trim());
|
|
21
|
+
lines.forEach(line => {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(line);
|
|
24
|
+
responses.push(parsed);
|
|
25
|
+
console.log('Response:', JSON.stringify(parsed, null, 2));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// Not JSON
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
server.stderr.on('data', (data) => {
|
|
33
|
+
console.log('Server stderr:', data.toString());
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Send initialize request
|
|
37
|
+
const initRequest = {
|
|
38
|
+
jsonrpc: '2.0',
|
|
39
|
+
id: 1,
|
|
40
|
+
method: 'initialize',
|
|
41
|
+
params: {
|
|
42
|
+
protocolVersion: '2024-11-05',
|
|
43
|
+
capabilities: {},
|
|
44
|
+
clientInfo: {
|
|
45
|
+
name: 'test-client',
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
console.log('\n=== Test 1: Initialize ===');
|
|
52
|
+
server.stdin.write(JSON.stringify(initRequest) + '\n');
|
|
53
|
+
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
// Test liveauth_mcp_start (the correct tool name)
|
|
56
|
+
const startRequest = {
|
|
57
|
+
jsonrpc: '2.0',
|
|
58
|
+
id: 2,
|
|
59
|
+
method: 'tools/call',
|
|
60
|
+
params: {
|
|
61
|
+
name: 'liveauth_mcp_start',
|
|
62
|
+
arguments: {},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
console.log('\n=== Test 2: Start MCP Session (PoW) ===');
|
|
67
|
+
server.stdin.write(JSON.stringify(startRequest) + '\n');
|
|
68
|
+
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
const startResponse = responses.find(r => r.id === 2);
|
|
71
|
+
if (startResponse && startResponse.result && !startResponse.result.isError) {
|
|
72
|
+
try {
|
|
73
|
+
const content = startResponse.result.content[0].text;
|
|
74
|
+
const result = JSON.parse(content);
|
|
75
|
+
|
|
76
|
+
if (result.powChallenge) {
|
|
77
|
+
console.log('\n✅ PoW Challenge received!');
|
|
78
|
+
console.log(` Difficulty: ${result.powChallenge.difficultyBits} bits`);
|
|
79
|
+
console.log(` Expires: ${new Date(result.powChallenge.expiresAtUnix * 1000)}`);
|
|
80
|
+
} else if (result.invoice) {
|
|
81
|
+
console.log('\n✅ Lightning invoice received!');
|
|
82
|
+
console.log(` Amount: ${result.invoice.amountSats} sats`);
|
|
83
|
+
console.log(` Invoice: ${result.invoice.bolt11.substring(0, 50)}...`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Now test status
|
|
87
|
+
const statusRequest = {
|
|
88
|
+
jsonrpc: '2.0',
|
|
89
|
+
id: 3,
|
|
90
|
+
method: 'tools/call',
|
|
91
|
+
params: {
|
|
92
|
+
name: 'liveauth_mcp_status',
|
|
93
|
+
arguments: { quoteId: result.quoteId },
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
console.log('\n=== Test 3: Check Status ===');
|
|
98
|
+
server.stdin.write(JSON.stringify(statusRequest) + '\n');
|
|
99
|
+
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.log('❌ Failed to parse response:', e.message);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
console.log('❌ Start request failed');
|
|
105
|
+
console.log(startResponse);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
const statusResponse = responses.find(r => r.id === 3);
|
|
110
|
+
if (statusResponse && statusResponse.result && !statusResponse.result.isError) {
|
|
111
|
+
console.log('\n✅ Status check worked!');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log('\n=== Test Complete ===');
|
|
115
|
+
server.kill();
|
|
116
|
+
process.exit(0);
|
|
117
|
+
}, 2000);
|
|
118
|
+
|
|
119
|
+
}, 2000);
|
|
120
|
+
}, 1000);
|
|
121
|
+
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
console.log('\n⏱️ Test timeout - killing server');
|
|
124
|
+
server.kill();
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}, 15000);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Start the MCP server
|
|
11
|
+
const serverPath = join(__dirname, '../dist/index.js');
|
|
12
|
+
const server = spawn('node', [serverPath], {
|
|
13
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
let responses = [];
|
|
17
|
+
|
|
18
|
+
server.stdout.on('data', (data) => {
|
|
19
|
+
const lines = data.toString().split('\n').filter(l => l.trim());
|
|
20
|
+
lines.forEach(line => {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(line);
|
|
23
|
+
responses.push(parsed);
|
|
24
|
+
console.log('Response:', JSON.stringify(parsed, null, 2));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
// Not JSON, probably stderr message
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
server.stderr.on('data', (data) => {
|
|
32
|
+
console.log('Server stderr:', data.toString());
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Send initialize request
|
|
36
|
+
const initRequest = {
|
|
37
|
+
jsonrpc: '2.0',
|
|
38
|
+
id: 1,
|
|
39
|
+
method: 'initialize',
|
|
40
|
+
params: {
|
|
41
|
+
protocolVersion: '2024-11-05',
|
|
42
|
+
capabilities: {},
|
|
43
|
+
clientInfo: {
|
|
44
|
+
name: 'test-client',
|
|
45
|
+
version: '1.0.0',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
console.log('\n=== Test 1: Initialize ===');
|
|
51
|
+
server.stdin.write(JSON.stringify(initRequest) + '\n');
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
// List tools
|
|
55
|
+
const listToolsRequest = {
|
|
56
|
+
jsonrpc: '2.0',
|
|
57
|
+
id: 2,
|
|
58
|
+
method: 'tools/list',
|
|
59
|
+
params: {},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
console.log('\n=== Test 2: List Tools ===');
|
|
63
|
+
server.stdin.write(JSON.stringify(listToolsRequest) + '\n');
|
|
64
|
+
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
// Test get_challenge with demo public key
|
|
67
|
+
const getChallengeRequest = {
|
|
68
|
+
jsonrpc: '2.0',
|
|
69
|
+
id: 3,
|
|
70
|
+
method: 'tools/call',
|
|
71
|
+
params: {
|
|
72
|
+
name: 'liveauth_get_challenge',
|
|
73
|
+
arguments: {
|
|
74
|
+
projectPublicKey: 'la_pk_wajRhFpfdc-cnS9Ekj6Otk4m',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
console.log('\n=== Test 3: Get Challenge ===');
|
|
80
|
+
server.stdin.write(JSON.stringify(getChallengeRequest) + '\n');
|
|
81
|
+
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
console.log('\n=== Test Results ===');
|
|
84
|
+
console.log(`Total responses: ${responses.length}`);
|
|
85
|
+
|
|
86
|
+
const toolsResponse = responses.find(r => r.id === 2);
|
|
87
|
+
if (toolsResponse && toolsResponse.result && toolsResponse.result.tools) {
|
|
88
|
+
console.log(`✅ Tools listed: ${toolsResponse.result.tools.length} tools`);
|
|
89
|
+
toolsResponse.result.tools.forEach(tool => {
|
|
90
|
+
console.log(` - ${tool.name}`);
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
console.log('❌ Failed to list tools');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const challengeResponse = responses.find(r => r.id === 3);
|
|
97
|
+
if (challengeResponse && challengeResponse.result) {
|
|
98
|
+
console.log('✅ Challenge request successful');
|
|
99
|
+
try {
|
|
100
|
+
const content = challengeResponse.result.content[0].text;
|
|
101
|
+
const challenge = JSON.parse(content);
|
|
102
|
+
console.log(` Challenge difficulty: ${challenge.difficultyBits} bits`);
|
|
103
|
+
console.log(` Target: ${challenge.targetHex.substring(0, 20)}...`);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
console.log(' Response:', JSON.stringify(challengeResponse.result, null, 2));
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
console.log('❌ Challenge request failed');
|
|
109
|
+
if (challengeResponse) {
|
|
110
|
+
console.log(' Error:', JSON.stringify(challengeResponse, null, 2));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log('\n✅ MCP server is responding correctly!');
|
|
115
|
+
server.kill();
|
|
116
|
+
process.exit(0);
|
|
117
|
+
}, 2000);
|
|
118
|
+
}, 1000);
|
|
119
|
+
}, 1000);
|
|
120
|
+
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
console.log('\n⏱️ Test timeout - killing server');
|
|
123
|
+
server.kill();
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}, 10000);
|
package/tsconfig.json
CHANGED