test-tools.tsโข1.74 kB
#!/usr/bin/env node
import * as dotenv from 'dotenv';
// Load debug environment
dotenv.config({ path: '.env.debug' });
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
// Test specific tools
async function testTools() {
console.log('๐งช Testing MCP Tools...\n');
// Initialize server
const server = new McpServer({
name: 'agentjobs-mcp-test',
version: 'test'
});
// Load tools
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const toolsDir = path.join(__dirname, 'tools');
try {
const toolFiles = await fs.readdir(toolsDir);
console.log(`๐ Found ${toolFiles.length} tool files`);
for (const file of toolFiles) {
if (file.endsWith('.js')) {
try {
console.log(`โ๏ธ Loading tool: ${file}`);
const toolModule = await import(`./tools/${file}`);
if (typeof toolModule.default === 'function') {
toolModule.default(server);
console.log(`โ
Successfully registered: ${file}`);
} else {
console.log(`โ Invalid tool format: ${file}`);
}
} catch (error: any) {
console.log(`โ Error loading ${file}:`, error?.message || error);
}
}
}
// Show success message
console.log('\nโ
Tool testing completed!');
console.log('๐ก To run in debug mode: MCP_DEBUG=true npm run debug');
} catch (error) {
console.error('โ Error during tool testing:', error);
}
}
// Run if this script is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
testTools().catch(console.error);
}
export { testTools };