- 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.
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { MCPRepository } from "@/database/repositories/mcp";
|
|
|
|
export async function PUT(request: Request) {
|
|
try {
|
|
const { mcpId, newConfig } = await request.json();
|
|
|
|
if (!mcpId) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "MCP ID is required" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
if (!newConfig) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "New configuration is required" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
console.log(`Updating config for MCP: ${mcpId}`);
|
|
|
|
// Verificar se o MCP está instalado
|
|
if (!MCPRepository.isInstalled(mcpId)) {
|
|
return NextResponse.json(
|
|
{
|
|
success: false,
|
|
error: `MCP ${mcpId} is not installed`,
|
|
},
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
// Atualizar configuração
|
|
MCPRepository.updateConfig(mcpId, newConfig);
|
|
|
|
console.log(`MCP ${mcpId} configuration updated successfully`);
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: `MCP ${mcpId} configuration updated successfully`,
|
|
mcpId,
|
|
});
|
|
} catch (error: any) {
|
|
console.error("Error updating MCP configuration:", error);
|
|
return NextResponse.json(
|
|
{ success: false, error: error.message || "Failed to update MCP configuration" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|