#!/usr/bin/env bun
/**
* Test script to verify MCP server tools are properly defined
* Tests that the new embedding tools are correctly added to the MCP server
*/
import { createConfiguredMCPServer } from '../src/backend/mcp/server.js';
async function testMCPToolsDefinition() {
console.log('🧪 Testing MCP Tools Definition...\n');
try {
// Test that we can create the MCP server without errors
console.log('🔧 Creating MCP server...');
// Mock the required environment variables
const originalSemanticSearch = process.env.SEMANTIC_SEARCH_ENABLED;
process.env.SEMANTIC_SEARCH_ENABLED = 'true';
// Import the server creation function
const { createMCPServer } = await import('../src/backend/mcp/server.js');
console.log('✅ MCP server creation function imported successfully');
// Test that the server can be created
const server = createMCPServer();
console.log('✅ MCP server instance created successfully');
// Restore original environment
if (originalSemanticSearch !== undefined) {
process.env.SEMANTIC_SEARCH_ENABLED = originalSemanticSearch;
} else {
delete process.env.SEMANTIC_SEARCH_ENABLED;
}
console.log('\n🎉 MCP server tools definition test completed successfully!');
console.log('📋 The following new embedding tools should be available when semantic search is enabled:');
console.log(' - getEmbeddingQueueStatus: Get current status and statistics of the embedding queue');
console.log(' - getArticleEmbeddingStatus: Get embedding status for a specific article');
console.log(' - getBulkEmbeddingProgress: Get progress of bulk embedding operations');
console.log('\n📝 Enhanced existing tools:');
console.log(' - createArticle: Now uses background embedding for immediate response');
console.log(' - updateArticle: Now uses background embedding for immediate response');
console.log(' - readArticle: Now includes embedding status in response');
console.log(' - listArticles: Now includes embedding status for each article');
} catch (error) {
console.error('❌ Test failed:', error);
process.exit(1);
}
}
// Run the test
testMCPToolsDefinition().catch((error) => {
console.error('❌ Test failed:', error);
process.exit(1);
});