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:
1 parent
1042f2136b
commit
f19bf10ef3
35 files changed
+4743
-429
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { MCPRepository } from "@/database/repositories/mcp";
|
||||
import { MCPCacheRepository } from "@/database/repositories/mcp-cache";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
console.log("Fetching installed MCPs...");
|
||||
|
||||
// Buscar todos os MCPs instalados com detalhes
|
||||
const installedMcps = MCPRepository.listInstalledWithDetails();
|
||||
|
||||
// Enriquecer com dados do cache do marketplace
|
||||
const enrichedMcps = installedMcps.map((mcp) => {
|
||||
// Tentar encontrar no cache usando diferentes critérios
|
||||
const cacheEntry =
|
||||
MCPCacheRepository.findByOwnerRepo(mcp.owner, mcp.repo) ||
|
||||
MCPCacheRepository.findByName(mcp.name) ||
|
||||
MCPCacheRepository.findById(mcp.id);
|
||||
|
||||
if (cacheEntry) {
|
||||
return {
|
||||
...mcp,
|
||||
// Usar dados do cache quando disponíveis
|
||||
author:
|
||||
cacheEntry.publisher_id !== "Unknown"
|
||||
? cacheEntry.publisher_id
|
||||
: mcp.owner,
|
||||
description: cacheEntry.description || `MCP instalado: ${mcp.name}`,
|
||||
repository: cacheEntry.detail_url || cacheEntry.website,
|
||||
homepage: cacheEntry.website,
|
||||
rating: cacheEntry.rating || 0,
|
||||
totalRatings: cacheEntry.review_cnt || 0,
|
||||
category: cacheEntry.category || "other",
|
||||
tags: cacheEntry.content_tag_list
|
||||
? cacheEntry.content_tag_list.split(",")
|
||||
: [],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...mcp,
|
||||
author: mcp.owner !== "unknown" ? mcp.owner : "Unknown",
|
||||
description: `MCP instalado: ${mcp.name}`,
|
||||
repository: "",
|
||||
homepage: "",
|
||||
rating: 0,
|
||||
totalRatings: 0,
|
||||
category: "other",
|
||||
tags: [],
|
||||
status: mcp.status || "unknown",
|
||||
statusMessage: mcp.status_message || "",
|
||||
};
|
||||
});
|
||||
|
||||
console.log(`Found ${enrichedMcps.length} installed MCPs`);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
mcps: enrichedMcps,
|
||||
total: enrichedMcps.length,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching installed MCPs:", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: error.message || "Failed to fetch installed MCPs",
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user