feat(mcp): add GitHub repo support and tools display in MCP cards

- Support installing MCP servers from GitHub repos by converting 'github:user/repo' to 'git+https://github.com/user/repo.git' to avoid SSH issues and improve npm compatibility
- Display available tools in MCPCard with badges, showing up to 6 tools and total count for better visibility of server capabilities
- Remove unused onViewDetails prop and make uninstall button full-width for improved UI consistency
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-28 22:17:19 -03:00
1 parent f19bf10ef3
commit 745746afa9
8 files changed
+227 -60

No files matched your search

+2 -1
View File
@@ -170,11 +170,12 @@ export class MCPInstallerService {
});
// Construir ambiente
// Para NPM, executar npx do diretório onde foi instalado (não usa --prefix que não funciona)
const environment: MCPEnvironment = {
type: "npm",
path: npmDir,
executable: "npx",
args: ["--prefix", npmDir, packageName],
args: [packageName],
};
return environment;
+14
View File
@@ -32,11 +32,18 @@ export class MCPValidatorService {
...(config.env || {}),
};
// Para NPM, adicionar node_modules/.bin ao PATH para encontrar binários locais
if (environment.type === "npm" && environment.path) {
const nodeBinPath = `${environment.path}/node_modules/.bin`;
env.PATH = `${nodeBinPath}:${env.PATH || process.env.PATH}`;
}
console.log(`🧪 Testing MCP server: ${command} ${args.join(" ")}`);
try {
// Spawnar processo do servidor MCP
const serverProcess = spawn(command, args, {
cwd: environment.path, // Executar do diretório de instalação
env,
stdio: ["pipe", "pipe", "pipe"],
});
@@ -232,8 +239,15 @@ export class MCPValidatorService {
...(config.env || {}),
};
// Para NPM, adicionar node_modules/.bin ao PATH para encontrar binários locais
if (environment.type === "npm" && environment.path) {
const nodeBinPath = `${environment.path}/node_modules/.bin`;
env.PATH = `${nodeBinPath}:${env.PATH || process.env.PATH}`;
}
try {
const serverProcess = spawn(command, args, {
cwd: environment.path, // Executar do diretório de instalação
env,
stdio: ["pipe", "pipe", "pipe"],
});
+13 -2
View File
@@ -137,10 +137,21 @@ export async function spawnWithProgress(
/**
* Sanitiza nome de pacote para evitar command injection
* Suporta formatos: @scope/pkg, github:user/repo, git+https://..., etc.
*/
export function sanitizePackageName(packageName: string): string {
// Remove caracteres perigosos, mantém apenas alphanumeric, @, /, -, _
return packageName.replace(/[^a-zA-Z0-9@/\-_.]/g, "");
// URLs git+https:// devem ser preservadas completamente (são seguras)
if (
packageName.startsWith("git+https://") ||
packageName.startsWith("git+http://")
) {
// Apenas validar que parece uma URL válida
return packageName;
}
// Remove caracteres perigosos, mantém alphanumeric, @, :, +, /, -, _, .
// Suporta: @scope/pkg, github:user/repo
return packageName.replace(/[^a-zA-Z0-9@:+/\-_.]/g, "");
}
/**