scythe-context-mcp 0.1.0

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/.env.example ADDED
@@ -0,0 +1,21 @@
1
+ GEMINI_API_KEY=
2
+ GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta
3
+ GEMINI_MODEL=gemini-embedding-2
4
+ GEMINI_OUTPUT_DIMENSIONALITY=1536
5
+
6
+ # Third-party proxy compatibility:
7
+ # x-goog-api-key | bearer | query
8
+ GEMINI_AUTH_MODE=x-goog-api-key
9
+ GEMINI_API_KEY_HEADER=x-goog-api-key
10
+ GEMINI_API_KEY_QUERY_PARAM=key
11
+
12
+ SCYTHE_CONTEXT_DEFAULT_PROJECT=
13
+ SCYTHE_CONTEXT_INDEX_DIR=.scythe-context
14
+ SCYTHE_CONTEXT_MAX_FILE_BYTES=524288
15
+ SCYTHE_CONTEXT_TARGET_CHUNK_CHARS=4000
16
+ SCYTHE_CONTEXT_CHUNK_OVERLAP_CHARS=400
17
+ SCYTHE_CONTEXT_MAX_CHUNKS_PER_FILE=80
18
+ SCYTHE_CONTEXT_EMBEDDING_BATCH_SIZE=16
19
+ SCYTHE_CONTEXT_MAX_EMBEDDING_CHUNKS=256
20
+
21
+ # Legacy REPO_BEACON_* variables are still accepted as fallback during migration.
package/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project follows semantic versioning before npm publication where practical.
6
+
7
+ ## [0.1.0] - 2026-06-13
8
+
9
+ ### Added
10
+
11
+ - Local stdio MCP server for Codex App / CLI.
12
+ - Gemini Embedding 2 provider with official Gemini and v1beta proxy compatibility.
13
+ - Configurable auth modes: `x-goog-api-key`, `bearer`, and `query`.
14
+ - SQLite metadata store, SQLite FTS5 keyword index, and sqlite-vec vector index.
15
+ - File scanner, chunker, persistent metadata indexing, and embedding cache.
16
+ - Semantic, keyword, and hybrid search.
17
+ - Lightweight symbol/dependency graph with related-file lookup.
18
+ - `repo_context_pack` with context budgeting, bounded multi-hop traversal, and optional related snippets.
19
+ - `repo_index_status` metadata, embedding, and freshness diagnostics.
20
+ - `gemini_embedding_probe` provider diagnostics with secret-safe errors.
21
+ - Multilingual README files: Traditional Chinese, English, and Simplified Chinese.
22
+ - GitHub CI, issue templates, PR template, security policy, contributing guide, and Apache-2.0 license.
23
+
24
+ ### Notes
25
+
26
+ - Embedding text is sent to the configured Gemini-compatible endpoint only when embedding operations are requested.
27
+ - Local indexes are stored under `.scythe-context/` by default and are not committed.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://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 exercising
24
+ 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 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 cross-claim
83
+ or counterclaim in a lawsuit) alleging that the Work or a Contribution
84
+ incorporated within the Work constitutes direct or contributory patent
85
+ infringement, then any patent licenses granted to You under this
86
+ License for that Work shall terminate as of the date such litigation
87
+ 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 scythe-context-mcp contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.en.md ADDED
@@ -0,0 +1,197 @@
1
+ # Scythe Context MCP
2
+
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
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
+ [![Node.js >=24.11](https://img.shields.io/badge/Node.js-%3E%3D24.11-339933.svg)](package.json)
6
+
7
+ [繁體中文](README.md) | [English](README.en.md) | [简体中文](README.zh-CN.md)
8
+
9
+ 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
+ ## Why Use It
12
+
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.
18
+
19
+ 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
+ ## 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
42
+
43
+ ### From npm
44
+
45
+ Install the CLI globally from npm:
46
+
47
+ ```bash
48
+ npm install -g scythe-context-mcp
49
+ ```
50
+
51
+ ### From source
52
+
53
+ ```bash
54
+ git clone https://github.com/Lianye-Scythe/scythe-context-mcp.git
55
+ cd scythe-context-mcp
56
+ npm install
57
+ cp .env.example .env
58
+ npm run build
59
+ ```
60
+
61
+ Runtime target: Node.js 24 LTS. Node 26 may work, but it is not the baseline until it enters LTS.
62
+
63
+ 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
+
65
+ ## Codex Setup
66
+
67
+ ### npm binary
68
+
69
+ If installed globally from npm:
70
+
71
+ ```toml
72
+ [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
78
+ 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
+ ]
87
+
88
+ [mcp_servers.scythe_context.env]
89
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
90
+ ```
91
+
92
+ ### Local checkout
93
+
94
+ If running from source:
95
+
96
+ ```toml
97
+ [mcp_servers.scythe_context]
98
+ command = "node"
99
+ 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
+ env_vars = ["GEMINI_API_KEY"]
106
+
107
+ [mcp_servers.scythe_context.env]
108
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
109
+ ```
110
+
111
+ ### Third-party v1beta proxy
112
+
113
+ ```toml
114
+ [mcp_servers.scythe_context.env]
115
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
116
+ GEMINI_AUTH_MODE = "bearer"
117
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
118
+ ```
119
+
120
+ Supported auth modes:
121
+
122
+ - `x-goog-api-key`
123
+ - `bearer`
124
+ - `query`
125
+
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.
127
+
128
+ ## Typical Workflow
129
+
130
+ 1. Check index status first:
131
+
132
+ ```text
133
+ repo_index_status
134
+ ```
135
+
136
+ 2. If metadata is missing or freshness is stale:
137
+
138
+ ```text
139
+ repo_reindex({ "dry_run": false })
140
+ ```
141
+
142
+ 3. Build embeddings only when semantic search or context packs need vectors:
143
+
144
+ ```text
145
+ repo_reindex({ "dry_run": false, "index_embeddings": true })
146
+ ```
147
+
148
+ 4. Ask Codex for task-oriented context:
149
+
150
+ ```text
151
+ repo_context_pack({ "query": "where is auth token validation handled?" })
152
+ ```
153
+
154
+ 5. Expand imports / reverse imports for a matched file:
155
+
156
+ ```text
157
+ repo_related_files({ "path": "src/server/auth.ts" })
158
+ ```
159
+
160
+ ## MCP Tools
161
+
162
+ | Tool | Purpose |
163
+ | --- | --- |
164
+ | `repo_index_status` | Shows index path, metadata/embedding coverage, freshness diagnostics, and recommended actions. |
165
+ | `repo_reindex` | Scans the project and writes metadata; calls the embedding provider only when `index_embeddings=true`. |
166
+ | `repo_context_pack` | Packs primary snippets, match reasons, related files, and suggested paths for a task query. |
167
+ | `repo_semantic_search` | Runs hybrid or semantic search over indexed chunks; useful for ranking diagnostics. |
168
+ | `repo_related_files` | Shows symbols, imports, and importedBy for one file. |
169
+ | `gemini_embedding_probe` | Tests Gemini or proxy compatibility and returns endpoint, latency, error classification, and remediation hints. |
170
+
171
+ ## Privacy and Local Files
172
+
173
+ - `.scythe-context/`: default index directory, not committed.
174
+ - `.repo-beacon/`: legacy index directory name, still ignored.
175
+ - `local/`: private API test files, reference HTML, screenshots, and other local-only material.
176
+ - `.env`: local configuration, not committed.
177
+
178
+ Do not include API keys, proxy tokens, private source snippets, or index databases in issues, PRs, or public logs.
179
+
180
+ ## Documentation
181
+
182
+ - [Architecture](docs/architecture.md)
183
+ - [Development Plan](docs/development-plan.md)
184
+ - [Gemini Compatibility](docs/gemini-compatibility.md)
185
+ - [Tech Stack](docs/tech-stack.md)
186
+ - [Codex Integration Review](docs/codex-integration.md)
187
+
188
+ ## Development and Publishing Checks
189
+
190
+ ```bash
191
+ npm test
192
+ npm run build
193
+ npm audit --omit=dev
194
+ npm pack --dry-run
195
+ ```
196
+
197
+ Confirm the package does not include `.env`, `.scythe-context/`, `.repo-beacon/`, `local/`, API keys, or private reference files.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Scythe Context MCP
2
+
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
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
5
+ [![Node.js >=24.11](https://img.shields.io/badge/Node.js-%3E%3D24.11-339933.svg)](package.json)
6
+
7
+ [繁體中文](README.md) | [English](README.en.md) | [简体中文](README.zh-CN.md)
8
+
9
+ Scythe Context MCP 是給 Codex App / Codex CLI 使用的本機程式碼上下文引擎。它在 repo 內建立 SQLite/sqlite-vec 索引,結合語義搜尋、關鍵字搜尋、符號/依賴關係與 context packing,讓 Codex 更快拿到可操作的檔案、行號、片段與相關路徑。
10
+
11
+ ## 為什麼用它
12
+
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 與可修復建議。
18
+
19
+ 隱私提醒:只有在執行 embedding 相關功能時,query 或 chunk text 才會送到你設定的 Gemini-compatible endpoint。第三方 proxy 應視為可看到這些文字。
20
+
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
+ ## 安裝
42
+
43
+ ### 從 npm 安裝
44
+
45
+ 使用 npm 安裝全域指令:
46
+
47
+ ```bash
48
+ npm install -g scythe-context-mcp
49
+ ```
50
+
51
+ ### 從原始碼安裝
52
+
53
+ ```bash
54
+ git clone https://github.com/Lianye-Scythe/scythe-context-mcp.git
55
+ cd scythe-context-mcp
56
+ npm install
57
+ cp .env.example .env
58
+ npm run build
59
+ ```
60
+
61
+ Runtime 目標是 Node.js 24 LTS。Node 26 可能可用,但在進入 LTS 前不作為主要驗收基準。
62
+
63
+ 舊專案名 `repo-beacon-mcp` 已改為 `scythe-context-mcp`。舊的 `REPO_BEACON_*` 環境變數仍作為 fallback 相容,但新設定應改用 `SCYTHE_CONTEXT_*`。
64
+
65
+ ## Codex 設定
66
+
67
+ ### npm binary
68
+
69
+ 如果已用 npm 全域安裝:
70
+
71
+ ```toml
72
+ [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
78
+ 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
+ ]
87
+
88
+ [mcp_servers.scythe_context.env]
89
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
90
+ ```
91
+
92
+ ### 本機 checkout
93
+
94
+ 如果從原始碼執行:
95
+
96
+ ```toml
97
+ [mcp_servers.scythe_context]
98
+ command = "node"
99
+ 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
+ env_vars = ["GEMINI_API_KEY"]
106
+
107
+ [mcp_servers.scythe_context.env]
108
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
109
+ ```
110
+
111
+ ### 第三方 v1beta proxy
112
+
113
+ ```toml
114
+ [mcp_servers.scythe_context.env]
115
+ GEMINI_BASE_URL = "https://your-proxy.example.com/v1beta"
116
+ GEMINI_AUTH_MODE = "bearer"
117
+ GEMINI_OUTPUT_DIMENSIONALITY = "1536"
118
+ ```
119
+
120
+ 支援的 auth mode:
121
+
122
+ - `x-goog-api-key`
123
+ - `bearer`
124
+ - `query`
125
+
126
+ 啟動 Codex 前在 shell 或系統環境中設定 `GEMINI_API_KEY`,避免把 key 寫進可同步或可提交的設定檔。
127
+
128
+ ## 常用工作流
129
+
130
+ 1. 先檢查索引狀態:
131
+
132
+ ```text
133
+ repo_index_status
134
+ ```
135
+
136
+ 2. 如果 metadata 不存在或 freshness 顯示 stale:
137
+
138
+ ```text
139
+ repo_reindex({ "dry_run": false })
140
+ ```
141
+
142
+ 3. 需要語義搜尋或 context pack 時,再建立 embeddings:
143
+
144
+ ```text
145
+ repo_reindex({ "dry_run": false, "index_embeddings": true })
146
+ ```
147
+
148
+ 4. 讓 Codex 針對任務拿上下文:
149
+
150
+ ```text
151
+ repo_context_pack({ "query": "where is auth token validation handled?" })
152
+ ```
153
+
154
+ 5. 對某個命中檔案展開 imports / reverse imports:
155
+
156
+ ```text
157
+ repo_related_files({ "path": "src/server/auth.ts" })
158
+ ```
159
+
160
+ ## MCP 工具
161
+
162
+ | Tool | 用途 |
163
+ | --- | --- |
164
+ | `repo_index_status` | 查看 index path、metadata/embedding coverage、freshness diagnostics 與建議動作。 |
165
+ | `repo_reindex` | 掃描專案並寫入 metadata;設定 `index_embeddings=true` 時才會呼叫 embedding provider。 |
166
+ | `repo_context_pack` | 針對任務查詢打包 primary snippets、match reasons、related files 與 suggested paths。 |
167
+ | `repo_semantic_search` | 對已索引 chunks 做 hybrid 或 semantic search,適合排查 ranking。 |
168
+ | `repo_related_files` | 查看單一檔案的 symbols、imports、importedBy。 |
169
+ | `gemini_embedding_probe` | 測試 Gemini 或 proxy 相容性,回傳 endpoint、latency、錯誤分類與可修復建議。 |
170
+
171
+ ## 隱私與本機檔案
172
+
173
+ - `.scythe-context/`: 預設索引目錄,不提交。
174
+ - `.repo-beacon/`: 舊索引目錄名稱,仍被 ignore。
175
+ - `local/`: 私密 API 測試檔、參考 HTML、截圖等本機資料,不提交。
176
+ - `.env`: 本機設定,不提交。
177
+
178
+ 不要把 API key、proxy token、私有程式碼片段或 index database 放進 issue、PR 或公開 logs。
179
+
180
+ ## 文件
181
+
182
+ - [架構設計](docs/architecture.md)
183
+ - [開發計畫](docs/development-plan.md)
184
+ - [Gemini 相容性](docs/gemini-compatibility.md)
185
+ - [技術棧](docs/tech-stack.md)
186
+ - [Codex 整合審查](docs/codex-integration.md)
187
+
188
+ ## 開發與發佈檢查
189
+
190
+ ```bash
191
+ npm test
192
+ npm run build
193
+ npm audit --omit=dev
194
+ npm pack --dry-run
195
+ ```
196
+
197
+ 確認 package 不包含 `.env`、`.scythe-context/`, `.repo-beacon/`, `local/`, API key 或私密參考檔。