()
| 8 | import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; |
| 9 | |
| 10 | async function testConditionalTools() { |
| 11 | console.log('\n=== Test: Conditional Tool Registration ===\n'); |
| 12 | |
| 13 | // Test 1: Regular client (should include feedback tool) |
| 14 | console.log('Test 1: Testing with regular client (should include feedback tool)...'); |
| 15 | const regularClient = new Client( |
| 16 | { |
| 17 | name: "test-client", |
| 18 | version: "1.0.0" |
| 19 | }, |
| 20 | { |
| 21 | capabilities: {} |
| 22 | } |
| 23 | ); |
| 24 | |
| 25 | const regularTransport = new StdioClientTransport({ |
| 26 | command: "node", |
| 27 | args: ["../dist/index.js"] |
| 28 | }); |
| 29 | |
| 30 | await regularClient.connect(regularTransport); |
| 31 | const regularTools = await regularClient.listTools(); |
| 32 | |
| 33 | const hasFeedbackRegular = regularTools.tools.some(t => t.name === 'give_feedback_to_desktop_commander'); |
| 34 | console.log(` Tools count: ${regularTools.tools.length}`); |
| 35 | console.log(` Has give_feedback_to_desktop_commander: ${hasFeedbackRegular}`); |
| 36 | |
| 37 | if (hasFeedbackRegular) { |
| 38 | console.log(' ✅ PASS: Feedback tool is included for regular client'); |
| 39 | } else { |
| 40 | console.log(' ❌ FAIL: Feedback tool should be included for regular client'); |
| 41 | process.exit(1); |
| 42 | } |
| 43 | |
| 44 | await regularClient.close(); |
| 45 | |
| 46 | // Wait a bit between tests |
| 47 | await new Promise(resolve => setTimeout(resolve, 1000)); |
| 48 | |
| 49 | // Test 2: desktop-commander-app client (should exclude feedback tool and get_prompts) |
| 50 | console.log('\nTest 2: Testing with desktop-commander-app client (should exclude feedback tool and get_prompts)...'); |
| 51 | const dcClient = new Client( |
| 52 | { |
| 53 | name: "desktop-commander-app", |
| 54 | version: "1.0.0" |
| 55 | }, |
| 56 | { |
| 57 | capabilities: {} |
| 58 | } |
| 59 | ); |
| 60 | |
| 61 | const dcTransport = new StdioClientTransport({ |
| 62 | command: "node", |
| 63 | args: ["../dist/index.js"] |
| 64 | }); |
| 65 | |
| 66 | await dcClient.connect(dcTransport); |
| 67 | const dcTools = await dcClient.listTools(); |
no test coverage detected