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:
Evandro Fonseca Junior committed 2025-10-29 15:35:15 -03:00
1 parent 4739a13458
commit f96d4ed696
34 files changed
+260 -3775

No files matched your search

+2 -61
View File
@@ -1,6 +1,5 @@
import { NextResponse } from "next/server";
import { DeepNLPService } from "@/lib/services/deepnlp";
import { MCPCacheRepository } from "@/database/repositories/mcp-cache";
export async function GET(request: Request) {
try {
@@ -16,67 +15,9 @@ export async function GET(request: Request) {
console.log(`Fetching server config for: ${mcpId}`);
// Primeiro, tentar buscar do cache local (PulseMCP)
const [owner, repo] = mcpId.includes("/") ? mcpId.split("/") : ["", mcpId];
// Marketplace removido: pular cache local
// Buscar no cache usando ID completo ou apenas repo
const cachedMcps = MCPCacheRepository.search({
query: repo,
limit: 1,
});
if (cachedMcps.length > 0) {
const cachedMCP = cachedMcps[0];
// Verificar se tem configuração no ext_info
if (cachedMCP.ext_info) {
try {
const extInfo =
typeof cachedMCP.ext_info === "string"
? JSON.parse(cachedMCP.ext_info)
: cachedMCP.ext_info;
if (
extInfo.config &&
Array.isArray(extInfo.config) &&
extInfo.config.length > 0
) {
console.log(`Found config in cache for ${mcpId}`);
// Converter formato PulseMCP para formato esperado pelo modal
const serverConfig = extInfo.config.find(
(c: any) => c.type === "server"
);
const envConfig = extInfo.config.find((c: any) => c.type === "env");
if (serverConfig) {
// Usar o nome do servidor config como chave
const serverName =
serverConfig.name || extInfo.package_name || cachedMCP.id;
const formattedConfig = {
mcpServers: {
[serverName]: {
command: serverConfig.command || "npx",
args: serverConfig.args || [],
env: envConfig?.variables || {},
},
},
};
return NextResponse.json({
success: true,
config: formattedConfig,
source: "pulsemcp",
});
}
}
} catch (error) {
console.error("Error parsing ext_info:", error);
}
}
}
// Se não encontrou no cache, tentar DeepNLP como fallback
// Tentar DeepNLP
try {
const serverConfig = await DeepNLPService.getServerConfig(mcpId);