@jahales/mcp-zoekt 2.2.3

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 (55) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +400 -0
  3. package/dist/config.d.ts +17 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +83 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/errors/codes.d.ts +28 -0
  8. package/dist/errors/codes.d.ts.map +1 -0
  9. package/dist/errors/codes.js +161 -0
  10. package/dist/errors/codes.js.map +1 -0
  11. package/dist/formatting/repoList.d.ts +14 -0
  12. package/dist/formatting/repoList.d.ts.map +1 -0
  13. package/dist/formatting/repoList.js +55 -0
  14. package/dist/formatting/repoList.js.map +1 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +88 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/logger.d.ts +8 -0
  20. package/dist/logger.d.ts.map +1 -0
  21. package/dist/logger.js +36 -0
  22. package/dist/logger.js.map +1 -0
  23. package/dist/pagination/cursor.d.ts +103 -0
  24. package/dist/pagination/cursor.d.ts.map +1 -0
  25. package/dist/pagination/cursor.js +136 -0
  26. package/dist/pagination/cursor.js.map +1 -0
  27. package/dist/server.d.ts +12 -0
  28. package/dist/server.d.ts.map +1 -0
  29. package/dist/server.js +468 -0
  30. package/dist/server.js.map +1 -0
  31. package/dist/tools/find-references.d.ts +53 -0
  32. package/dist/tools/find-references.d.ts.map +1 -0
  33. package/dist/tools/find-references.js +284 -0
  34. package/dist/tools/find-references.js.map +1 -0
  35. package/dist/tools/get-health.d.ts +37 -0
  36. package/dist/tools/get-health.d.ts.map +1 -0
  37. package/dist/tools/get-health.js +128 -0
  38. package/dist/tools/get-health.js.map +1 -0
  39. package/dist/tools/search-files.d.ts +58 -0
  40. package/dist/tools/search-files.d.ts.map +1 -0
  41. package/dist/tools/search-files.js +139 -0
  42. package/dist/tools/search-files.js.map +1 -0
  43. package/dist/tools/search-symbols.d.ts +49 -0
  44. package/dist/tools/search-symbols.d.ts.map +1 -0
  45. package/dist/tools/search-symbols.js +235 -0
  46. package/dist/tools/search-symbols.js.map +1 -0
  47. package/dist/zoekt/client.d.ts +51 -0
  48. package/dist/zoekt/client.d.ts.map +1 -0
  49. package/dist/zoekt/client.js +262 -0
  50. package/dist/zoekt/client.js.map +1 -0
  51. package/dist/zoekt/types.d.ts +208 -0
  52. package/dist/zoekt/types.d.ts.map +1 -0
  53. package/dist/zoekt/types.js +6 -0
  54. package/dist/zoekt/types.js.map +1 -0
  55. package/package.json +66 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Jacob Hales
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,400 @@
1
+ # @jahales/mcp-zoekt
2
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
3
+
4
+ An MCP (Model Context Protocol) server that enables AI coding assistants to search code across indexed repositories using [Zoekt](https://github.com/sourcegraph/zoekt).
5
+
6
+ ## Features
7
+
8
+ - **`search`** - Search code across indexed repositories using Zoekt query syntax
9
+ - **`search_symbols`** - Search for symbol names (functions, classes, methods, variables)
10
+ - **`search_files`** - Search for files by filename pattern
11
+ - **`find_references`** - Find all definitions and usages of a symbol
12
+ - **`list_repos`** - List all indexed repositories with optional filtering
13
+ - **`file_content`** - Retrieve full file contents from indexed repositories
14
+ - **`get_health`** - Check health status of MCP server and Zoekt backend
15
+
16
+ ## Quick Install
17
+
18
+ ### VS Code with GitHub Copilot
19
+
20
+ [![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-NPM-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=zoekt&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40jahales%2Fmcp-zoekt%22%2C%22--url%22%2C%22http%3A%2F%2Flocalhost%3A6070%22%5D%7D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-NPM-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=zoekt&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40jahales%2Fmcp-zoekt%22%2C%22--url%22%2C%22http%3A%2F%2Flocalhost%3A6070%22%5D%7D&quality=insiders)
21
+
22
+ [![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Docker-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=zoekt&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22--network%22%2C%22host%22%2C%22-e%22%2C%22ZOEKT_URL%3Dhttp%3A%2F%2Flocalhost%3A6070%22%2C%22ghcr.io%2Fjahales%2Fmcp-zoekt%22%5D%7D) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Docker-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=zoekt&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22--network%22%2C%22host%22%2C%22-e%22%2C%22ZOEKT_URL%3Dhttp%3A%2F%2Flocalhost%3A6070%22%2C%22ghcr.io%2Fjahales%2Fmcp-zoekt%22%5D%7D&quality=insiders)
23
+
24
+ ## Installation
25
+
26
+ ### Using npx (recommended)
27
+ ```bash
28
+ npx @jahales/mcp-zoekt --url http://localhost:6070
29
+ ```
30
+
31
+ ### Using Docker
32
+
33
+ ```bash
34
+ docker run -i --rm --network host \
35
+ -e ZOEKT_URL=http://localhost:6070 \
36
+ ghcr.io/jahales/mcp-zoekt
37
+ ```
38
+
39
+ ### From source
40
+
41
+ ```bash
42
+ git clone https://github.com/jahales/mcp-zoekt.git
43
+ cd mcp-zoekt/zoekt-mcp
44
+ npm install
45
+ npm run build
46
+ npm start -- --url http://localhost:6070
47
+ ```
48
+
49
+ ## Prerequisites
50
+
51
+ This MCP server requires a running Zoekt infrastructure. See the `docker/` directory for Docker Compose configuration.
52
+
53
+ ### Quick Start
54
+
55
+ 1. Start Zoekt infrastructure:
56
+ ```bash
57
+ cd docker
58
+ # Configure your GitHub token and organizations in config/
59
+ docker compose up -d
60
+ ```
61
+
62
+ 2. Wait for initial indexing (check logs):
63
+ ```bash
64
+ docker compose logs -f
65
+ ```
66
+
67
+ 3. Start the MCP server:
68
+ ```bash
69
+ npx @jahales/mcp-zoekt --url http://localhost:6070
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ ### CLI Options
75
+
76
+ | Option | Environment Variable | Default | Description |
77
+ |--------|---------------------|---------|-------------|
78
+ | `--url` | `ZOEKT_URL` | (required) | Zoekt webserver URL |
79
+ | `--transport` | `MCP_TRANSPORT` | `stdio` | Transport: `stdio` or `http` |
80
+ | `--port` | `MCP_PORT` | `3000` | HTTP server port |
81
+ | `--host` | `MCP_HOST` | `0.0.0.0` | HTTP server host |
82
+ | `--log-level` | `LOG_LEVEL` | `info` | Log level: `debug`, `info`, `warn`, `error` |
83
+ | `--debug` | - | - | Shorthand for `--log-level debug` |
84
+ | `--timeout` | `ZOEKT_TIMEOUT_MS` | `30000` | Request timeout (ms) |
85
+
86
+ ### Examples
87
+
88
+ ```bash
89
+ # Basic usage
90
+ npx @jahales/mcp-zoekt --url http://localhost:6070
91
+
92
+ # With debug logging
93
+ npx @jahales/mcp-zoekt --url http://localhost:6070 --debug
94
+
95
+ # Using environment variable
96
+ ZOEKT_URL=http://localhost:6070 npx @jahales/mcp-zoekt
97
+
98
+ # Custom timeout
99
+ npx @jahales/mcp-zoekt --url http://localhost:6070 --timeout 60000
100
+ ```
101
+
102
+ ## MCP Client Configuration
103
+
104
+ ### VS Code with GitHub Copilot
105
+
106
+ #### Using npx
107
+
108
+ Add to `.vscode/mcp.json` in your workspace:
109
+
110
+ ```json
111
+ {
112
+ "servers": {
113
+ "zoekt": {
114
+ "command": "npx",
115
+ "args": ["-y", "@jahales/mcp-zoekt", "--url", "http://localhost:6070"]
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ #### Using Docker
122
+
123
+ ```json
124
+ {
125
+ "servers": {
126
+ "zoekt": {
127
+ "command": "docker",
128
+ "args": [
129
+ "run", "-i", "--rm", "--network", "host",
130
+ "-e", "ZOEKT_URL=http://localhost:6070",
131
+ "ghcr.io/jahales/mcp-zoekt"
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### Claude Desktop
139
+
140
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
141
+
142
+ #### Using npx
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "zoekt": {
148
+ "command": "npx",
149
+ "args": ["-y", "@jahales/mcp-zoekt", "--url", "http://localhost:6070"]
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ #### Using Docker
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "zoekt": {
161
+ "command": "docker",
162
+ "args": [
163
+ "run", "-i", "--rm", "--network", "host",
164
+ "-e", "ZOEKT_URL=http://localhost:6070",
165
+ "ghcr.io/jahales/mcp-zoekt"
166
+ ]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### Continue.dev
173
+
174
+ Add to your Continue configuration:
175
+
176
+ ```json
177
+ {
178
+ "experimental": {
179
+ "modelContextProtocolServers": [
180
+ {
181
+ "transport": {
182
+ "type": "stdio",
183
+ "command": "npx",
184
+ "args": ["-y", "@jahales/mcp-zoekt", "--url", "http://localhost:6070"]
185
+ }
186
+ }
187
+ ]
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## Tool Reference
193
+
194
+ ### `search`
195
+
196
+ Search code across indexed repositories using Zoekt query syntax.
197
+
198
+ **Input:**
199
+ - `query` (required): Zoekt search query
200
+ - `limit` (optional): Maximum results (1-100, default: 30)
201
+ - `contextLines` (optional): Context lines around matches (0-10, default: 3)
202
+
203
+ **Query Syntax:**
204
+ ```
205
+ # Simple text search
206
+ authentication
207
+
208
+ # Regex
209
+ func.*Handler
210
+
211
+ # File filter
212
+ file:\.ts$
213
+
214
+ # Language filter
215
+ lang:typescript
216
+
217
+ # Repository filter
218
+ repo:my-org/my-repo
219
+
220
+ # Combine filters
221
+ lang:go func.*Error file:handler
222
+
223
+ # Symbol search
224
+ sym:MyClass
225
+
226
+ # Boolean operators
227
+ (auth OR authentication) AND NOT test
228
+ ```
229
+
230
+ ### `list_repos`
231
+
232
+ List all indexed repositories.
233
+
234
+ **Input:**
235
+ - `filter` (optional): Regex pattern to filter repository names
236
+
237
+ **Examples:**
238
+ ```
239
+ # List all repositories
240
+ {}
241
+
242
+ # Filter by organization
243
+ {"filter": "my-org"}
244
+
245
+ # Filter by pattern
246
+ {"filter": ".*-api$"}
247
+ ```
248
+
249
+ ### `search_symbols`
250
+
251
+ Search for symbol names (functions, classes, methods, variables) across repositories. Automatically uses Zoekt's `sym:` query prefix.
252
+
253
+ **Input:**
254
+ - `query` (required): Symbol search query
255
+ - `limit` (optional): Maximum results (1-100, default: 30)
256
+ - `contextLines` (optional): Context lines around matches (0-10, default: 3)
257
+ - `cursor` (optional): Pagination cursor from previous response
258
+
259
+ **Examples:**
260
+ ```
261
+ # Find symbols named handleRequest
262
+ {"query": "handleRequest"}
263
+
264
+ # Symbols starting with "get" (regex)
265
+ {"query": "/^get.*/"}
266
+
267
+ # TypeScript symbols matching "handler"
268
+ {"query": "handler lang:typescript"}
269
+
270
+ # Symbol in specific repo
271
+ {"query": "UserService repo:myorg/myrepo"}
272
+ ```
273
+
274
+ ### `search_files`
275
+
276
+ Search for files by filename pattern. Returns file paths only, not content.
277
+
278
+ **Input:**
279
+ - `query` (required): File name search query
280
+ - `limit` (optional): Maximum results (1-100, default: 30)
281
+ - `cursor` (optional): Pagination cursor from previous response
282
+
283
+ **Examples:**
284
+ ```
285
+ # Exact filename match
286
+ {"query": "package.json"}
287
+
288
+ # TypeScript test files (regex)
289
+ {"query": "/.*\\.test\\.ts$/"}
290
+
291
+ # README in specific repo
292
+ {"query": "README.md repo:myorg/myrepo"}
293
+
294
+ # YAML config files
295
+ {"query": "config lang:yaml"}
296
+ ```
297
+
298
+ ### `find_references`
299
+
300
+ Find all definitions and usages of a symbol across repositories. Returns both where the symbol is defined and where it is used.
301
+
302
+ **Input:**
303
+ - `symbol` (required): Symbol to find references for
304
+ - `filters` (optional): Additional query filters (lang:, repo:, etc.)
305
+ - `limit` (optional): Maximum results (1-100, default: 30)
306
+ - `contextLines` (optional): Context lines around matches (0-10, default: 3)
307
+ - `cursor` (optional): Pagination cursor from previous response
308
+
309
+ **Examples:**
310
+ ```
311
+ # Find all references to handleRequest
312
+ {"symbol": "handleRequest"}
313
+
314
+ # TypeScript only
315
+ {"symbol": "UserService", "filters": "lang:typescript"}
316
+
317
+ # Within specific repo
318
+ {"symbol": "validateInput", "filters": "repo:backend"}
319
+ ```
320
+
321
+ ### `get_health`
322
+
323
+ Check health status of the MCP server and Zoekt backend. Returns connectivity status, server version, and index statistics.
324
+
325
+ **Input:** None required
326
+
327
+ **Output:**
328
+ - Health status: healthy, degraded, or unhealthy
329
+ - MCP server version
330
+ - Zoekt backend connectivity
331
+ - Index statistics (repository count, document count, index size)
332
+
333
+ ### `file_content`
334
+
335
+ Retrieve full file contents from an indexed repository.
336
+
337
+ **Input:**
338
+ - `repository` (required): Full repository name (e.g., `github.com/org/repo`)
339
+ - `path` (required): File path within the repository
340
+ - `branch` (optional): Branch name (default: HEAD)
341
+
342
+ ## Development
343
+
344
+ ### Build
345
+
346
+ ```bash
347
+ npm run build
348
+ ```
349
+
350
+ ### Run Tests
351
+
352
+ ```bash
353
+ npm test # Unit tests (watch mode)
354
+ npm run test:run # Unit tests (single run)
355
+ ```
356
+
357
+ ### Integration Tests
358
+
359
+ Integration tests require a running Zoekt instance. Use the test infrastructure:
360
+
361
+ ```bash
362
+ # Start test infrastructure
363
+ cd docker
364
+ docker compose -f docker-compose.test.yml up -d
365
+
366
+ # Wait for Zoekt to be ready (check health)
367
+ curl http://localhost:6070/api/list
368
+
369
+ # Run integration tests
370
+ cd ../zoekt-mcp
371
+ npm run test:integration
372
+
373
+ # Run all tests (unit + integration)
374
+ npm run test:all
375
+
376
+ # Stop test infrastructure
377
+ cd ../docker
378
+ docker compose -f docker-compose.test.yml down
379
+ ```
380
+
381
+ The test infrastructure includes:
382
+ - Zoekt webserver on port 6070
383
+ - Embedded test corpus in `tests/fixtures/test-repo/`
384
+ - Pre-configured indexer for deterministic test results
385
+
386
+ ### Type Check
387
+
388
+ ```bash
389
+ npm run typecheck
390
+ ```
391
+
392
+ ### Lint
393
+
394
+ ```bash
395
+ npm run lint
396
+ ```
397
+
398
+ ## License
399
+
400
+ MIT
@@ -0,0 +1,17 @@
1
+ import type { LogLevel } from './logger.js';
2
+ /**
3
+ * MCP Server Configuration
4
+ */
5
+ export interface McpServerConfig {
6
+ zoektUrl: string;
7
+ transport: 'stdio' | 'http';
8
+ port: number | undefined;
9
+ host: string | undefined;
10
+ logLevel: LogLevel;
11
+ timeoutMs: number;
12
+ }
13
+ /**
14
+ * Parse command line arguments and environment variables to build config
15
+ */
16
+ export declare function loadConfig(args: string[]): McpServerConfig;
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAmF1D"}
package/dist/config.js ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Parse command line arguments and environment variables to build config
3
+ */
4
+ export function loadConfig(args) {
5
+ // Track which values were explicitly set via CLI
6
+ let transportSet = false;
7
+ let logLevelSet = false;
8
+ let timeoutSet = false;
9
+ const config = {};
10
+ // Parse CLI arguments (highest priority)
11
+ for (let i = 0; i < args.length; i++) {
12
+ const arg = args[i];
13
+ const nextArg = args[i + 1];
14
+ switch (arg) {
15
+ case '--url':
16
+ if (nextArg)
17
+ config.zoektUrl = nextArg;
18
+ i++;
19
+ break;
20
+ case '--transport':
21
+ if (nextArg === 'stdio' || nextArg === 'http') {
22
+ config.transport = nextArg;
23
+ transportSet = true;
24
+ }
25
+ i++;
26
+ break;
27
+ case '--port':
28
+ config.port = parseInt(nextArg ?? '3000', 10);
29
+ i++;
30
+ break;
31
+ case '--host':
32
+ if (nextArg)
33
+ config.host = nextArg;
34
+ i++;
35
+ break;
36
+ case '--log-level':
37
+ if (['debug', 'info', 'warn', 'error'].includes(nextArg ?? '')) {
38
+ config.logLevel = nextArg;
39
+ logLevelSet = true;
40
+ }
41
+ i++;
42
+ break;
43
+ case '--debug':
44
+ config.logLevel = 'debug';
45
+ logLevelSet = true;
46
+ break;
47
+ case '--timeout':
48
+ config.timeoutMs = parseInt(nextArg ?? '30000', 10);
49
+ timeoutSet = true;
50
+ i++;
51
+ break;
52
+ }
53
+ }
54
+ // Fall back to environment variables (only if CLI didn't set)
55
+ if (!config.zoektUrl && process.env['ZOEKT_URL']) {
56
+ config.zoektUrl = process.env['ZOEKT_URL'];
57
+ }
58
+ if (!transportSet && (process.env['MCP_TRANSPORT'] === 'stdio' || process.env['MCP_TRANSPORT'] === 'http')) {
59
+ config.transport = process.env['MCP_TRANSPORT'];
60
+ }
61
+ if (config.port === undefined && process.env['MCP_PORT']) {
62
+ config.port = parseInt(process.env['MCP_PORT'], 10);
63
+ }
64
+ if (config.host === undefined && process.env['MCP_HOST']) {
65
+ config.host = process.env['MCP_HOST'];
66
+ }
67
+ if (!logLevelSet && process.env['LOG_LEVEL'] && ['debug', 'info', 'warn', 'error'].includes(process.env['LOG_LEVEL'])) {
68
+ config.logLevel = process.env['LOG_LEVEL'];
69
+ }
70
+ if (!timeoutSet && process.env['ZOEKT_TIMEOUT_MS']) {
71
+ config.timeoutMs = parseInt(process.env['ZOEKT_TIMEOUT_MS'], 10);
72
+ }
73
+ // Apply defaults (lowest priority)
74
+ config.transport = config.transport ?? 'stdio';
75
+ config.logLevel = config.logLevel ?? 'info';
76
+ config.timeoutMs = config.timeoutMs ?? 30000;
77
+ // Validate required fields
78
+ if (!config.zoektUrl) {
79
+ throw new Error('Zoekt URL is required. Use --url flag or ZOEKT_URL environment variable.');
80
+ }
81
+ return config;
82
+ }
83
+ //# sourceMappingURL=config.js.map