@lorrylurui/code-intelligence-mcp 1.1.9 → 1.1.11

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 (2) hide show
  1. package/dist/config/env.js +87 -3
  2. package/package.json +1 -1
@@ -24,11 +24,11 @@ const MCP_SERVER_ENV_PATH = path.resolve(MCP_SERVER_ROOT, '.env');
24
24
  * 行为:优先使用第三方显式设置的值,否则保留 MCP Server 本地配置
25
25
  */
26
26
  export function loadProjectDotenv(projectRoot) {
27
- // 先确保加载 MCP Server 本地的 .env(如果尚未加载)
28
- if (existsSync(MCP_SERVER_ENV_PATH) && !process.env.MYSQL_ENABLED) {
27
+ // 始终确保 MCP Server 本地的 .env 被加载(补充加载,确保有默认值)
28
+ if (existsSync(MCP_SERVER_ENV_PATH)) {
29
29
  dotenv.config({
30
30
  path: MCP_SERVER_ENV_PATH,
31
- override: false,
31
+ override: false, // 不覆盖已存在的变量
32
32
  });
33
33
  }
34
34
  const envPath = path.resolve(projectRoot, '.env');
@@ -113,3 +113,87 @@ export function validateEnv() {
113
113
  }
114
114
  }
115
115
  }
116
+ // import dotenv from 'dotenv';
117
+ // import path from 'node:path';
118
+ // import { fileURLToPath } from 'node:url';
119
+ // import { existsSync, readFileSync } from 'node:fs';
120
+ // const __dirname = path.dirname(fileURLToPath(import.meta.url));
121
+ // const projectRoot = path.resolve(__dirname, '../../');
122
+ // // 解析命令行参数 --key=value 格式,注入到 process.env
123
+ // for (const arg of process.argv) {
124
+ // const match = arg.match(/^--([A-Z_][A-Z0-9_]*)=(.+)$/);
125
+ // if (match) {
126
+ // process.env[match[1]] = match[2];
127
+ // }
128
+ // }
129
+ // // 加载本地 .env(外部传入的 env 已经在 process.env 中,override: false 不会覆盖它们)
130
+ // dotenv.config({
131
+ // path: path.resolve(projectRoot, '.env'),
132
+ // override: false,
133
+ // });
134
+ // // 尝试从第三方项目目录加载 .env,按变量维度覆盖(只覆盖第三方明确配置的变量)
135
+ // const clientProjectRoot = process.env.INDEX_ROOT || process.cwd();
136
+ // const clientEnvPath = path.resolve(clientProjectRoot, '.env');
137
+ // if (existsSync(clientEnvPath)) {
138
+ // console.error(
139
+ // `[Config] Merging .env from client project root: ${clientProjectRoot}`
140
+ // );
141
+ // // 手动解析第三方 .env,只覆盖其明确配置的变量
142
+ // const clientEnvContent = readFileSync(clientEnvPath, 'utf-8');
143
+ // for (const line of clientEnvContent.split('\n')) {
144
+ // const trimmed = line.trim();
145
+ // if (!trimmed || trimmed.startsWith('#')) continue;
146
+ // const eqIdx = trimmed.indexOf('=');
147
+ // if (eqIdx === -1) continue;
148
+ // const key = trimmed.slice(0, eqIdx).trim();
149
+ // const value = trimmed.slice(eqIdx + 1).trim();
150
+ // // 移除引号
151
+ // const cleanValue = value.replace(/^["']|["']$/g, '');
152
+ // if (key) {
153
+ // process.env[key] = cleanValue;
154
+ // }
155
+ // }
156
+ // }
157
+ // // 外部传入的 env 已在上一步保留,这里确保环境变量已正确设置
158
+ // for (const arg of process.argv) {
159
+ // const match = arg.match(/^--([A-Z_][A-Z0-9_]*)=(.+)$/);
160
+ // if (match) {
161
+ // process.env[match[1]] = match[2];
162
+ // }
163
+ // }
164
+ // const requiredWhenEnabled = [
165
+ // 'MYSQL_HOST',
166
+ // 'MYSQL_USER',
167
+ // 'MYSQL_DATABASE',
168
+ // ] as const;
169
+ // console.error(
170
+ // `[Config] MYSQL_ENABLED: ${process.env.MYSQL_ENABLED},
171
+ // MYSQL_HOST: ${process.env.MYSQL_HOST},
172
+ // MYSQL_USER: ${process.env.MYSQL_USER},
173
+ // MYSQL_DATABASE: ${process.env.MYSQL_DATABASE},
174
+ // EMBEDDING_SERVICE_URL: ${process.env.EMBEDDING_SERVICE_URL},
175
+ // MYSQL_SYMBOLS_TABLE: ${process.env.MYSQL_SYMBOLS_TABLE}
176
+ // `
177
+ // );
178
+ // export const env = {
179
+ // mysqlEnabled: process.env.MYSQL_ENABLED === 'true',
180
+ // mysqlHost: process.env.MYSQL_HOST ?? '127.0.0.1',
181
+ // mysqlPort: Number(process.env.MYSQL_PORT ?? '3306'),
182
+ // mysqlUser: process.env.MYSQL_USER ?? 'root',
183
+ // mysqlPassword: process.env.MYSQL_PASSWORD ?? '',
184
+ // mysqlDatabase: process.env.MYSQL_DATABASE ?? 'code_intelligence',
185
+ // /** symbols 表名,可通过 MYSQL_SYMBOLS_TABLE 环境变量配置 */
186
+ // mysqlSymbolsTable: process.env.MYSQL_SYMBOLS_TABLE ?? 'symbols',
187
+ // /** Phase 5:指向 Python FastAPI 嵌入服务根 URL,如 http://127.0.0.1:8765 */
188
+ // embeddingServiceUrl: (process.env.EMBEDDING_SERVICE_URL ?? '').trim(),
189
+ // };
190
+ // export function validateEnv(): void {
191
+ // if (!env.mysqlEnabled) {
192
+ // return;
193
+ // }
194
+ // for (const key of requiredWhenEnabled) {
195
+ // if (!process.env[key]) {
196
+ // throw new Error(`Missing environment variable: ${key}`);
197
+ // }
198
+ // }
199
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lorrylurui/code-intelligence-mcp",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "private": false,
5
5
  "description": "MCP server 提供仓库内可复用代码块(ts/tsx/js/jsx/css/less)的索引和查询能力,支持基于代码上下文的智能推荐。",
6
6
  "type": "module",