feat: 添加 Code Index MCP 提供者支持,更新相关 API 和配置

This commit is contained in:
catlog22
2025-12-25 19:58:42 +08:00
parent e8b9bcae92
commit 203100431b
7 changed files with 293 additions and 13 deletions

View File

@@ -40,7 +40,9 @@ import {
updateClaudeCacheSettings,
getClaudeCliToolsInfo,
addClaudeCustomEndpoint,
removeClaudeCustomEndpoint
removeClaudeCustomEndpoint,
updateCodeIndexMcp,
getCodeIndexMcp
} from '../../tools/claude-cli-tools.js';
export interface RouteContext {
@@ -750,5 +752,45 @@ export async function handleCliRoutes(ctx: RouteContext): Promise<boolean> {
return true;
}
// API: Get Code Index MCP provider
if (pathname === '/api/cli/code-index-mcp' && req.method === 'GET') {
try {
const provider = getCodeIndexMcp(initialPath);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ provider }));
} catch (err) {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: (err as Error).message }));
}
return true;
}
// API: Update Code Index MCP provider
if (pathname === '/api/cli/code-index-mcp' && req.method === 'PUT') {
handlePostRequest(req, res, async (body: unknown) => {
try {
const { provider } = body as { provider: 'codexlens' | 'ace' };
if (!provider || !['codexlens', 'ace'].includes(provider)) {
return { error: 'Invalid provider. Must be "codexlens" or "ace"', status: 400 };
}
const result = updateCodeIndexMcp(initialPath, provider);
if (result.success) {
broadcastToClients({
type: 'CODE_INDEX_MCP_UPDATED',
payload: { provider, timestamp: new Date().toISOString() }
});
return { success: true, provider };
} else {
return { error: result.error, status: 500 };
}
} catch (err) {
return { error: (err as Error).message, status: 500 };
}
});
return true;
}
return false;
}