feat(mcp): enhance MCP installation with status tracking and custom configs

- Add /mcp-servers/ to .gitignore for MCP server installations
- Extend mcp_installations table with status, logs, and validation fields
- Refactor MCP install route to support custom configs, enable logs, and async installation
- Improve MCPSyncService with promise-based syncing to prevent concurrent operations

This update improves MCP management by adding robust installation tracking, custom configuration support, and better error handling for a more reliable user experience.
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-28 21:59:00 -03:00
1 parent 1042f2136b
commit f19bf10ef3
35 files changed
+4743 -429

No files matched your search

+28 -12
View File
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server";
import { MCPInstallationStatus } from "@/lib/types/mcp";
import { MCPRepository } from "@/database/repositories/mcp";
import { MCPEnvironmentService } from "@/lib/services/mcp-environment";
export async function DELETE(request: Request) {
try {
@@ -13,28 +13,44 @@ export async function DELETE(request: Request) {
);
}
console.log(`Uninstalling MCP: ${mcpId}`);
console.log(`🗑️ Uninstalling MCP: ${mcpId}`);
// Verificar se está instalado
if (!MCPRepository.isInstalled(mcpId)) {
return NextResponse.json({
success: false,
error: `MCP ${mcpId} is not installed`,
}, { status: 400 });
return NextResponse.json(
{
success: false,
error: `MCP ${mcpId} is not installed`,
},
{ status: 400 }
);
}
// Obter ambiente antes de remover do banco
const environment = MCPRepository.getEnvironment(mcpId);
// Remover do banco local
MCPRepository.removeInstallation(mcpId);
const result: MCPInstallationStatus = {
success: true,
message: `MCP ${mcpId} uninstalled successfully`,
mcpId,
};
console.log(`✓ MCP ${mcpId} removed from database`);
// Limpar arquivos de instalação se ambiente existe
if (environment) {
try {
await MCPEnvironmentService.cleanupEnvironment(environment);
console.log(`✓ MCP ${mcpId} environment cleaned up`);
} catch (error: any) {
console.warn(
`⚠️ Could not clean up environment for ${mcpId}: ${error.message}`
);
// Não falhar a desinstalação se limpeza falhar
}
}
return NextResponse.json({
success: true,
installation: result,
message: `MCP ${mcpId} uninstalled successfully`,
mcpId,
});
} catch (error: any) {
console.error("Error uninstalling MCP:", error);