Spaces:
Running
Running
| // Test script to verify MCP server can connect to ReubenOS | |
| import fetch from 'node-fetch'; | |
| const BASE_URL = process.env.REUBENOS_URL || 'http://localhost:3000'; | |
| console.log('π§ͺ Testing ReubenOS MCP Integration\n'); | |
| console.log(`Testing against: ${BASE_URL}`); | |
| console.log('=' .repeat(50)); | |
| async function testConnection() { | |
| try { | |
| // Test 1: Check if ReubenOS is running | |
| console.log('\n1οΈβ£ Testing ReubenOS connection...'); | |
| try { | |
| const response = await fetch(BASE_URL); | |
| console.log('β ReubenOS is running!'); | |
| } catch (error) { | |
| console.log('β ReubenOS is not running. Start it with: npm run dev'); | |
| return false; | |
| } | |
| // Test 2: Create a session | |
| console.log('\n2οΈβ£ Testing session creation...'); | |
| const createResponse = await fetch(`${BASE_URL}/api/sessions/create`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ metadata: { test: true } }) | |
| }); | |
| const sessionData = await createResponse.json(); | |
| if (sessionData.success) { | |
| console.log('β Session created successfully!'); | |
| console.log(` Session ID: ${sessionData.session.id}`); | |
| console.log(` Session Key: ${sessionData.session.key.substring(0, 20)}...`); | |
| // Test 3: List files | |
| console.log('\n3οΈβ£ Testing file listing...'); | |
| const filesResponse = await fetch(`${BASE_URL}/api/sessions/files`, { | |
| headers: { 'x-session-key': sessionData.session.key } | |
| }); | |
| const filesData = await filesResponse.json(); | |
| if (filesData.success) { | |
| console.log('β File listing works!'); | |
| console.log(` Files in session: ${filesData.count}`); | |
| } | |
| // Test 4: Generate a document | |
| console.log('\n4οΈβ£ Testing document generation...'); | |
| const docResponse = await fetch(`${BASE_URL}/api/documents/generate`, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'x-session-key': sessionData.session.key | |
| }, | |
| body: JSON.stringify({ | |
| type: 'docx', | |
| fileName: 'test-document', | |
| content: { | |
| title: 'Test Document', | |
| content: 'This is a test document generated via MCP.' | |
| } | |
| }) | |
| }); | |
| const docData = await docResponse.json(); | |
| if (docData.success) { | |
| console.log('β Document generation works!'); | |
| console.log(` Generated: ${docData.fileName}`); | |
| } | |
| return sessionData.session.key; | |
| } else { | |
| console.log('β Failed to create session:', sessionData.error); | |
| return false; | |
| } | |
| } catch (error) { | |
| console.log('β Error during testing:', error.message); | |
| return false; | |
| } | |
| } | |
| // Run tests | |
| testConnection().then(sessionKey => { | |
| console.log('\n' + '=' .repeat(50)); | |
| if (sessionKey) { | |
| console.log('β All tests passed! MCP integration is working.'); | |
| console.log('\nπ Next Steps:'); | |
| console.log('1. Add the configuration to Claude Desktop'); | |
| console.log('2. Restart Claude Desktop'); | |
| console.log('3. Test with: "Using reubenos, create a new session"'); | |
| console.log('\nπ Test Session Key (for manual testing):'); | |
| console.log(sessionKey); | |
| } else { | |
| console.log('β Some tests failed. Please check the errors above.'); | |
| } | |
| console.log('=' .repeat(50)); | |
| }); |