#!/usr/bin/env node /** * Simple test client for Bitbucket MCP Server. * Tests the router and API client functionality. */ import { BitbucketRouter } from './dist/router.js'; const router = new BitbucketRouter(); console.log('🧪 Testing Bitbucket MCP Router\n'); // Test 1: List pull requests (will fail without valid token, but tests structure) console.log('Test 1: list_pull_requests'); try { const result = await router.executeTool('list_pull_requests', { workspace: 'test-workspace', repository: 'test-repo' }); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Expected error (no valid token):', error.message); } // Test 2: Get pull request console.log('\nTest 2: get_pull_request'); try { const result = await router.executeTool('get_pull_request', { workspace: 'test-workspace', repository: 'test-repo', pullRequestId: 12345 }); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Expected error (no valid token):', error.message); } // Test 3: Get PR status console.log('\nTest 3: get_pull_request_status'); try { const result = await router.executeTool('get_pull_request_status', { workspace: 'test-workspace', repository: 'test-repo', pullRequestId: 12345 }); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Expected error (no valid token):', error.message); } // Test 4: Get PR comments console.log('\nTest 4: get_pull_request_comments'); try { const result = await router.executeTool('get_pull_request_comments', { workspace: 'test-workspace', repository: 'test-repo', pullRequestId: 12345 }); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Expected error (no valid token):', error.message); } // Test 6: Invalid tool name console.log('\nTest 5: Unknown tool'); try { const result = await router.executeTool('invalid_tool', {}); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Error:', error.message); } // Test 5: Get PR activities console.log('\nTest 5: get_pull_request_activities'); try { const result = await router.executeTool('get_pull_request_activities', { workspace: 'test-workspace', repository: 'test-repo', pullRequestId: 12345 }); console.log('Result:', JSON.stringify(result, null, 2)); } catch (error) { console.log('Expected error (no valid token):', error.message); } console.log('\n✅ All tests completed!');