Skip to main content
Glama
server.test.ts2.73 kB
/** * Integration tests for the Onyx MCP Server */ import { OnyxMcpServer } from '../../server.js'; import nock from 'nock'; describe('OnyxMcpServer Integration', () => { let server: OnyxMcpServer; 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'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lupuletic/onyx-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server