@iflow-mcp/lupuletic-onyx-mcp-server 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/LICENSE +21 -0
  3. package/README.md +314 -0
  4. package/build/__tests__/config/config.test.d.ts +1 -0
  5. package/build/__tests__/config/config.test.js +56 -0
  6. package/build/__tests__/config/config.test.js.map +1 -0
  7. package/build/__tests__/index.test.d.ts +1 -0
  8. package/build/__tests__/index.test.js +25 -0
  9. package/build/__tests__/index.test.js.map +1 -0
  10. package/build/__tests__/integration/server.test.d.ts +1 -0
  11. package/build/__tests__/integration/server.test.js +73 -0
  12. package/build/__tests__/integration/server.test.js.map +1 -0
  13. package/build/__tests__/services/onyxApi.test.d.ts +1 -0
  14. package/build/__tests__/services/onyxApi.test.js +317 -0
  15. package/build/__tests__/services/onyxApi.test.js.map +1 -0
  16. package/build/__tests__/tools/tools.test.d.ts +1 -0
  17. package/build/__tests__/tools/tools.test.js +177 -0
  18. package/build/__tests__/tools/tools.test.js.map +1 -0
  19. package/build/config/index.d.ts +20 -0
  20. package/build/config/index.js +26 -0
  21. package/build/config/index.js.map +1 -0
  22. package/build/index.d.ts +2 -0
  23. package/build/index.js +24 -0
  24. package/build/index.js.map +1 -0
  25. package/build/server.d.ts +21 -0
  26. package/build/server.js +82 -0
  27. package/build/server.js.map +1 -0
  28. package/build/services/onyxApi.d.ts +68 -0
  29. package/build/services/onyxApi.js +272 -0
  30. package/build/services/onyxApi.js.map +1 -0
  31. package/build/tools/chatTool.d.ts +23 -0
  32. package/build/tools/chatTool.js +60 -0
  33. package/build/tools/chatTool.js.map +1 -0
  34. package/build/tools/index.d.ts +6 -0
  35. package/build/tools/index.js +7 -0
  36. package/build/tools/index.js.map +1 -0
  37. package/build/tools/searchTool.d.ts +20 -0
  38. package/build/tools/searchTool.js +55 -0
  39. package/build/tools/searchTool.js.map +1 -0
  40. package/build/types/index.d.ts +157 -0
  41. package/build/types/index.js +86 -0
  42. package/build/types/index.js.map +1 -0
  43. package/package.json +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Onyx MCP Server will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Automated version bumping based on conventional commit prefixes in PR titles and commit messages
12
+ - Commit message validation using commitlint to enforce conventional commit format
13
+ - Interactive commit message creation using commitizen (via `npm run commit`)
14
+ - Git hooks to enforce commit message format and code quality
15
+
16
+ ### Changed
17
+ - Consolidated CI/CD workflows to avoid duplication
18
+ - Improved npm publishing process to automatically determine version bump type
19
+ - Enhanced PR template with clearer instructions for conventional commit format
20
+
21
+ ## [1.0.0] - 2025-03-23
22
+
23
+ ### Added
24
+ - Initial open source release
25
+ - Support for two main tools:
26
+ - `search_onyx`: For semantic search across Onyx document sets
27
+ - `chat_with_onyx`: For conversational interactions with Onyx knowledge base
28
+ - Comprehensive documentation:
29
+ - Getting started guide
30
+ - API documentation
31
+ - Troubleshooting guide
32
+ - Usage examples
33
+ - MIT License
34
+ - Contribution guidelines
35
+
36
+ ### Changed
37
+ - Made the project more generic (not just for coding assistants)
38
+ - Improved error handling and reporting
39
+ - Enhanced README with more detailed instructions and examples
40
+
41
+ ## [0.1.0] - 2025-03-15
42
+
43
+ ### Added
44
+ - Initial development version
45
+ - Basic search functionality
46
+ - Basic chat functionality
47
+ - Simple README with installation instructions
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Onyx MCP Server Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/lupuletic-onyx-mcp-server-badge.png)](https://mseep.ai/app/lupuletic-onyx-mcp-server)
2
+
3
+ # Onyx MCP Server
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![npm version](https://img.shields.io/npm/v/onyx-mcp-server.svg)](https://www.npmjs.com/package/onyx-mcp-server)
7
+ [![npm downloads](https://img.shields.io/npm/dm/onyx-mcp-server.svg)](https://www.npmjs.com/package/onyx-mcp-server)
8
+ [![smithery badge](https://smithery.ai/badge/@lupuletic/onyx-mcp-server)](https://smithery.ai/server/@lupuletic/onyx-mcp-server)
9
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/lupuletic/onyx-mcp-server/blob/main/CONTRIBUTING.md)
10
+
11
+ > A Model Context Protocol (MCP) server for seamless integration with Onyx AI knowledge bases.
12
+
13
+ This MCP server connects any MCP-compatible client to your Onyx knowledge base, allowing you to search and retrieve relevant context from your documents. It provides a bridge between MCP clients and the Onyx API, enabling powerful semantic search and chat capabilities.
14
+
15
+ <img width="1166" alt="image" src="https://github.com/user-attachments/assets/6396b010-cb1b-489c-98ec-dbb53e3996d2" />
16
+
17
+
18
+ ## Features
19
+
20
+ - **Enhanced Search**: Semantic search across your Onyx document sets with LLM relevance filtering
21
+ - **Context Window Retrieval**: Retrieve chunks above and below the matching chunk for better context
22
+ - **Full Document Retrieval**: Option to retrieve entire documents instead of just chunks
23
+ - **Chat Integration**: Use Onyx's powerful chat API with LLM + RAG for comprehensive answers
24
+ - **Configurable Document Set Filtering**: Target specific document sets for more relevant results
25
+
26
+ ## Installation
27
+
28
+ ### Installing via Smithery
29
+
30
+ To install Onyx MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@lupuletic/onyx-mcp-server):
31
+
32
+ ```bash
33
+ npx -y @smithery/cli install @lupuletic/onyx-mcp-server --client claude
34
+ ```
35
+
36
+ ### Prerequisites
37
+
38
+ - Node.js (v16 or higher)
39
+ - An Onyx instance with API access
40
+ - An Onyx API token
41
+
42
+ ### Setup
43
+
44
+ 1. Clone the repository:
45
+ ```bash
46
+ git clone https://github.com/lupuletic/onyx-mcp-server.git
47
+ cd onyx-mcp-server
48
+ ```
49
+
50
+ 2. Install dependencies:
51
+ ```bash
52
+ npm install
53
+ ```
54
+
55
+ 3. Build the server:
56
+ ```bash
57
+ npm run build
58
+ ```
59
+
60
+ 4. Configure your Onyx API Token:
61
+ ```bash
62
+ export ONYX_API_TOKEN="your-api-token-here"
63
+ export ONYX_API_URL="http://localhost:8080/api" # Adjust as needed
64
+ ```
65
+
66
+ 5. Start the server:
67
+ ```bash
68
+ npm start
69
+ ```
70
+
71
+ ## Configuring MCP Clients
72
+
73
+ ### For Claude Desktop App
74
+
75
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "onyx-search": {
81
+ "command": "node",
82
+ "args": ["/path/to/onyx-mcp-server/build/index.js"],
83
+ "env": {
84
+ "ONYX_API_TOKEN": "your-api-token-here",
85
+ "ONYX_API_URL": "http://localhost:8080/api"
86
+ },
87
+ "disabled": false,
88
+ "alwaysAllow": []
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### For Claude in VSCode (Cline)
95
+
96
+ Add to your Cline MCP settings file:
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "onyx-search": {
102
+ "command": "node",
103
+ "args": ["/path/to/onyx-mcp-server/build/index.js"],
104
+ "env": {
105
+ "ONYX_API_TOKEN": "your-api-token-here",
106
+ "ONYX_API_URL": "http://localhost:8080/api"
107
+ },
108
+ "disabled": false,
109
+ "alwaysAllow": []
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ ### For Other MCP Clients
116
+
117
+ Consult your MCP client's documentation for how to add a custom MCP server. You'll need to provide:
118
+
119
+ - The command to run the server (`node`)
120
+ - The path to the built server file (`/path/to/onyx-mcp-server/build/index.js`)
121
+ - Environment variables for `ONYX_API_TOKEN` and `ONYX_API_URL`
122
+
123
+ ## Available Tools
124
+
125
+ Once configured, your MCP client will have access to two powerful tools:
126
+
127
+ ### 1. Search Tool
128
+
129
+ The `search_onyx` tool provides direct access to Onyx's search capabilities with enhanced context retrieval:
130
+
131
+ ```
132
+ <use_mcp_tool>
133
+ <server_name>onyx-search</server_name>
134
+ <tool_name>search_onyx</tool_name>
135
+ <arguments>
136
+ {
137
+ "query": "customer onboarding process",
138
+ "documentSets": ["Company Policies", "Training Materials"],
139
+ "maxResults": 3,
140
+ "chunksAbove": 1,
141
+ "chunksBelow": 1,
142
+ "retrieveFullDocuments": true
143
+ }
144
+ </arguments>
145
+ </use_mcp_tool>
146
+ ```
147
+
148
+ Parameters:
149
+ - `query` (required): The topic to search for
150
+ - `documentSets` (optional): List of document set names to search within (empty for all)
151
+ - `maxResults` (optional): Maximum number of results to return (default: 5, max: 10)
152
+ - `chunksAbove` (optional): Number of chunks to include above the matching chunk (default: 1)
153
+ - `chunksBelow` (optional): Number of chunks to include below the matching chunk (default: 1)
154
+ - `retrieveFullDocuments` (optional): Whether to retrieve full documents instead of just chunks (default: false)
155
+
156
+ ### 2. Chat Tool
157
+
158
+ The `chat_with_onyx` tool leverages Onyx's powerful chat API with LLM + RAG for comprehensive answers:
159
+
160
+ ```
161
+ <use_mcp_tool>
162
+ <server_name>onyx-search</server_name>
163
+ <tool_name>chat_with_onyx</tool_name>
164
+ <arguments>
165
+ {
166
+ "query": "What is our company's policy on remote work?",
167
+ "personaId": 15,
168
+ "documentSets": ["Company Policies", "HR Documents"],
169
+ "chatSessionId": "optional-existing-session-id"
170
+ }
171
+ </arguments>
172
+ </use_mcp_tool>
173
+ ```
174
+
175
+ Parameters:
176
+ - `query` (required): The question to ask Onyx
177
+ - `personaId` (optional): The ID of the persona to use (default: 15)
178
+ - `documentSets` (optional): List of document set names to search within (empty for all)
179
+ - `chatSessionId` (optional): Existing chat session ID to continue a conversation
180
+
181
+ #### Chat Sessions
182
+
183
+ The chat tool supports maintaining conversation context across multiple interactions. After the first call, the response will include a `chat_session_id` in the metadata. You can pass this ID in subsequent calls to maintain context.
184
+
185
+ ## Choosing Between Search and Chat
186
+
187
+ - **Use Search When**: You need specific, targeted information from documents and want to control exactly how much context is retrieved.
188
+ - **Use Chat When**: You need comprehensive answers that combine information from multiple sources, or when you want the LLM to synthesize information for you.
189
+
190
+ For the best results, you can use both tools in combination - search for specific details and chat for comprehensive understanding.
191
+
192
+ ## Use Cases
193
+
194
+ - **Knowledge Management**: Access your organization's knowledge base through any MCP-compatible interface
195
+ - **Customer Support**: Help support agents quickly find relevant information
196
+ - **Research**: Conduct deep research across your organization's documents
197
+ - **Training**: Provide access to training materials and documentation
198
+ - **Policy Compliance**: Ensure teams have access to the latest policies and procedures
199
+
200
+ ## Development
201
+
202
+ ### Running in Development Mode
203
+
204
+ ```bash
205
+ npm run dev
206
+ ```
207
+
208
+ ### Committing Changes
209
+
210
+ This project enforces the [Conventional Commits](https://www.conventionalcommits.org/) specification for all commit messages. To make this easier, we provide an interactive commit tool:
211
+
212
+ ```bash
213
+ npm run commit
214
+ ```
215
+
216
+ This will guide you through creating a properly formatted commit message. Alternatively, you can write your own commit messages following the conventional format:
217
+
218
+ ```
219
+ <type>[optional scope]: <description>
220
+
221
+ [optional body]
222
+
223
+ [optional footer(s)]
224
+ ```
225
+
226
+ Where `type` is one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
227
+
228
+ ### Building for Production
229
+
230
+ ```bash
231
+ npm run build
232
+ ```
233
+
234
+ ### Testing
235
+
236
+ Run the test suite:
237
+
238
+ ```bash
239
+ npm test
240
+ ```
241
+
242
+ Run tests with coverage:
243
+
244
+ ```bash
245
+ npm run test:coverage
246
+ ```
247
+
248
+ ### Linting
249
+
250
+ ```bash
251
+ npm run lint
252
+ ```
253
+
254
+ Fix linting issues:
255
+
256
+ ```bash
257
+ npm run lint:fix
258
+ ```
259
+
260
+ ## Continuous Integration
261
+
262
+ This project uses GitHub Actions for continuous integration and deployment. The CI pipeline runs on every push to the main branch and on pull requests. It performs the following checks:
263
+
264
+ - Linting
265
+ - Building
266
+ - Testing
267
+ - Code coverage reporting
268
+
269
+ ### Automated Version Bumping and Publishing
270
+
271
+ When a PR is merged to the main branch, the project automatically determines the appropriate version bump type and publishes to npm. The system analyzes both PR titles and commit messages to determine the version bump type.
272
+
273
+ 1. **PR Title Validation**: All PR titles are validated against the [Conventional Commits](https://www.conventionalcommits.org/) specification:
274
+ - PR titles must start with a type (e.g., `feat:`, `fix:`, `docs:`)
275
+ - This validation happens automatically when a PR is created or updated
276
+ - PRs with invalid titles will fail the validation check
277
+
278
+ 2. **Commit Message Validation**: All commit messages are also validated against the conventional commits format:
279
+ - Commit messages must start with a type (e.g., `feat:`, `fix:`, `docs:`)
280
+ - This is enforced by git hooks that run when you commit
281
+ - Commits with invalid messages will be rejected
282
+ - Use `npm run commit` for an interactive commit message creation tool
283
+
284
+ 3. **Version Bump Determination**: The system analyzes both the PR title and commit messages to determine the appropriate version bump:
285
+ - PR titles starting with `feat` or containing new features → minor version bump
286
+ - PR titles starting with `fix` or containing bug fixes → patch version bump
287
+ - PR titles containing `BREAKING CHANGE` or with an exclamation mark → major version bump
288
+ - If the PR title doesn't indicate a specific bump type, the system analyzes commit messages
289
+ - The highest priority bump type found in any commit message is used (major > minor > patch)
290
+ - If no conventional commit prefixes are found, the system automatically defaults to a patch version bump without failing
291
+
292
+ 4. **Version Update and Publishing**:
293
+ - Bumps the version in package.json according to semantic versioning
294
+ - Commits and pushes the version change
295
+ - Publishes the new version to npm
296
+
297
+ This automated process ensures consistent versioning based on the nature of the changes, following semantic versioning principles, and eliminates manual version management.
298
+
299
+ ## Contributing
300
+
301
+ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.
302
+
303
+ ## Security
304
+
305
+ If you discover a security vulnerability, please follow our [Security Policy](SECURITY.md).
306
+
307
+ ## License
308
+
309
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
310
+
311
+
312
+ <a href="https://glama.ai/mcp/servers/@lupuletic/onyx-mcp-server">
313
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/@lupuletic/onyx-mcp-server/badge" />
314
+ </a>
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Unit tests for the config module
3
+ */
4
+ import { loadConfig, SERVER_CONFIG, DEBUG } from '../../config/index.js';
5
+ // Save original environment
6
+ const originalEnv = process.env;
7
+ beforeEach(() => {
8
+ // Reset environment variables before each test
9
+ process.env = { ...originalEnv };
10
+ delete process.env.ONYX_API_TOKEN;
11
+ delete process.env.ONYX_API_URL;
12
+ delete process.env.DEBUG;
13
+ });
14
+ afterAll(() => {
15
+ // Restore original environment
16
+ process.env = originalEnv;
17
+ });
18
+ describe('Config Module', () => {
19
+ describe('loadConfig', () => {
20
+ it('should load default config when no environment variables are set', () => {
21
+ const config = loadConfig();
22
+ expect(config).toEqual({
23
+ apiUrl: 'http://localhost:8080/api',
24
+ apiToken: '',
25
+ });
26
+ });
27
+ it('should use environment variables when set', () => {
28
+ process.env.ONYX_API_TOKEN = 'test-token';
29
+ process.env.ONYX_API_URL = 'http://test-url.com/api';
30
+ const config = loadConfig();
31
+ expect(config).toEqual({
32
+ apiUrl: 'http://test-url.com/api',
33
+ apiToken: 'test-token',
34
+ });
35
+ });
36
+ });
37
+ describe('SERVER_CONFIG', () => {
38
+ it('should have the correct server configuration', () => {
39
+ expect(SERVER_CONFIG).toHaveProperty('name', 'onyx-mcp-server');
40
+ expect(SERVER_CONFIG).toHaveProperty('version', '1.0.0');
41
+ });
42
+ });
43
+ describe('DEBUG', () => {
44
+ it('should be false by default', () => {
45
+ expect(DEBUG).toBe(false);
46
+ });
47
+ it('should be true when DEBUG environment variable is set to "true"', () => {
48
+ // Set the DEBUG environment variable
49
+ process.env.DEBUG = 'true';
50
+ // Re-import the module to get the updated value
51
+ // Note: This is a simplified test since we can't easily reset modules in Jest ESM
52
+ expect(process.env.DEBUG).toBe('true');
53
+ });
54
+ });
55
+ });
56
+ //# sourceMappingURL=config.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../../src/__tests__/config/config.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEzE,4BAA4B;AAC5B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;AAEhC,UAAU,CAAC,GAAG,EAAE;IACd,+CAA+C;IAC/C,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;IACjC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAClC,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAChC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,GAA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B,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;YACzE,qCAAqC;YACrC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC;YAE3B,gDAAgD;YAChD,kFAAkF;YAClF,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Unit tests for the main entry point
3
+ */
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ // ES modules equivalent of __dirname
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ describe('Main Entry Point', () => {
11
+ it('should have a main function that starts the server', async () => {
12
+ // Simple test to verify the file exists and has the expected content
13
+ const indexPath = path.resolve(__dirname, '../index.ts');
14
+ const fileExists = fs.existsSync(indexPath);
15
+ expect(fileExists).toBe(true);
16
+ // Read the file content
17
+ const content = fs.readFileSync(indexPath, 'utf8');
18
+ // Verify it contains the expected functions and imports
19
+ expect(content).toContain('async function main()');
20
+ expect(content).toContain('import { StdioServerTransport }');
21
+ expect(content).toContain('import { OnyxMcpServer }');
22
+ expect(content).toContain('main().catch(console.error)');
23
+ });
24
+ });
25
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,qCAAqC;AACrC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QAClE,qEAAqE;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9B,wBAAwB;QACxB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEnD,wDAAwD;QACxD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;QACtD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Integration tests for the Onyx MCP Server
3
+ */
4
+ import { OnyxMcpServer } from '../../server.js';
5
+ import nock from 'nock';
6
+ describe('OnyxMcpServer Integration', () => {
7
+ let server;
8
+ beforeEach(() => {
9
+ // Set up environment variables
10
+ process.env.ONYX_API_TOKEN = 'test-token';
11
+ process.env.ONYX_API_URL = 'http://test-api.com/api';
12
+ // Mock all HTTP requests
13
+ nock.disableNetConnect();
14
+ // Create server and transport
15
+ server = new OnyxMcpServer();
16
+ });
17
+ afterEach(() => {
18
+ nock.cleanAll();
19
+ nock.enableNetConnect();
20
+ delete process.env.ONYX_API_TOKEN;
21
+ delete process.env.ONYX_API_URL;
22
+ });
23
+ it('should initialize and run the server', async () => {
24
+ // Run the server with the mock transport
25
+ // We're just testing that the server can be created without errors
26
+ expect(server).toBeDefined();
27
+ // Verify that the server has the expected properties
28
+ expect(server).toHaveProperty('server');
29
+ });
30
+ it('should handle list tools request', async () => {
31
+ // Run the server with the mock transport
32
+ // We're just testing that the server can be created without errors
33
+ expect(server).toBeDefined();
34
+ // Verify that the server has the expected properties
35
+ expect(server).toHaveProperty('server');
36
+ });
37
+ it('should handle call tool request for search_onyx', async () => {
38
+ // Set up API mocks
39
+ nock('http://test-api.com')
40
+ .post('/api/admin/search')
41
+ .reply(200, { documents: [] });
42
+ // Run the server
43
+ // We're just testing that the server can be created without errors
44
+ expect(server).toBeDefined();
45
+ // Verify that the server has the expected properties
46
+ expect(server).toHaveProperty('server');
47
+ });
48
+ it('should handle call tool request for chat_with_onyx', async () => {
49
+ // Set up API mocks
50
+ nock('http://test-api.com')
51
+ .post('/api/chat/create-chat-session')
52
+ .reply(200, { chat_session_id: 'test-session-id' });
53
+ nock('http://test-api.com')
54
+ .post('/api/chat/send-message')
55
+ .reply(200, JSON.stringify({
56
+ answer: 'Test answer',
57
+ documents: []
58
+ }));
59
+ // Run the server
60
+ // We're just testing that the server can be created without errors
61
+ expect(server).toBeDefined();
62
+ // Verify that the server has the expected properties
63
+ expect(server).toHaveProperty('server');
64
+ });
65
+ it('should handle call tool request for unknown tool', async () => {
66
+ // Run the server
67
+ // We're just testing that the server can be created without errors
68
+ expect(server).toBeDefined();
69
+ // Verify that the server has the expected properties
70
+ expect(server).toHaveProperty('server');
71
+ });
72
+ });
73
+ //# sourceMappingURL=server.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.test.js","sourceRoot":"","sources":["../../../src/__tests__/integration/server.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAA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