fix: Autenticación por token para MCP Server
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 36s

- Ruta /api/mcp agregada a rutas públicas de Traefik
- Validación de token Bearer en el endpoint
- Token configurado como secret MCP_AUTH_TOKEN
This commit is contained in:
2025-11-25 12:56:04 -06:00
parent 0e86f9d7a9
commit bc5eb826e8
15 changed files with 154 additions and 1 deletions

View File

@@ -22,6 +22,18 @@ interface JsonRpcResponse {
}
export default defineEventHandler(async (event) => {
// Validar token de autenticación
const authHeader = getHeader(event, 'Authorization')
const expectedToken = process.env.MCP_AUTH_TOKEN
if (expectedToken) {
const providedToken = authHeader?.replace('Bearer ', '')
if (!providedToken || providedToken !== expectedToken) {
setResponseStatus(event, 401)
return createJsonRpcError(null, -32000, 'Unauthorized: Invalid or missing token')
}
}
try {
const body = await readBody(event) as JsonRpcRequest