https://retellai.com/?utm_source=discord&utm_medium=seo logo
m
Impossible to save my MCP once created.
s
HI @matteo_v99 thanks for reaching out. Your mcp server is added please refresh after clicking save button it willl be saved let me know if you face any problem
m
No, same problem. It’s not added @shahretell
g
I am having the same problem
I tested my MCP response in Postman and my Terminal and it is OK, but Retell is showing a bad request, I am using Vercel
m
I hope for a response today
g
Me too
Lets wait, either way I will create another post with the issue, feel free to write your problem too 😁
s
hi @gabriel_69931 thanks for reaching out.we look at this get back you in loop as soon as possible
g
Thank you @shahretell, any news?
Any update? @shahretell
@shahretell
😅
@shahretell any news?
s
HI @gabriel_69931 we have checked from our side You can your webhook configration is correct as retell requires webhook signature verification using x-retell-signature header.And check your response structure for MCP function is in correct schema also send it me too
g
Great let me check it
Thank yoy Shah
I'm still getting a 401 Unauthorized error from my MCP webhook, and I’d appreciate your help verifying that everything is correctly set up. Here’s what I’ve done: ✅ MCP Endpoint (Vercel) I'm using a Next.js 13+ project, and this is my entire /app/api/vicky/route.js file (stripped down, without the long system prompt): import { createHmac, timingSafeEqual } from "crypto"; export async function POST(req) { const OPENAI_API_KEY = process.env.OPENAI_API_KEY; const RETELL_SECRET = process.env.RETELL_SECRET; // key_57455b2cb601a474e328f92e25ac const rawBody = await req.text(); // Necesitamos el cuerpo como texto sin parsear const signature = req.headers.get("x-retell-signature"); // Validación de firma if (!signature || !RETELL_SECRET) { return new Response(JSON.stringify({ error: "Missing signature or secret" }), { status: 401 }); } const hmac = createHmac("sha256", RETELL_SECRET); hmac.update(rawBody); const expectedSignature = hmac.digest("hex"); const signatureBuffer = Buffer.from(signature, "utf-8"); const expectedBuffer = Buffer.from(expectedSignature, "utf-8"); if ( signatureBuffer.length !== expectedBuffer.length || !timingSafeEqual(signatureBuffer, expectedBuffer) ) { return new Response(JSON.stringify({ error: "Invalid signature" }), { status: 401 }); } // Si pasa la verificación, procesamos el mensaje let input = "Hola"; try { const body = JSON.parse(rawBody); if (body?.input) input = body.input; } catch { // seguimos con input por defecto } const systemPrompt = ``;
try { const response = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization:
Bearer ${OPENAI_API_KEY}
, }, body: JSON.stringify({ model: "gpt-3.5-turbo", messages: [ { role: "system", content: systemPrompt }, { role: "user", content: input } ], temperature: 0.3, max_tokens: 700 }), }); const data = await response.json(); if (!data.choices || !data.choices[0]) { return new Response(JSON.stringify({ error: "No response from OpenAI" }), { status: 500 }); } return new Response( JSON.stringify({ status: "success", message: data.choices[0].message.content }), { status: 200, headers: { "Content-Type": "application/json" } } ); } catch (err) { return new Response(JSON.stringify({ error: "OpenAI error", details: err.message }), { status: 500 }); } } Environment Variables (in Vercel) RETELL_SECRET = my valid Retell api key OPENAI_API_KEY = my valid OpenAI key MCP Setup in Retell In the Retell MCP config, I’ve set: URL: https://vickymcpsimple.vercel.app/api/vicky Let me know If you expect a different response format (right now I return { status: "success", message: "..." }) Or if something’s off in signature verification
Let me know where I am doing someting wrong @shahretell Thank you in advance!
s
Hi @gabriel_69931 i have seen issues in your code and envirnoment variables here is a corrected version of code Envirnoment variable fixes RETELL_WEBHOOK_SECRET = [your_webhook_secret_from_retell_dashboard] OPENAI_API_KEY = [your_openai_api_key] Also please note that the webhook secret is NOT your Retell API key. You need to: Go to your Retell dashboard then Navigate to Webhook settings here you Find the Webhook Secret which is different from API key
g
Thank you so much @shahretell I will correct it and take a look!!!!
@shahretell I am having some trouble finding my webhook secret
SHould I configure my URL or where can I find it?
@shahretell ?
Sorry for the constant spam 😅
But I have tried everything and I cannot see the webhook secret
@shahretell
My error message when I test it in postman is invalid signature, I am sending as headers this
@User can you help me with this?
@User I cannot see my webhook secret, I don´t know if when I set an API key as a webhook key, this solves the issue. But either way I am still getting an error and my MCP is not saving (just keeps buffering).
Hello! @shahretell can you help me with this issue?
@shahretell ?????
s
Hi @gabriel_69931 at that time where are facing error ? have add api key in webhook secret having webhook badge like that
g
I have it like that
This is my current repo import { createHmac, timingSafeEqual } from "crypto"; export async function POST(req) { const OPENAI_API_KEY = process.env.OPENAI_API_KEY; const RETELL_WEBHOOK_SECRET = process.env.RETELL_WEBHOOK_SECRET; // NOT your API key! const rawBody = await req.text(); const signature = req.headers.get("x-retell-signature"); // Validation if (!signature || !RETELL_WEBHOOK_SECRET) { return new Response(JSON.stringify({ error: "Missing signature or secret" }), { status: 401 }); } // Signature verification const hmac = createHmac("sha256", RETELL_WEBHOOK_SECRET); hmac.update(rawBody); const expectedSignature = hmac.digest("hex"); const signatureBuffer = Buffer.from(signature, "utf-8"); const expectedBuffer = Buffer.from(expectedSignature, "utf-8"); if ( signatureBuffer.length !== expectedBuffer.length || !timingSafeEqual(signatureBuffer, expectedBuffer) ) { return new Response(JSON.stringify({ error: "Invalid signature" }), { status: 401 }); } // Process the message let input = "Hola"; try { const body = JSON.parse(rawBody); if (body?.input) input = body.input; } catch { // Use default input } const systemPrompt = `
`; try { const response = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization:
Bearer ${OPENAI_API_KEY}
, // Fixed template literal }, body: JSON.stringify({ model: "gpt-3.5-turbo", messages: [ { role: "system", content: systemPrompt }, { role: "user", content: input } ], temperature: 0.3, max_tokens: 700 }), }); const data = await response.json(); if (!data.choices || !data.choices[0]) { return new Response(JSON.stringify({ error: "No response from OpenAI" }), { status: 500 }); } return new Response( JSON.stringify({ status: "success", message: data.choices[0].message.content }), { status: 200, headers: { "Content-Type": "application/json" } } ); } catch (err) { return new Response(JSON.stringify({ error: "OpenAI error", details: err.message }), { status: 500 }); } }
These are my environment variables in vercel. I know for a fact that both of them are correct
I still get error with these headers when I test it in postman
The error i am getting is return new Response(JSON.stringify({ error: "Invalid signature" }), { status: 401 });
What do you think is happening @shahretell
Am I doing something wrong with the code? @shahretell