Corregir endpoint POST para crear variables en Gitea
All checks were successful
build-and-deploy / build (push) Successful in 11s
build-and-deploy / deploy (push) Successful in 4s

- El endpoint POST requiere el nombre de la variable en la ruta
- Cambiar de POST /basePath a POST /basePath/{name}
- Esto resuelve el error 405 (Method Not Allowed)
This commit is contained in:
2025-10-16 17:34:08 -06:00
parent bfb6c71379
commit a162292e70

View File

@@ -401,9 +401,10 @@ server.registerTool(
});
notificationMessage = `✓ Variable '${name}' actualizada exitosamente`;
} else {
result = await giteaRequest(basePath, {
// POST también requiere el nombre en la ruta, no en el body
result = await giteaRequest(`${basePath}/${name}`, {
method: 'POST',
body: JSON.stringify({ name, value }),
body: JSON.stringify({ value }),
});
notificationMessage = `✓ Variable '${name}' creada exitosamente (no existía previamente)`;
}
@@ -481,90 +482,6 @@ 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());