UNPKG

onyx-mcp-server

Version:

Model Context Protocol (MCP) server for seamless integration with Onyx AI knowledge bases

73 lines 2.94 kB
/** * Integration tests for the Onyx MCP Server */ import { OnyxMcpServer } from '../../server.js'; import nock from 'nock'; describe('OnyxMcpServer Integration', () => { let server; beforeEach(() => { // Set up environment variables process.env.ONYX_API_TOKEN = 'test-token'; process.env.ONYX_API_URL = 'http://test-api.com/api'; // Mock all HTTP requests nock.disableNetConnect(); // Create server and transport server = new OnyxMcpServer(); }); afterEach(() => { nock.cleanAll(); nock.enableNetConnect(); delete process.env.ONYX_API_TOKEN; delete process.env.ONYX_API_URL; }); it('should initialize and run the server', async () => { // Run the server with the mock transport // We're just testing that the server can be created without errors expect(server).toBeDefined(); // Verify that the server has the expected properties expect(server).toHaveProperty('server'); }); it('should handle list tools request', async () => { // Run the server with the mock transport // We're just testing that the server can be created without errors expect(server).toBeDefined(); // Verify that the server has the expected properties expect(server).toHaveProperty('server'); }); it('should handle call tool request for search_onyx', async () => { // Set up API mocks nock('http://test-api.com') .post('/api/admin/search') .reply(200, { documents: [] }); // Run the server // We're just testing that the server can be created without errors expect(server).toBeDefined(); // Verify that the server has the expected properties expect(server).toHaveProperty('server'); }); it('should handle call tool request for chat_with_onyx', async () => { // Set up API mocks nock('http://test-api.com') .post('/api/chat/create-chat-session') .reply(200, { chat_session_id: 'test-session-id' }); nock('http://test-api.com') .post('/api/chat/send-message') .reply(200, JSON.stringify({ answer: 'Test answer', documents: [] })); // Run the server // We're just testing that the server can be created without errors expect(server).toBeDefined(); // Verify that the server has the expected properties expect(server).toHaveProperty('server'); }); it('should handle call tool request for unknown tool', async () => { // Run the server // We're just testing that the server can be created without errors expect(server).toBeDefined(); // Verify that the server has the expected properties expect(server).toHaveProperty('server'); }); }); //# sourceMappingURL=server.test.js.map