fix: Autenticación por token para MCP Server
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 36s
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user