@rashidazarang/aptly-mcp
Version:
Model Context Protocol server for Aptly package repository management - enables AI assistants to manage Debian repositories
106 lines โข 4.48 kB
JavaScript
/**
* Test script for Aptly MCP Server
* Run with: npm run build && node build/test.js
*/
import { AptlyClient } from './utils/aptly-client.js';
const APTLY_URL = process.env.APTLY_API_URL || 'http://localhost:8080';
async function testAptlyConnection() {
console.log('๐งช Testing Aptly MCP Server Components');
console.log('======================================\n');
const client = new AptlyClient({
baseURL: APTLY_URL,
authToken: process.env.APTLY_AUTH_TOKEN
});
// Test 1: Health check
console.log('1. Testing Aptly server connection...');
try {
const isHealthy = await client.ping();
console.log(` ${isHealthy ? 'โ
' : 'โ'} Health check: ${isHealthy ? 'PASS' : 'FAIL'}`);
if (!isHealthy) {
console.log(' ๐ก Make sure Aptly is running: aptly api serve -listen=":8080"');
return;
}
}
catch (error) {
console.log(` โ Connection failed: ${error instanceof Error ? error.message : String(error)}`);
return;
}
// Test 2: List repositories
console.log('\n2. Testing repository listing...');
try {
const repos = await client.listRepositories();
console.log(` โ
Found ${repos.length} repository(ies)`);
repos.forEach(repo => {
console.log(` - ${repo.Name}${repo.Comment ? ` (${repo.Comment})` : ''}`);
});
}
catch (error) {
console.log(` โ Repository listing failed: ${error instanceof Error ? error.message : String(error)}`);
}
// Test 3: List mirrors
console.log('\n3. Testing mirror listing...');
try {
const mirrors = await client.listMirrors();
console.log(` โ
Found ${mirrors.length} mirror(s)`);
mirrors.forEach(mirror => {
console.log(` - ${mirror.Name}: ${mirror.ArchiveRoot} (${mirror.Distribution})`);
});
}
catch (error) {
console.log(` โ Mirror listing failed: ${error instanceof Error ? error.message : String(error)}`);
}
// Test 4: List snapshots
console.log('\n4. Testing snapshot listing...');
try {
const snapshots = await client.listSnapshots();
console.log(` โ
Found ${snapshots.length} snapshot(s)`);
snapshots.forEach(snapshot => {
const createdDate = new Date(snapshot.CreatedAt).toLocaleDateString();
console.log(` - ${snapshot.Name}: ${snapshot.Description} (${createdDate})`);
});
}
catch (error) {
console.log(` โ Snapshot listing failed: ${error instanceof Error ? error.message : String(error)}`);
}
// Test 5: List published repositories
console.log('\n5. Testing published repository listing...');
try {
const published = await client.listPublishedRepositories();
console.log(` โ
Found ${published.length} published repository(ies)`);
published.forEach(pub => {
const endpoint = pub.Prefix ? `${pub.Prefix}/${pub.Distribution}` : pub.Distribution;
console.log(` - ${endpoint} (${pub.SourceKind})`);
});
}
catch (error) {
console.log(` โ Published repository listing failed: ${error instanceof Error ? error.message : String(error)}`);
}
// Test 6: List uploaded files
console.log('\n6. Testing file upload listing...');
try {
const files = await client.listUploadedFiles();
const dirCount = Object.keys(files).length;
console.log(` โ
Found ${dirCount} upload directory(ies)`);
for (const [dir, fileList] of Object.entries(files)) {
console.log(` - ${dir}: ${fileList.length} file(s)`);
fileList.forEach(file => {
console.log(` * ${file.filename} (${file.size} bytes)`);
});
}
}
catch (error) {
console.log(` โ File listing failed: ${error instanceof Error ? error.message : String(error)}`);
}
console.log('\n๐ All tests completed!');
console.log('\nThe Aptly MCP server is ready for use with Claude Desktop.');
console.log('Add the server to your Claude Desktop configuration to start using it.');
}
// Run tests if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
testAptlyConnection().catch((error) => {
console.error('Test failed:', error);
process.exit(1);
});
}
//# sourceMappingURL=test.js.map