scythe-context-mcp 0.1.0 → 0.1.1

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  This project follows semantic versioning before npm publication where practical.
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.1] - 2026-06-13
10
+
11
+ ### Added
12
+
13
+ - CLI smoke-test flags: `--help` and `--version`.
14
+ - npm and GitHub package metadata for homepage and issue links.
15
+ - Windows Codex App + WSL workspace setup guidance using Windows `npx.cmd`.
16
+ - CI coverage for CLI smoke tests.
17
+ - `PWD` fallback for default project detection, reducing the need for fixed per-repo MCP configuration.
18
+ - README clarification for WSL `PWD/p` forwarding versus direct Gemini proxy configuration.
19
+
7
20
  ## [0.1.0] - 2026-06-13
8
21
 
9
22
  ### Added
package/README.en.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Scythe Context MCP
2
2
 
3
3
  [![CI](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/scythe-context-mcp.svg)](https://www.npmjs.com/package/scythe-context-mcp)
4
5
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
6
  [![Node.js >=24.11](https://img.shields.io/badge/Node.js-%3E%3D24.11-339933.svg)](package.json)
6
7
 
@@ -8,47 +9,28 @@
8
9
 
9
10
  Scythe Context MCP is a local code-context engine for Codex App / Codex CLI. It builds a SQLite/sqlite-vec index inside the repo and combines semantic search, keyword search, symbol/dependency metadata, and context packing so Codex can retrieve actionable files, line ranges, snippets, and related paths faster.
10
11
 
11
- ## Why Use It
12
+ ## Highlights
12
13
 
13
- - **Local-first**: metadata, FTS, and vector indexes live under `.scythe-context/`.
14
- - **Hybrid retrieval**: combines Gemini embeddings, SQLite FTS5, path boosts, and symbol-aware ranking instead of relying on one retrieval path.
15
- - **Codex-oriented output**: returns line ranges, snippets, match reasons, grep keywords, related files, and suggested paths.
16
- - **Bring your own provider**: supports the official Gemini API and third-party Gemini-compatible v1beta proxies.
17
- - **Diagnosable**: includes provider probe, index freshness, embedding coverage, and actionable remediation hints.
14
+ - Local-first: metadata, FTS, and vector indexes live under `.scythe-context/`.
15
+ - Hybrid retrieval: combines Gemini embeddings, SQLite FTS5, path boosts, and symbol-aware ranking instead of relying on one retrieval path.
16
+ - Codex-oriented output: returns line ranges, snippets, match reasons, grep keywords, related files, and suggested paths.
17
+ - Gemini-compatible: supports the official Gemini API and third-party v1beta proxies.
18
+ - Diagnosable: includes provider probe, index freshness, embedding coverage, and actionable remediation hints.
18
19
 
19
20
  Privacy note: query or chunk text is sent to the configured Gemini-compatible endpoint only when embedding features are used. Treat third-party proxies as services that can see that text.
20
21
 
21
- ## Feature Status
22
-
23
- Implemented:
24
-
25
- - repo scanning, binary/large-file skipping, and chunking
26
- - SQLite metadata, SQLite FTS5, and sqlite-vec vector indexes
27
- - Gemini Embedding 2 provider and batch fallback
28
- - semantic / keyword / hybrid search
29
- - lightweight symbol/dependency graph
30
- - related-file lookup and bounded multi-hop traversal
31
- - `repo_context_pack` context budgeting and related snippet packing
32
- - provider diagnostics and index freshness diagnostics
33
-
34
- Next:
35
-
36
- - provider capability cache
37
- - fuller install/native dependency doctor
38
- - keyword-only fallback when embeddings fail
39
- - tree-sitter symbol extraction if needed
40
-
41
- ## Installation
22
+ ## Quick Start
42
23
 
43
- ### From npm
44
-
45
- Install the CLI globally from npm:
24
+ Codex MCP config can use `npx -y scythe-context-mcp` directly; a global install is not required. Global installation is mostly useful for checking that the CLI runs, or for using the short command form in Codex config.
46
25
 
47
26
  ```bash
48
27
  npm install -g scythe-context-mcp
28
+ scythe-context-mcp --version
49
29
  ```
50
30
 
51
- ### From source
31
+ Runtime target: Node.js 24 LTS. Node 26 may work, but it is not the baseline until it enters LTS.
32
+
33
+ Run from source:
52
34
 
53
35
  ```bash
54
36
  git clone https://github.com/Lianye-Scythe/scythe-context-mcp.git
@@ -58,72 +40,162 @@ cp .env.example .env
58
40
  npm run build
59
41
  ```
60
42
 
61
- Runtime target: Node.js 24 LTS. Node 26 may work, but it is not the baseline until it enters LTS.
62
-
63
43
  The old project name `repo-beacon-mcp` has been renamed to `scythe-context-mcp`. Legacy `REPO_BEACON_*` environment variables are still accepted as fallback, but new setups should use `SCYTHE_CONTEXT_*`.
64
44
 
65
45
  ## Codex Setup
66
46
 
67
- ### npm binary
47
+ Codex MCP configuration uses fields such as `command`, `args`, `cwd`, `env`, and `env_vars`; see the official [Model Context Protocol](https://developers.openai.com/codex/mcp) and [Configuration Reference](https://developers.openai.com/codex/config-reference) docs.
68
48
 
69
- If installed globally from npm:
49
+ ### Choose The Runtime
50
+
51
+ | Scenario | Recommendation |
52
+ | --- | --- |
53
+ | Codex and MCP both run on Windows | Use Windows `node.exe` plus Windows npm `npx-cli.js`. |
54
+ | Codex CLI runs inside WSL/Linux/macOS | Use `npx` or `node dist/index.js` from the same environment. |
55
+ | Codex App on Windows opens a WSL repo | The App's WSL MCP bridge may still be unreliable; run MCP on Windows Node and pass the current WSL workspace to the Windows process with `PWD` + `WSLENV`. |
56
+
57
+ ### Native Windows
58
+
59
+ Use `where node` and `npm root -g` to confirm your own Windows Node/npm paths first; the example below uses an nvm4w installation path.
60
+
61
+ Minimum config:
70
62
 
71
63
  ```toml
72
64
  [mcp_servers.scythe_context]
73
- command = "scythe-context-mcp"
74
- enabled = true
75
- required = false
76
- startup_timeout_sec = 20
77
- tool_timeout_sec = 120
65
+ command = 'C:\nvm4w\nodejs\node.exe'
66
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', '-y', 'scythe-context-mcp']
78
67
  env_vars = ["GEMINI_API_KEY"]
79
- enabled_tools = [
80
- "repo_index_status",
81
- "repo_reindex",
82
- "repo_context_pack",
83
- "repo_semantic_search",
84
- "repo_related_files",
85
- "gemini_embedding_probe"
86
- ]
68
+ ```
87
69
 
88
- [mcp_servers.scythe_context.env]
89
- GEMINI_OUTPUT_DIMENSIONALITY = "1536"
70
+ If `scythe-context-mcp` is installed globally and Codex can see it on PATH, it can be shorter:
71
+
72
+ ```toml
73
+ [mcp_servers.scythe_context]
74
+ command = "scythe-context-mcp"
75
+ env_vars = ["GEMINI_API_KEY"]
90
76
  ```
91
77
 
92
- ### Local checkout
78
+ ### WSL/Linux/macOS
93
79
 
94
- If running from source:
80
+ When Codex and the MCP server both run in the same Unix-like environment, the minimum config is:
81
+
82
+ ```toml
83
+ [mcp_servers.scythe_context]
84
+ command = "npx"
85
+ args = ["-y", "scythe-context-mcp"]
86
+ env_vars = ["GEMINI_API_KEY"]
87
+ ```
88
+
89
+ When running from source:
95
90
 
96
91
  ```toml
97
92
  [mcp_servers.scythe_context]
98
93
  command = "node"
99
94
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
100
- cwd = "/path/to/scythe-context-mcp"
101
- enabled = true
102
- required = false
103
- startup_timeout_sec = 20
104
- tool_timeout_sec = 120
105
95
  env_vars = ["GEMINI_API_KEY"]
96
+ ```
97
+
98
+ Here `args` points to the built Scythe Context MCP entrypoint; do not pin `cwd` to one repo in global config. Scythe prefers a tool call's `project_path`, then the workspace `PWD` / process `cwd` used when Codex starts the MCP server. Set `cwd` or `SCYTHE_CONTEXT_DEFAULT_PROJECT` only in project-scoped `.codex/config.toml`, or when you intentionally want to pin one repo.
99
+
100
+ ### Windows Codex App + WSL repo
101
+
102
+ Codex App on Windows may not reliably start WSL-side stdio MCP servers while using WSL agent mode. If MCP tools do not appear in the App, MCP handshakes time out, or config paths cross Windows/WSL boundaries, run the MCP server on Windows Node and let Scythe Context index the WSL repo path.
103
+
104
+ Minimum config:
106
105
 
106
+ ```toml
107
+ [mcp_servers.scythe_context]
108
+ command = "/mnt/c/nvm4w/nodejs/node.exe"
109
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
+ cwd = "/mnt/c/Users/you"
111
+ env_vars = ["GEMINI_API_KEY", "PWD"]
112
+
113
+ [mcp_servers.scythe_context.env]
114
+ WSLENV = "PWD/p"
115
+ ```
116
+
117
+ Notes:
118
+
119
+ - Keep `cwd` on a Windows-accessible directory such as `/mnt/c/Users/you`. Do not use the WSL repo's UNC directory as `cwd`, because npm/npx may go through CMD, and CMD does not support UNC current directories.
120
+ - This `cwd` is not the repo to index; it is only a safe startup directory for the Windows process. The real WSL repo is passed through `PWD/p`.
121
+ - `PWD/p` lets WSL convert the current workspace path into a UNC path readable by the Windows process, so you do not need to edit config for every repo.
122
+ - If `GEMINI_API_KEY` already exists in the Windows user environment or is forwarded by Codex `env_vars`, you do not need to put the key in `WSLENV`.
123
+ - Do not point Windows `node.exe` at `dist/index.js` inside a WSL checkout unless that checkout's dependencies were installed by Windows npm. `better-sqlite3` and `sqlite-vec` include native modules, and Windows Node cannot load native binaries installed by Linux npm.
124
+
125
+ Proxy URL, model, and auth mode can be written directly in Codex config; they do not need to go through `WSLENV`:
126
+
127
+ ```toml
107
128
  [mcp_servers.scythe_context.env]
129
+ WSLENV = "PWD/p"
130
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
+ GEMINI_MODEL = "gemini-embedding-2"
132
+ GEMINI_AUTH_MODE = "bearer"
108
133
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
109
134
  ```
110
135
 
111
- ### Third-party v1beta proxy
136
+ ### Optional hardening
137
+
138
+ These settings are not required for a minimal launch, but they help for large repos, first-time `npx` downloads, or a fixed tool surface:
139
+
140
+ ```toml
141
+ [mcp_servers.scythe_context]
142
+ startup_timeout_sec = 40
143
+ tool_timeout_sec = 120
144
+ enabled_tools = [
145
+ "repo_index_status",
146
+ "repo_reindex",
147
+ "repo_context_pack",
148
+ "repo_semantic_search",
149
+ "repo_related_files",
150
+ "gemini_embedding_probe"
151
+ ]
152
+ ```
153
+
154
+ `enabled = true` and `required = false` are usually the default behavior and do not need to be written explicitly.
155
+
156
+ If you really want to pin one default project, set `SCYTHE_CONTEXT_DEFAULT_PROJECT` under `[mcp_servers.scythe_context.env]`. Normal multi-repo usage should not need this; Scythe prefers a tool call's `project_path`, then `PWD`, then the MCP process `cwd`.
157
+
158
+ ### Gemini / v1beta proxy
159
+
160
+ If URL/model/auth are not set, Scythe uses the official Gemini-compatible defaults:
161
+
162
+ - `GEMINI_BASE_URL`: `https://generativelanguage.googleapis.com/v1beta`
163
+ - `GEMINI_MODEL`: `gemini-embedding-2`
164
+ - `GEMINI_AUTH_MODE`: `x-goog-api-key`
165
+ - `GEMINI_OUTPUT_DIMENSIONALITY`: `1536`
166
+
167
+ Official Gemini users usually only need to provide `GEMINI_API_KEY`. Third-party proxies or custom models can override these non-secret settings:
168
+
169
+ For model names and REST endpoint behavior, see Google's official [Gemini embeddings docs](https://ai.google.dev/gemini-api/docs/embeddings).
112
170
 
113
171
  ```toml
114
172
  [mcp_servers.scythe_context.env]
115
173
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
174
+ GEMINI_MODEL = "gemini-embedding-2"
116
175
  GEMINI_AUTH_MODE = "bearer"
117
176
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
118
177
  ```
119
178
 
179
+ Set `GEMINI_API_KEY` in the environment that starts Codex, or in the system environment, and forward it with `env_vars = ["GEMINI_API_KEY"]`. Do not write the key into synced or committed config files except for local throwaway testing.
180
+
120
181
  Supported auth modes:
121
182
 
122
183
  - `x-goog-api-key`
123
184
  - `bearer`
124
185
  - `query`
125
186
 
126
- Set `GEMINI_API_KEY` in the shell or system environment before starting Codex. Do not write API keys into synced or committed config files.
187
+ Official Gemini usually uses `x-goog-api-key`; many third-party proxies use `bearer`. If a proxy requires a query-string key, use `query` and set `GEMINI_API_KEY_QUERY_PARAM` if needed.
188
+
189
+ `WSLENV` is a WSL interop rule, not a Codex-specific field. You only need it when the Windows Codex App opens a WSL repo and the MCP server is launched through Windows Node. Add `GEMINI_API_KEY`, URL, or model variables to `WSLENV` only when they exist only in the WSL environment:
190
+
191
+ ```toml
192
+ [mcp_servers.scythe_context.env]
193
+ WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
194
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
+ GEMINI_MODEL = "gemini-embedding-2"
196
+ GEMINI_AUTH_MODE = "bearer"
197
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
+ ```
127
199
 
128
200
  ## Typical Workflow
129
201
 
@@ -168,6 +240,12 @@ Set `GEMINI_API_KEY` in the shell or system environment before starting Codex. D
168
240
  | `repo_related_files` | Shows symbols, imports, and importedBy for one file. |
169
241
  | `gemini_embedding_probe` | Tests Gemini or proxy compatibility and returns endpoint, latency, error classification, and remediation hints. |
170
242
 
243
+ ## Feature Status
244
+
245
+ Implemented: repo scanning, chunking, SQLite metadata, SQLite FTS5, sqlite-vec, Gemini Embedding 2 provider, semantic/keyword/hybrid search, lightweight symbol/dependency graph, related-file lookup, `repo_context_pack`, provider diagnostics, and index freshness diagnostics.
246
+
247
+ Next: provider capability cache, install/native dependency doctor, keyword-only fallback when embeddings fail, and tree-sitter symbol extraction if needed.
248
+
171
249
  ## Privacy and Local Files
172
250
 
173
251
  - `.scythe-context/`: default index directory, not committed.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Scythe Context MCP
2
2
 
3
3
  [![CI](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/scythe-context-mcp.svg)](https://www.npmjs.com/package/scythe-context-mcp)
4
5
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
6
  [![Node.js >=24.11](https://img.shields.io/badge/Node.js-%3E%3D24.11-339933.svg)](package.json)
6
7
 
@@ -8,47 +9,28 @@
8
9
 
9
10
  Scythe Context MCP 是給 Codex App / Codex CLI 使用的本機程式碼上下文引擎。它在 repo 內建立 SQLite/sqlite-vec 索引,結合語義搜尋、關鍵字搜尋、符號/依賴關係與 context packing,讓 Codex 更快拿到可操作的檔案、行號、片段與相關路徑。
10
11
 
11
- ## 為什麼用它
12
+ ## 核心特性
12
13
 
13
- - **本機優先**:metadata、FTS 與向量索引都存在 repo 內的 `.scythe-context/`。
14
- - **混合搜尋**:結合 Gemini embeddings、SQLite FTS5、path/symbol ranking,避免只靠單一召回方式。
15
- - **Codex 友善輸出**:回傳 line ranges、snippets、match reasons、grep keywords、related files 與 suggested paths。
16
- - **可接自己的 provider**:支援官方 Gemini API,也支援第三方 Gemini-compatible v1beta proxy。
17
- - **可診斷**:內建 provider probe、index freshness、embedding coverage 與可修復建議。
14
+ - 本機優先:metadata、FTS 與向量索引都存在 repo 內的 `.scythe-context/`。
15
+ - 混合搜尋:結合 Gemini embeddings、SQLite FTS5、path/symbol ranking,避免只靠單一召回方式。
16
+ - Codex 友善輸出:回傳 line ranges、snippets、match reasons、grep keywords、related files 與 suggested paths。
17
+ - Gemini-compatible:支援官方 Gemini API,也支援第三方 v1beta proxy。
18
+ - 可診斷:內建 provider probe、index freshness、embedding coverage 與可修復建議。
18
19
 
19
20
  隱私提醒:只有在執行 embedding 相關功能時,query 或 chunk text 才會送到你設定的 Gemini-compatible endpoint。第三方 proxy 應視為可看到這些文字。
20
21
 
21
- ## 功能狀態
22
-
23
- 已完成:
24
-
25
- - repo 掃描、binary/large-file skip、chunking
26
- - SQLite metadata、SQLite FTS5、sqlite-vec 向量索引
27
- - Gemini Embedding 2 provider 與 batch fallback
28
- - semantic / keyword / hybrid search
29
- - 輕量 symbol/dependency graph
30
- - related-file lookup、bounded multi-hop traversal
31
- - `repo_context_pack` context budgeting 與 related snippet packing
32
- - provider diagnostics 與 index freshness diagnostics
33
-
34
- 下一步:
35
-
36
- - provider capability cache
37
- - 更完整的安裝/原生依賴 doctor
38
- - embedding 失敗時的 keyword-only fallback
39
- - 必要時加入 tree-sitter symbol extraction
40
-
41
- ## 安裝
22
+ ## 快速開始
42
23
 
43
- ### npm 安裝
44
-
45
- 使用 npm 安裝全域指令:
24
+ Codex MCP 設定可以直接用 `npx -y scythe-context-mcp`,不一定要先全域安裝。全域安裝主要適合先確認 CLI 可執行,或在 Codex 設定中使用短命令。
46
25
 
47
26
  ```bash
48
27
  npm install -g scythe-context-mcp
28
+ scythe-context-mcp --version
49
29
  ```
50
30
 
51
- ### 從原始碼安裝
31
+ Runtime 目標是 Node.js 24 LTS。Node 26 可能可用,但在進入 LTS 前不作為主要驗收基準。
32
+
33
+ 從原始碼執行:
52
34
 
53
35
  ```bash
54
36
  git clone https://github.com/Lianye-Scythe/scythe-context-mcp.git
@@ -58,72 +40,162 @@ cp .env.example .env
58
40
  npm run build
59
41
  ```
60
42
 
61
- Runtime 目標是 Node.js 24 LTS。Node 26 可能可用,但在進入 LTS 前不作為主要驗收基準。
62
-
63
43
  舊專案名 `repo-beacon-mcp` 已改為 `scythe-context-mcp`。舊的 `REPO_BEACON_*` 環境變數仍作為 fallback 相容,但新設定應改用 `SCYTHE_CONTEXT_*`。
64
44
 
65
45
  ## Codex 設定
66
46
 
67
- ### npm binary
47
+ Codex MCP 設定使用 `command`、`args`、`cwd`、`env` 與 `env_vars` 等欄位;可參考官方文件:[Model Context Protocol](https://developers.openai.com/codex/mcp) 與 [Configuration Reference](https://developers.openai.com/codex/config-reference)。
68
48
 
69
- 如果已用 npm 全域安裝:
49
+ ### 先選執行環境
50
+
51
+ | 情境 | 建議 |
52
+ | --- | --- |
53
+ | Codex 和 MCP 都在 Windows | 用 Windows `node.exe` + Windows npm `npx-cli.js`。 |
54
+ | Codex CLI 在 WSL/Linux/macOS | 用同一個環境內的 `npx` 或 `node dist/index.js`。 |
55
+ | Codex App on Windows 開 WSL repo | 目前 App 的 WSL MCP bridge 仍可能不穩;建議 MCP 跑 Windows Node,再用 `PWD` + `WSLENV` 把目前 WSL workspace 傳給 Windows process。 |
56
+
57
+ ### Native Windows
58
+
59
+ 請先用 `where node` 和 `npm root -g` 確認你自己的 Windows Node/npm 路徑;下面是 nvm4w 安裝位置的範例。
60
+
61
+ 最小設定:
70
62
 
71
63
  ```toml
72
64
  [mcp_servers.scythe_context]
73
- command = "scythe-context-mcp"
74
- enabled = true
75
- required = false
76
- startup_timeout_sec = 20
77
- tool_timeout_sec = 120
65
+ command = 'C:\nvm4w\nodejs\node.exe'
66
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', '-y', 'scythe-context-mcp']
78
67
  env_vars = ["GEMINI_API_KEY"]
79
- enabled_tools = [
80
- "repo_index_status",
81
- "repo_reindex",
82
- "repo_context_pack",
83
- "repo_semantic_search",
84
- "repo_related_files",
85
- "gemini_embedding_probe"
86
- ]
68
+ ```
87
69
 
88
- [mcp_servers.scythe_context.env]
89
- GEMINI_OUTPUT_DIMENSIONALITY = "1536"
70
+ 如果 `scythe-context-mcp` 已全域安裝且 Codex 啟動時的 PATH 能找到它,可以更短:
71
+
72
+ ```toml
73
+ [mcp_servers.scythe_context]
74
+ command = "scythe-context-mcp"
75
+ env_vars = ["GEMINI_API_KEY"]
90
76
  ```
91
77
 
92
- ### 本機 checkout
78
+ ### WSL/Linux/macOS
93
79
 
94
- 如果從原始碼執行:
80
+ Codex 和 MCP server 都在同一個 Unix-like 環境中執行時,最小設定是:
81
+
82
+ ```toml
83
+ [mcp_servers.scythe_context]
84
+ command = "npx"
85
+ args = ["-y", "scythe-context-mcp"]
86
+ env_vars = ["GEMINI_API_KEY"]
87
+ ```
88
+
89
+ 從原始碼執行時:
95
90
 
96
91
  ```toml
97
92
  [mcp_servers.scythe_context]
98
93
  command = "node"
99
94
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
100
- cwd = "/path/to/scythe-context-mcp"
101
- enabled = true
102
- required = false
103
- startup_timeout_sec = 20
104
- tool_timeout_sec = 120
105
95
  env_vars = ["GEMINI_API_KEY"]
96
+ ```
97
+
98
+ 這裡 `args` 指向 Scythe Context MCP 的 build 入口;全域設定不要把 `cwd` 固定到某個 repo。Scythe 會優先使用工具呼叫的 `project_path`,再使用 Codex 啟動 MCP 時的 workspace `PWD` / process `cwd`。只有在專案 scoped `.codex/config.toml`、或你真的想 pin 某個 repo 時,才需要設定 `cwd` 或 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。
99
+
100
+ ### Windows Codex App + WSL repo
101
+
102
+ 目前 Codex App on Windows 的 WSL agent mode 可能無法可靠啟動 WSL-side stdio MCP server。若你遇到 App 裡看不到 MCP tools、MCP handshake timeout、或 config path 混到 Windows/WSL 的問題,建議使用 Windows Node 啟動 MCP,並讓 Scythe Context 透過 WSL path 索引 repo。
103
+
104
+ 最小設定:
106
105
 
106
+ ```toml
107
+ [mcp_servers.scythe_context]
108
+ command = "/mnt/c/nvm4w/nodejs/node.exe"
109
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
+ cwd = "/mnt/c/Users/you"
111
+ env_vars = ["GEMINI_API_KEY", "PWD"]
112
+
113
+ [mcp_servers.scythe_context.env]
114
+ WSLENV = "PWD/p"
115
+ ```
116
+
117
+ 注意:
118
+
119
+ - `cwd` 放 Windows 可用目錄,例如 `/mnt/c/Users/you`。不要把 `cwd` 設成 WSL repo 的 UNC 目錄,因為 npm/npx 可能經過 CMD,而 CMD 不支援 UNC current directory。
120
+ - 這個 `cwd` 不是要索引的 repo,只是 Windows process 的安全啟動位置;真正的 WSL repo 由 `PWD/p` 傳入。
121
+ - `PWD/p` 會讓 WSL 把目前 workspace 路徑轉成 Windows process 可讀的 UNC path;所以不需要每換一個 repo 就改設定。
122
+ - 如果 `GEMINI_API_KEY` 已存在 Windows 使用者環境或由 Codex `env_vars` 直接轉發,就不需要把 key 放進 `WSLENV`。
123
+ - 不要用 Windows `node.exe` 直接執行 WSL checkout 裡的 `dist/index.js`,除非該 checkout 的 dependencies 是用 Windows npm 安裝的。`better-sqlite3` 和 `sqlite-vec` 都包含 native module,Windows Node 不能載入 Linux npm 安裝出的 native binary。
124
+
125
+ 中轉站 URL、model、auth mode 可以直接寫在 Codex config 裡,不需要透過 `WSLENV`:
126
+
127
+ ```toml
107
128
  [mcp_servers.scythe_context.env]
129
+ WSLENV = "PWD/p"
130
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
+ GEMINI_MODEL = "gemini-embedding-2"
132
+ GEMINI_AUTH_MODE = "bearer"
108
133
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
109
134
  ```
110
135
 
111
- ### 第三方 v1beta proxy
136
+ ### 可選強化設定
137
+
138
+ 以下設定不是最小啟動必需,但在大型 repo、首次 `npx` 下載或想固定工具面時有用:
139
+
140
+ ```toml
141
+ [mcp_servers.scythe_context]
142
+ startup_timeout_sec = 40
143
+ tool_timeout_sec = 120
144
+ enabled_tools = [
145
+ "repo_index_status",
146
+ "repo_reindex",
147
+ "repo_context_pack",
148
+ "repo_semantic_search",
149
+ "repo_related_files",
150
+ "gemini_embedding_probe"
151
+ ]
152
+ ```
153
+
154
+ `enabled = true` 和 `required = false` 通常是預設行為,不需要特別寫。
155
+
156
+ 如果你真的想固定某一個預設專案,可以在 `[mcp_servers.scythe_context.env]` 設 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。一般多 repo 使用不需要這樣做;Scythe 會優先使用工具呼叫的 `project_path`,再使用 `PWD`,最後才使用 MCP process 的 `cwd`。
157
+
158
+ ### Gemini / v1beta proxy
159
+
160
+ 如果不填 URL/model/auth,預設會使用官方 Gemini 相容設定:
161
+
162
+ - `GEMINI_BASE_URL`: `https://generativelanguage.googleapis.com/v1beta`
163
+ - `GEMINI_MODEL`: `gemini-embedding-2`
164
+ - `GEMINI_AUTH_MODE`: `x-goog-api-key`
165
+ - `GEMINI_OUTPUT_DIMENSIONALITY`: `1536`
166
+
167
+ 因此官方 Gemini 使用者通常只需要提供 `GEMINI_API_KEY`。第三方中轉站或自訂模型才需要覆蓋下面這些非秘密設定:
168
+
169
+ 模型與 REST endpoint 可對照 Google 官方 [Gemini embeddings 文件](https://ai.google.dev/gemini-api/docs/embeddings)。
112
170
 
113
171
  ```toml
114
172
  [mcp_servers.scythe_context.env]
115
173
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
174
+ GEMINI_MODEL = "gemini-embedding-2"
116
175
  GEMINI_AUTH_MODE = "bearer"
117
176
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
118
177
  ```
119
178
 
179
+ `GEMINI_API_KEY` 建議放在 Codex 啟動環境或系統環境變數,並用 `env_vars = ["GEMINI_API_KEY"]` 轉發給 MCP server。除非只做本機臨時測試,否則不要把 key 寫進可同步或可提交的 config。
180
+
120
181
  支援的 auth mode:
121
182
 
122
183
  - `x-goog-api-key`
123
184
  - `bearer`
124
185
  - `query`
125
186
 
126
- 啟動 Codex 前在 shell 或系統環境中設定 `GEMINI_API_KEY`,避免把 key 寫進可同步或可提交的設定檔。
187
+ 官方 Gemini 通常使用 `x-goog-api-key`;很多第三方中轉站使用 `bearer`。如果中轉站要求 query string key,可以使用 `query`,必要時再設定 `GEMINI_API_KEY_QUERY_PARAM`。
188
+
189
+ `WSLENV` 是 WSL interop 規則,不是 Codex 專用欄位。只有在 Windows Codex App + WSL repo 模式需要讓 WSL 把變數轉交給 Windows Node 時才需要。若 `GEMINI_API_KEY`、URL 或 model 只存在 WSL 環境變數,才把它們加進 `WSLENV`:
190
+
191
+ ```toml
192
+ [mcp_servers.scythe_context.env]
193
+ WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
194
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
+ GEMINI_MODEL = "gemini-embedding-2"
196
+ GEMINI_AUTH_MODE = "bearer"
197
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
+ ```
127
199
 
128
200
  ## 常用工作流
129
201
 
@@ -168,6 +240,12 @@ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
168
240
  | `repo_related_files` | 查看單一檔案的 symbols、imports、importedBy。 |
169
241
  | `gemini_embedding_probe` | 測試 Gemini 或 proxy 相容性,回傳 endpoint、latency、錯誤分類與可修復建議。 |
170
242
 
243
+ ## 功能狀態
244
+
245
+ 已完成:repo 掃描、chunking、SQLite metadata、SQLite FTS5、sqlite-vec、Gemini Embedding 2 provider、semantic/keyword/hybrid search、輕量 symbol/dependency graph、related-file lookup、`repo_context_pack`、provider diagnostics、index freshness diagnostics。
246
+
247
+ 下一步:provider capability cache、安裝/原生依賴 doctor、embedding 失敗時的 keyword-only fallback、必要時加入 tree-sitter symbol extraction。
248
+
171
249
  ## 隱私與本機檔案
172
250
 
173
251
  - `.scythe-context/`: 預設索引目錄,不提交。
package/README.zh-CN.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Scythe Context MCP
2
2
 
3
3
  [![CI](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Lianye-Scythe/scythe-context-mcp/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/scythe-context-mcp.svg)](https://www.npmjs.com/package/scythe-context-mcp)
4
5
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
6
  [![Node.js >=24.11](https://img.shields.io/badge/Node.js-%3E%3D24.11-339933.svg)](package.json)
6
7
 
@@ -8,47 +9,28 @@
8
9
 
9
10
  Scythe Context MCP 是给 Codex App / Codex CLI 使用的本地代码上下文引擎。它在 repo 内建立 SQLite/sqlite-vec 索引,结合语义搜索、关键字搜索、符号/依赖关系与 context packing,让 Codex 更快拿到可操作的文件、行号、片段与相关路径。
10
11
 
11
- ## 为什么用它
12
+ ## 核心特性
12
13
 
13
- - **本地优先**:metadata、FTS 与向量索引都存在 repo 内的 `.scythe-context/`。
14
- - **混合搜索**:结合 Gemini embeddings、SQLite FTS5、path/symbol ranking,避免只靠单一召回方式。
15
- - **Codex 友好输出**:返回 line ranges、snippets、match reasons、grep keywords、related files 与 suggested paths。
16
- - **可接自己的 provider**:支持官方 Gemini API,也支持第三方 Gemini-compatible v1beta proxy。
17
- - **可诊断**:内置 provider probe、index freshness、embedding coverage 与可修复建议。
14
+ - 本地优先:metadata、FTS 与向量索引都存在 repo 内的 `.scythe-context/`。
15
+ - 混合搜索:结合 Gemini embeddings、SQLite FTS5、path/symbol ranking,避免只靠单一召回方式。
16
+ - Codex 友好输出:返回 line ranges、snippets、match reasons、grep keywords、related files 与 suggested paths。
17
+ - Gemini-compatible:支持官方 Gemini API,也支持第三方 v1beta proxy。
18
+ - 可诊断:内置 provider probe、index freshness、embedding coverage 与可修复建议。
18
19
 
19
20
  隐私提醒:只有在执行 embedding 相关功能时,query 或 chunk text 才会发送到你配置的 Gemini-compatible endpoint。第三方 proxy 应视为可以看到这些文字。
20
21
 
21
- ## 功能状态
22
-
23
- 已完成:
24
-
25
- - repo 扫描、binary/large-file skip、chunking
26
- - SQLite metadata、SQLite FTS5、sqlite-vec 向量索引
27
- - Gemini Embedding 2 provider 与 batch fallback
28
- - semantic / keyword / hybrid search
29
- - 轻量 symbol/dependency graph
30
- - related-file lookup、bounded multi-hop traversal
31
- - `repo_context_pack` context budgeting 与 related snippet packing
32
- - provider diagnostics 与 index freshness diagnostics
33
-
34
- 下一步:
35
-
36
- - provider capability cache
37
- - 更完整的安装/原生依赖 doctor
38
- - embedding 失败时的 keyword-only fallback
39
- - 必要时加入 tree-sitter symbol extraction
40
-
41
- ## 安装
22
+ ## 快速开始
42
23
 
43
- ### npm 安装
44
-
45
- 使用 npm 安装全局命令:
24
+ Codex MCP 配置可以直接用 `npx -y scythe-context-mcp`,不一定要先全局安装。全局安装主要适合先确认 CLI 可执行,或在 Codex 配置中使用短命令。
46
25
 
47
26
  ```bash
48
27
  npm install -g scythe-context-mcp
28
+ scythe-context-mcp --version
49
29
  ```
50
30
 
51
- ### 从源码安装
31
+ Runtime 目标是 Node.js 24 LTS。Node 26 可能可用,但在进入 LTS 前不作为主要验收基准。
32
+
33
+ 从源码执行:
52
34
 
53
35
  ```bash
54
36
  git clone https://github.com/Lianye-Scythe/scythe-context-mcp.git
@@ -58,72 +40,162 @@ cp .env.example .env
58
40
  npm run build
59
41
  ```
60
42
 
61
- Runtime 目标是 Node.js 24 LTS。Node 26 可能可用,但在进入 LTS 前不作为主要验收基准。
62
-
63
43
  旧项目名 `repo-beacon-mcp` 已改为 `scythe-context-mcp`。旧的 `REPO_BEACON_*` 环境变量仍作为 fallback 兼容,但新配置应改用 `SCYTHE_CONTEXT_*`。
64
44
 
65
45
  ## Codex 配置
66
46
 
67
- ### npm binary
47
+ Codex MCP 配置使用 `command`、`args`、`cwd`、`env` 与 `env_vars` 等字段;可参考官方文档:[Model Context Protocol](https://developers.openai.com/codex/mcp) 与 [Configuration Reference](https://developers.openai.com/codex/config-reference)。
68
48
 
69
- 如果已用 npm 全局安装:
49
+ ### 先选运行环境
50
+
51
+ | 情境 | 建议 |
52
+ | --- | --- |
53
+ | Codex 和 MCP 都在 Windows | 用 Windows `node.exe` + Windows npm `npx-cli.js`。 |
54
+ | Codex CLI 在 WSL/Linux/macOS | 用同一个环境内的 `npx` 或 `node dist/index.js`。 |
55
+ | Codex App on Windows 打开 WSL repo | 目前 App 的 WSL MCP bridge 仍可能不稳定;建议 MCP 跑 Windows Node,再用 `PWD` + `WSLENV` 把当前 WSL workspace 传给 Windows process。 |
56
+
57
+ ### Native Windows
58
+
59
+ 请先用 `where node` 和 `npm root -g` 确认你自己的 Windows Node/npm 路径;下面是 nvm4w 安装位置的示例。
60
+
61
+ 最小配置:
70
62
 
71
63
  ```toml
72
64
  [mcp_servers.scythe_context]
73
- command = "scythe-context-mcp"
74
- enabled = true
75
- required = false
76
- startup_timeout_sec = 20
77
- tool_timeout_sec = 120
65
+ command = 'C:\nvm4w\nodejs\node.exe'
66
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', '-y', 'scythe-context-mcp']
78
67
  env_vars = ["GEMINI_API_KEY"]
79
- enabled_tools = [
80
- "repo_index_status",
81
- "repo_reindex",
82
- "repo_context_pack",
83
- "repo_semantic_search",
84
- "repo_related_files",
85
- "gemini_embedding_probe"
86
- ]
68
+ ```
87
69
 
88
- [mcp_servers.scythe_context.env]
89
- GEMINI_OUTPUT_DIMENSIONALITY = "1536"
70
+ 如果 `scythe-context-mcp` 已全局安装且 Codex 启动时的 PATH 能找到它,可以更短:
71
+
72
+ ```toml
73
+ [mcp_servers.scythe_context]
74
+ command = "scythe-context-mcp"
75
+ env_vars = ["GEMINI_API_KEY"]
90
76
  ```
91
77
 
92
- ### 本地 checkout
78
+ ### WSL/Linux/macOS
93
79
 
94
- 如果从源码执行:
80
+ Codex 和 MCP server 都在同一个 Unix-like 环境中运行时,最小配置是:
81
+
82
+ ```toml
83
+ [mcp_servers.scythe_context]
84
+ command = "npx"
85
+ args = ["-y", "scythe-context-mcp"]
86
+ env_vars = ["GEMINI_API_KEY"]
87
+ ```
88
+
89
+ 从源码执行时:
95
90
 
96
91
  ```toml
97
92
  [mcp_servers.scythe_context]
98
93
  command = "node"
99
94
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
100
- cwd = "/path/to/scythe-context-mcp"
101
- enabled = true
102
- required = false
103
- startup_timeout_sec = 20
104
- tool_timeout_sec = 120
105
95
  env_vars = ["GEMINI_API_KEY"]
96
+ ```
97
+
98
+ 这里 `args` 指向 Scythe Context MCP 的 build 入口;全局配置不要把 `cwd` 固定到某个 repo。Scythe 会优先使用工具调用的 `project_path`,再使用 Codex 启动 MCP 时的 workspace `PWD` / process `cwd`。只有在项目 scoped `.codex/config.toml`,或你真的想 pin 某个 repo 时,才需要设置 `cwd` 或 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。
99
+
100
+ ### Windows Codex App + WSL repo
101
+
102
+ 目前 Codex App on Windows 的 WSL agent mode 可能无法可靠启动 WSL-side stdio MCP server。如果你遇到 App 里看不到 MCP tools、MCP handshake timeout、或 config path 混到 Windows/WSL 的问题,建议使用 Windows Node 启动 MCP,并让 Scythe Context 通过 WSL path 索引 repo。
103
+
104
+ 最小配置:
106
105
 
106
+ ```toml
107
+ [mcp_servers.scythe_context]
108
+ command = "/mnt/c/nvm4w/nodejs/node.exe"
109
+ args = ['C:\nvm4w\nodejs\node_modules\npm\bin\npx-cli.js', "-y", "scythe-context-mcp"]
110
+ cwd = "/mnt/c/Users/you"
111
+ env_vars = ["GEMINI_API_KEY", "PWD"]
112
+
113
+ [mcp_servers.scythe_context.env]
114
+ WSLENV = "PWD/p"
115
+ ```
116
+
117
+ 注意:
118
+
119
+ - `cwd` 放 Windows 可用目录,例如 `/mnt/c/Users/you`。不要把 `cwd` 设成 WSL repo 的 UNC 目录,因为 npm/npx 可能经过 CMD,而 CMD 不支持 UNC current directory。
120
+ - 这个 `cwd` 不是要索引的 repo,只是 Windows process 的安全启动位置;真正的 WSL repo 由 `PWD/p` 传入。
121
+ - `PWD/p` 会让 WSL 把当前 workspace 路径转成 Windows process 可读的 UNC path;所以不需要每换一个 repo 就改配置。
122
+ - 如果 `GEMINI_API_KEY` 已存在 Windows 用户环境或由 Codex `env_vars` 直接转发,就不需要把 key 放进 `WSLENV`。
123
+ - 不要用 Windows `node.exe` 直接执行 WSL checkout 里的 `dist/index.js`,除非该 checkout 的 dependencies 是用 Windows npm 安装的。`better-sqlite3` 和 `sqlite-vec` 都包含 native module,Windows Node 不能加载 Linux npm 安装出的 native binary。
124
+
125
+ 中转站 URL、model、auth mode 可以直接写在 Codex config 里,不需要通过 `WSLENV`:
126
+
127
+ ```toml
107
128
  [mcp_servers.scythe_context.env]
129
+ WSLENV = "PWD/p"
130
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
131
+ GEMINI_MODEL = "gemini-embedding-2"
132
+ GEMINI_AUTH_MODE = "bearer"
108
133
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
109
134
  ```
110
135
 
111
- ### 第三方 v1beta proxy
136
+ ### 可选强化配置
137
+
138
+ 以下配置不是最小启动必需,但在大型 repo、首次 `npx` 下载或想固定工具面时有用:
139
+
140
+ ```toml
141
+ [mcp_servers.scythe_context]
142
+ startup_timeout_sec = 40
143
+ tool_timeout_sec = 120
144
+ enabled_tools = [
145
+ "repo_index_status",
146
+ "repo_reindex",
147
+ "repo_context_pack",
148
+ "repo_semantic_search",
149
+ "repo_related_files",
150
+ "gemini_embedding_probe"
151
+ ]
152
+ ```
153
+
154
+ `enabled = true` 和 `required = false` 通常是默认行为,不需要特别写。
155
+
156
+ 如果你真的想固定某一个默认项目,可以在 `[mcp_servers.scythe_context.env]` 设置 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。一般多 repo 使用不需要这样做;Scythe 会优先使用工具调用的 `project_path`,再使用 `PWD`,最后才使用 MCP process 的 `cwd`。
157
+
158
+ ### Gemini / v1beta proxy
159
+
160
+ 如果不填 URL/model/auth,默认会使用官方 Gemini 兼容配置:
161
+
162
+ - `GEMINI_BASE_URL`: `https://generativelanguage.googleapis.com/v1beta`
163
+ - `GEMINI_MODEL`: `gemini-embedding-2`
164
+ - `GEMINI_AUTH_MODE`: `x-goog-api-key`
165
+ - `GEMINI_OUTPUT_DIMENSIONALITY`: `1536`
166
+
167
+ 因此官方 Gemini 用户通常只需要提供 `GEMINI_API_KEY`。第三方中转站或自定义模型才需要覆盖下面这些非秘密配置:
168
+
169
+ 模型与 REST endpoint 可对照 Google 官方 [Gemini embeddings 文档](https://ai.google.dev/gemini-api/docs/embeddings)。
112
170
 
113
171
  ```toml
114
172
  [mcp_servers.scythe_context.env]
115
173
  GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
174
+ GEMINI_MODEL = "gemini-embedding-2"
116
175
  GEMINI_AUTH_MODE = "bearer"
117
176
  GEMINI_OUTPUT_DIMENSIONALITY = "1536"
118
177
  ```
119
178
 
179
+ `GEMINI_API_KEY` 建议放在 Codex 启动环境或系统环境变量,并用 `env_vars = ["GEMINI_API_KEY"]` 转发给 MCP server。除非只做本机临时测试,否则不要把 key 写进会同步或会提交的 config。
180
+
120
181
  支持的 auth mode:
121
182
 
122
183
  - `x-goog-api-key`
123
184
  - `bearer`
124
185
  - `query`
125
186
 
126
- 启动 Codex 前在 shell 或系统环境中设置 `GEMINI_API_KEY`,避免把 key 写进会同步或会提交的配置文件。
187
+ 官方 Gemini 通常使用 `x-goog-api-key`;很多第三方中转站使用 `bearer`。如果中转站要求 query string key,可以使用 `query`,必要时再设置 `GEMINI_API_KEY_QUERY_PARAM`。
188
+
189
+ `WSLENV` 是 WSL interop 规则,不是 Codex 专用字段。只有在 Windows Codex App + WSL repo 模式需要让 WSL 把变量转交给 Windows Node 时才需要。若 `GEMINI_API_KEY`、URL 或 model 只存在 WSL 环境变量,才把它们加进 `WSLENV`:
190
+
191
+ ```toml
192
+ [mcp_servers.scythe_context.env]
193
+ WSLENV = "PWD/p:GEMINI_API_KEY/w:GEMINI_BASE_URL/w:GEMINI_MODEL/w:GEMINI_AUTH_MODE/w:GEMINI_OUTPUT_DIMENSIONALITY/w"
194
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
195
+ GEMINI_MODEL = "gemini-embedding-2"
196
+ GEMINI_AUTH_MODE = "bearer"
197
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
198
+ ```
127
199
 
128
200
  ## 常用工作流
129
201
 
@@ -168,6 +240,12 @@ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
168
240
  | `repo_related_files` | 查看单一文件的 symbols、imports、importedBy。 |
169
241
  | `gemini_embedding_probe` | 测试 Gemini 或 proxy 兼容性,返回 endpoint、latency、错误分类与可修复建议。 |
170
242
 
243
+ ## 功能状态
244
+
245
+ 已完成:repo 扫描、chunking、SQLite metadata、SQLite FTS5、sqlite-vec、Gemini Embedding 2 provider、semantic/keyword/hybrid search、轻量 symbol/dependency graph、related-file lookup、`repo_context_pack`、provider diagnostics、index freshness diagnostics。
246
+
247
+ 下一步:provider capability cache、安装/原生依赖 doctor、embedding 失败时的 keyword-only fallback、必要时加入 tree-sitter symbol extraction。
248
+
171
249
  ## 隐私与本地文件
172
250
 
173
251
  - `.scythe-context/`: 默认索引目录,不提交。
package/dist/cli.js ADDED
@@ -0,0 +1,35 @@
1
+ export const PACKAGE_VERSION = "0.1.1";
2
+ export function parseCliArgs(args) {
3
+ if (args.length === 0)
4
+ return { kind: "serve" };
5
+ const [first] = args;
6
+ if (first === "--help" || first === "-h")
7
+ return { kind: "help" };
8
+ if (first === "--version" || first === "-v")
9
+ return { kind: "version" };
10
+ return { kind: "error", message: `Unknown option: ${first}` };
11
+ }
12
+ export function renderHelp() {
13
+ return `Scythe Context MCP ${PACKAGE_VERSION}
14
+
15
+ Local code-context MCP server for Codex App / CLI.
16
+
17
+ Usage:
18
+ scythe-context-mcp Start the MCP stdio server
19
+ scythe-context-mcp --help Show this help
20
+ scythe-context-mcp --version
21
+
22
+ Common Codex MCP config:
23
+ [mcp_servers.scythe_context]
24
+ command = "npx"
25
+ args = ["-y", "scythe-context-mcp"]
26
+ env_vars = ["GEMINI_API_KEY"]
27
+
28
+ Environment:
29
+ PWD Workspace path used when no explicit project is configured
30
+ SCYTHE_CONTEXT_DEFAULT_PROJECT Optional fixed default project override
31
+ GEMINI_API_KEY Gemini or Gemini-compatible API key
32
+ GEMINI_BASE_URL Gemini-compatible base URL, default https://generativelanguage.googleapis.com/v1beta
33
+ GEMINI_OUTPUT_DIMENSIONALITY Embedding dimensions, default 1536
34
+ `;
35
+ }
package/dist/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import path from "node:path";
2
3
  import process from "node:process";
3
4
  import { DEFAULT_INDEXING_LIMITS } from "./indexing/defaults.js";
@@ -32,9 +33,21 @@ function authModeFromEnv(value) {
32
33
  }
33
34
  throw new Error("GEMINI_AUTH_MODE must be one of: x-goog-api-key, bearer, query");
34
35
  }
36
+ function defaultProjectPathFromEnv() {
37
+ const explicitProject = envValue("SCYTHE_CONTEXT_DEFAULT_PROJECT", "REPO_BEACON_DEFAULT_PROJECT");
38
+ if (explicitProject)
39
+ return explicitProject;
40
+ // Codex App on Windows may launch this server through Windows Node while the
41
+ // active workspace is in WSL. In that setup, cwd often has to stay on a
42
+ // Windows directory for npm/npx, while PWD can still carry the workspace path.
43
+ if (process.env.PWD && fs.existsSync(process.env.PWD)) {
44
+ return process.env.PWD;
45
+ }
46
+ return process.cwd();
47
+ }
35
48
  export function loadConfig() {
36
49
  return {
37
- defaultProjectPath: path.resolve(envValue("SCYTHE_CONTEXT_DEFAULT_PROJECT", "REPO_BEACON_DEFAULT_PROJECT") || process.cwd()),
50
+ defaultProjectPath: path.resolve(defaultProjectPathFromEnv()),
38
51
  indexDirName: envValue("SCYTHE_CONTEXT_INDEX_DIR", "REPO_BEACON_INDEX_DIR") || ".scythe-context",
39
52
  indexing: {
40
53
  maxFileBytes: numberFromEnvAlias("SCYTHE_CONTEXT_MAX_FILE_BYTES", "REPO_BEACON_MAX_FILE_BYTES", DEFAULT_INDEXING_LIMITS.maxFileBytes) ??
package/dist/index.js CHANGED
@@ -2,12 +2,27 @@
2
2
  import "dotenv/config";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { PACKAGE_VERSION, parseCliArgs, renderHelp } from "./cli.js";
5
6
  import { loadConfig } from "./config.js";
6
7
  import { registerTools } from "./tools/registerTools.js";
8
+ const cliCommand = parseCliArgs(process.argv.slice(2));
9
+ if (cliCommand.kind === "help") {
10
+ console.log(renderHelp());
11
+ process.exit(0);
12
+ }
13
+ if (cliCommand.kind === "version") {
14
+ console.log(PACKAGE_VERSION);
15
+ process.exit(0);
16
+ }
17
+ if (cliCommand.kind === "error") {
18
+ console.error(cliCommand.message);
19
+ console.error("Run `scythe-context-mcp --help` for usage.");
20
+ process.exit(1);
21
+ }
7
22
  const config = loadConfig();
8
23
  const server = new McpServer({
9
24
  name: "scythe-context-mcp",
10
- version: "0.1.0",
25
+ version: PACKAGE_VERSION,
11
26
  }, {
12
27
  instructions: "Scythe Context is a local code-context MCP server for Codex. Use repo_index_status first, repo_reindex(dry_run=false) when metadata is missing or stale, and repo_context_pack for task lookup. Only set index_embeddings=true when semantic vectors are needed because chunk text is sent to the configured embedding endpoint. Keep max_context_chars and max_related_context_chars bounded. Use repo_semantic_search for ranking/debugging and repo_related_files for a focused file graph.",
13
28
  });
@@ -36,6 +36,29 @@ Scythe Context's server instructions now put the key workflow first:
36
36
 
37
37
  Codex CLI and the IDE extension share MCP configuration through `config.toml`. The Codex app also exposes plugins/MCP-related extension points, but local setup behavior can vary by App settings and installed plugins. For direct reproducible setup, document CLI/IDE `config.toml` first and keep App usage phrased as "Codex local MCP compatible" rather than assuming every App install auto-loads a project config.
38
38
 
39
+ ### Platform setup paths
40
+
41
+ Codex's official MCP configuration model is platform-neutral: a stdio server has `command`, optional `args`, optional `cwd`, `env`, and `env_vars`. The practical launch command should still match the OS that runs Node:
42
+
43
+ - Native Windows: use Windows `node.exe` and npm's `npx-cli.js`, or the short binary command only when Codex can reliably see the npm global binary on PATH.
44
+ - WSL/Linux/macOS: use `npx -y scythe-context-mcp` or `node dist/index.js` from a build produced in that same environment.
45
+ - Windows Codex App with WSL workspaces: use Windows `node.exe` and Windows npm package dependencies, but pass the current WSL workspace through `PWD` and `WSLENV`. Use `SCYTHE_CONTEXT_DEFAULT_PROJECT` only when intentionally pinning one fixed default project.
46
+
47
+ Do not mix a Node runtime from one OS with `node_modules` installed by another OS. This matters because Scythe Context depends on native SQLite modules.
48
+
49
+ ### Windows App with WSL workspaces
50
+
51
+ When Codex App runs a WSL project but MCP servers need to use Windows Node, prefer launching Scythe Context through Windows `node.exe` and npm's `npx-cli.js`:
52
+
53
+ - Current Codex App on Windows may not reliably start WSL-side stdio MCP servers while using WSL agent mode. If MCP tools are missing, handshakes time out, or config paths cross Windows/WSL boundaries, use the Windows Node workaround.
54
+ - Use `command = "/mnt/c/.../node.exe"` with the Windows npm `npx-cli.js` path as the first arg.
55
+ - Keep `cwd` on a Windows-accessible directory such as `/mnt/c/Users/you`; do not use a WSL repo UNC path as `cwd` because npm/npx may invoke CMD and CMD does not support UNC current directories.
56
+ - Forward `PWD` with `PWD/p` in `WSLENV` so WSL converts the current workspace to a UNC path for the Windows process.
57
+ - Include provider variables in `WSLENV` with `/w` only when those values exist in WSL and must be forwarded to Windows Node.
58
+ - Do not point Windows `node.exe` at a WSL checkout's `dist/index.js` unless dependencies were installed by Windows npm in that checkout.
59
+
60
+ The reason is native dependency compatibility. `better-sqlite3` and `sqlite-vec` load platform-specific binaries. Windows Node should load Windows-installed package dependencies, while WSL Node should load WSL-installed package dependencies.
61
+
39
62
  ### AGENTS.md
40
63
 
41
64
  Codex reads `AGENTS.md` before work and layers global plus project guidance. Scythe Context's `AGENTS.md` is intentionally short enough to fit comfortably under the default project instruction limit and focuses on:
@@ -67,6 +90,7 @@ Recommended config should expose all tools by default during development, but `e
67
90
  - Valid Codex TOML examples using `[mcp_servers.scythe_context.env]`.
68
91
  - Secret-safe config examples using `env_vars` for `GEMINI_API_KEY`.
69
92
  - `cwd` in MCP config so relative `.env` loading is predictable.
93
+ - Windows App + WSL setup guidance using Windows `node.exe`, npm `npx-cli.js`, `PWD`, and `WSLENV`.
70
94
  - `startup_timeout_sec` and `tool_timeout_sec` tuned above defaults.
71
95
  - Bounded context output for primary and related snippets.
72
96
  - Explicit opt-in embedding and opt-in related snippet packing.
@@ -88,6 +112,15 @@ Recommended config should expose all tools by default during development, but `e
88
112
  4. Check that `command`, `args`, and `cwd` point to the built repo and that `npm run build` has produced `dist/index.js`.
89
113
  5. If startup is slow on WSL or a cold Node install, raise `startup_timeout_sec`.
90
114
 
115
+ ### Windows App starts but WSL repo indexing fails
116
+
117
+ 1. Prefer the npm package path through Windows `node.exe` plus npm `npx-cli.js`.
118
+ 2. Keep `cwd` on `/mnt/c/...`, not the WSL repo.
119
+ 3. Forward the current workspace with `env_vars = ["PWD", ...]` and `WSLENV = "PWD/p:..."`.
120
+ 4. Forward provider environment variables with `WSLENV` only when they exist in WSL but the MCP server runs through Windows Node.
121
+ 5. Avoid mixing Windows Node with Linux-installed `node_modules`.
122
+ 6. Run the same Windows Node + `npx-cli.js` command from a WSL shell with `cwd` under `/mnt/c/Users/...` to verify the launch path before configuring Codex.
123
+
91
124
  ### Tool starts but embedding fails
92
125
 
93
126
  1. Run `gemini_embedding_probe` with a short test string.
@@ -136,13 +136,14 @@ POST /v1beta/models/gemini-embedding-2:batchEmbedContents
136
136
 
137
137
  ## Codex MCP 設定範例
138
138
 
139
+ 以下範例只示範 Gemini provider 參數。全域 MCP config 不要把 `cwd` 固定到某個 repo;只有 project-scoped `.codex/config.toml` 或刻意 pin 單一 repo 時才需要設定 `cwd` 或 `SCYTHE_CONTEXT_DEFAULT_PROJECT`。
140
+
139
141
  官方 Gemini:
140
142
 
141
143
  ```toml
142
144
  [mcp_servers.scythe_context]
143
145
  command = "node"
144
146
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
145
- cwd = "/path/to/scythe-context-mcp"
146
147
  env_vars = ["GEMINI_API_KEY"]
147
148
 
148
149
  [mcp_servers.scythe_context.env]
@@ -157,7 +158,6 @@ Bearer 中轉站:
157
158
  [mcp_servers.scythe_context]
158
159
  command = "node"
159
160
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
160
- cwd = "/path/to/scythe-context-mcp"
161
161
  env_vars = ["GEMINI_API_KEY"]
162
162
 
163
163
  [mcp_servers.scythe_context.env]
@@ -172,7 +172,6 @@ Query key 中轉站:
172
172
  [mcp_servers.scythe_context]
173
173
  command = "node"
174
174
  args = ["/path/to/scythe-context-mcp/dist/index.js"]
175
- cwd = "/path/to/scythe-context-mcp"
176
175
  env_vars = ["GEMINI_API_KEY"]
177
176
 
178
177
  [mcp_servers.scythe_context.env]
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "scythe-context-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Local MCP context engine for Codex with Gemini Embedding 2 support.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
+ "homepage": "https://github.com/Lianye-Scythe/scythe-context-mcp#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/Lianye-Scythe/scythe-context-mcp/issues"
10
+ },
7
11
  "repository": {
8
12
  "type": "git",
9
13
  "url": "git+https://github.com/Lianye-Scythe/scythe-context-mcp.git"
@@ -33,8 +37,10 @@
33
37
  "build": "tsc -p tsconfig.json",
34
38
  "dev": "tsx src/index.ts",
35
39
  "prepack": "npm run build",
40
+ "smoke": "node dist/index.js --version && node dist/index.js --help",
36
41
  "test": "vitest run",
37
- "typecheck": "tsc -p tsconfig.json --noEmit"
42
+ "typecheck": "tsc -p tsconfig.json --noEmit",
43
+ "verify": "npm test && npm run build && npm run smoke && npm audit --omit=dev && npm pack --dry-run"
38
44
  },
39
45
  "engines": {
40
46
  "node": ">=24.11.0 <27"