diff --git a/mcp-gitea-server/src/index.ts b/mcp-gitea-server/src/index.ts index cc30832..42a8107 100644 --- a/mcp-gitea-server/src/index.ts +++ b/mcp-gitea-server/src/index.ts @@ -481,6 +481,90 @@ server.registerTool( } ); +// ==================== HERRAMIENTA 7: gitea_transfer_manage ==================== +server.registerTool( + 'gitea_transfer_manage', + { + title: 'Gestionar Transferencias de Repositorios Gitea', + description: 'Gestiona transferencias: status (ver estado), accept (aceptar como recipient), reject (rechazar como owner). Requiere owner y repo.', + inputSchema: { + action: z.enum(['status', 'accept', 'reject']).describe('Acción a realizar'), + owner: z.string().describe('Propietario actual del repo'), + repo: z.string().describe('Nombre del repo'), + }, + outputSchema: { + result: z.any().describe('Resultado de la operación') + } + }, + async ({ action, owner, repo }) => { + try { + let result; + let notification = ''; + + switch (action) { + case 'status': + // Obtener información del repo incluyendo estado de transferencia + const repoData: any = await giteaRequest(`/repos/${owner}/${repo}`); + const transferStatus = repoData.repo_transfer; + + if (transferStatus) { + notification = `⚠️ Hay una transferencia pendiente: ${transferStatus.doer.login} → ${transferStatus.recipient.login}`; + result = { + has_pending_transfer: true, + transfer: transferStatus, + _notification: notification + }; + } else { + notification = '✓ No hay transferencias pendientes'; + result = { + has_pending_transfer: false, + _notification: notification + }; + } + break; + + case 'accept': + // Aceptar transferencia (como recipient) + result = await giteaRequest(`/repos/${owner}/${repo}/transfer/accept`, { + method: 'POST', + }); + notification = `✓ Transferencia aceptada exitosamente para '${owner}/${repo}'`; + result = typeof result === 'object' && result !== null + ? { ...result, _notification: notification } + : { success: true, _notification: notification }; + break; + + case 'reject': + // Rechazar/cancelar transferencia (como owner) + result = await giteaRequest(`/repos/${owner}/${repo}/transfer`, { + method: 'DELETE', + }); + notification = `✓ Transferencia rechazada/cancelada exitosamente para '${owner}/${repo}'`; + result = typeof result === 'object' && result !== null + ? { ...result, _notification: notification } + : { success: true, _notification: notification }; + break; + } + + return { + content: [{ + type: 'text', + text: JSON.stringify(result, null, 2) + }], + structuredContent: { + result + } + }; + } catch (error) { + const errorMsg = error instanceof Error ? error.message : 'Error desconocido'; + return { + content: [{ type: 'text', text: `Error: ${errorMsg}` }], + isError: true + }; + } + } +); + // ==================== SERVIDOR EXPRESS ==================== const app = express(); app.use(express.json());