#!/usr/bin/env node
/**
* Simple test script for Pollinations Think MCP Server
*/
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
function testMCPServer() {
console.log('🧪 Testing Pollinations Think MCP Server...');
const serverPath = join(__dirname, 'index.js');
const server = spawn('node', [serverPath], {
stdio: ['pipe', 'pipe', 'pipe']
});
let responseData = '';
server.stdout.on('data', (data) => {
responseData += data.toString();
});
server.stderr.on('data', (data) => {
console.error('Server error:', data.toString());
});
// Test the tools/list request
const listToolsRequest = {
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
};
// Send the request
server.stdin.write(JSON.stringify(listToolsRequest) + '\n');
// Wait for response
setTimeout(() => {
console.log('📋 Server Response:');
console.log(responseData);
// Test the think tool
const thinkRequest = {
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'think',
arguments: {
text: 'Should a small startup focus on growth or profitability first?',
thought_cycles: 2
}
}
};
console.log('\n🧠 Testing think tool...');
server.stdin.write(JSON.stringify(thinkRequest) + '\n');
// Wait for think response
setTimeout(() => {
console.log('\n✅ Test completed!');
console.log('If you see JSON responses above, the server is working correctly.');
server.kill();
}, 10000); // Wait 10 seconds for thinking to complete
}, 2000); // Wait 2 seconds for initial response
server.on('close', (code) => {
console.log(`\n🏁 Server process exited with code ${code}`);
});
}
// Run the test
testMCPServer();