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

+43 -3
View File
@@ -61,10 +61,20 @@ export class PulseMCPService {
/**
* Buscar todos os servidores MCP na API PulseMCP (sem parâmetros)
* Com retry automático e backoff exponencial para rate limiting
*/
static async getAllServers(): Promise<PulseMCPResponse> {
static async getAllServers(retryCount = 0): Promise<PulseMCPResponse> {
const maxRetries = 3;
const baseDelay = 2000; // 2 segundos base
try {
console.log("📡 Fetching all servers from PulseMCP API...");
if (retryCount > 0) {
console.log(
`📡 Retry ${retryCount}/${maxRetries} - Fetching from PulseMCP API...`
);
} else {
console.log("📡 Fetching all servers from PulseMCP API...");
}
const response = await fetch(`${PULSEMCP_API_BASE}/servers`, {
method: "GET",
@@ -77,6 +87,19 @@ export class PulseMCPService {
});
if (!response.ok) {
// Se for 429 (Too Many Requests), tentar novamente com backoff
if (response.status === 429 && retryCount < maxRetries) {
const delay = baseDelay * Math.pow(2, retryCount); // Backoff exponencial
console.warn(
`⚠️ Rate limit hit (429). Waiting ${delay}ms before retry ${
retryCount + 1
}/${maxRetries}...`
);
await new Promise((resolve) => setTimeout(resolve, delay));
return this.getAllServers(retryCount + 1);
}
throw new Error(
`PulseMCP API error: ${response.status} ${response.statusText}`
);
@@ -89,9 +112,26 @@ export class PulseMCPService {
return data;
} catch (error) {
// Se for erro de rate limit e ainda temos retries, tentar novamente
if (
error instanceof Error &&
error.message.includes("429") &&
retryCount < maxRetries
) {
const delay = baseDelay * Math.pow(2, retryCount);
console.warn(
`⚠️ Rate limit error. Waiting ${delay}ms before retry ${
retryCount + 1
}/${maxRetries}...`
);
await new Promise((resolve) => setTimeout(resolve, delay));
return this.getAllServers(retryCount + 1);
}
console.error("❌ Error calling PulseMCP API:", error);
throw new Error(
`Failed to fetch MCPs: ${
`Failed to fetch MCPs after ${retryCount + 1} attempts: ${
error instanceof Error ? error.message : "Unknown error"
}`
);