import fs from 'fs';
import path from 'path';
/**
* ToolDiscoveryService
* Scans for available servers and their tools, returning metadata for context generation.
* In a real implementation, this would query Claude or the local environment for installed tools.
*/
export interface DiscoveredTool {
name: string;
description: string;
triggerKeywords: string[];
server: string;
}
export class ToolDiscoveryService {
/**
* Discover all available tools and their metadata.
* @returns Array of discovered tools
*/
public discoverTools(): DiscoveredTool[] {
const configPath = path.join(process.cwd(), 'tools.config.json');
try {
if (fs.existsSync(configPath)) {
const content = fs.readFileSync(configPath, 'utf8');
return JSON.parse(content) as DiscoveredTool[];
} else {
console.error(`Tool configuration file not found at ${configPath}. Returning empty list.`);
return [];
}
} catch (error) {
console.error(`Error reading or parsing tool configuration file: ${error instanceof Error ? error.message : String(error)}`);
return []; // Return empty list on error
}
}
}