refactor(api): remove MCP marketplace cache integration
Removed dependencies on MCPCacheRepository and PulseMCPService from MCP routes to simplify installation and listing logic, avoiding reliance on potentially stale cached data and streamlining the codebase. Updated available-for-chat filter to include MCPs without explicit status.
This commit is contained in:
1 parent
4739a13458
commit
f96d4ed696
34 files changed
+260
-3775
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { MCPRepository } from "@/database/repositories/mcp";
|
||||
import { MCPCacheRepository } from "@/database/repositories/mcp-cache";
|
||||
// Marketplace cache removido
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -11,48 +11,20 @@ export async function GET() {
|
||||
// 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 || "",
|
||||
};
|
||||
});
|
||||
// Retornar dados de instalados sem enriquecimento de marketplace
|
||||
const enrichedMcps = installedMcps.map((mcp) => ({
|
||||
...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`);
|
||||
|
||||
|
||||
Reference in new issue
Block a user