Adjust the code according to the suggestions
This commit is contained in:
@@ -547,11 +547,22 @@ function isApiKeySet(providerName, session = null, projectRoot = null) {
|
|||||||
* @returns {boolean} True if the key exists and is not a placeholder, false otherwise.
|
* @returns {boolean} True if the key exists and is not a placeholder, false otherwise.
|
||||||
*/
|
*/
|
||||||
function getMcpApiKeyStatus(providerName, projectRoot = null) {
|
function getMcpApiKeyStatus(providerName, projectRoot = null) {
|
||||||
const mcpConfigPath = path.join(
|
// 1. 恢复rootDir检查和警告
|
||||||
findProjectRoot() || '.',
|
const rootDir = projectRoot || findProjectRoot();
|
||||||
'.cursor',
|
if (!rootDir) {
|
||||||
'mcp.json'
|
console.warn(
|
||||||
);
|
chalk.yellow('Warning: Could not find project root to check mcp.json.')
|
||||||
|
);
|
||||||
|
return false; // Cannot check without root
|
||||||
|
}
|
||||||
|
const mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json');
|
||||||
|
|
||||||
|
// 2. 文件存在性检查,保留注释warn
|
||||||
|
if (!fs.existsSync(mcpConfigPath)) {
|
||||||
|
// console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.'));
|
||||||
|
return false; // File doesn't exist
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8');
|
const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8');
|
||||||
const mcpConfig = JSON.parse(mcpConfigRaw);
|
const mcpConfig = JSON.parse(mcpConfigRaw);
|
||||||
|
|||||||
Reference in New Issue
Block a user