retell_create_web_call
Initiate a web call session with an AI agent by generating a call ID and access token for WebRTC connection setup.
Instructions
Create a new web call session. Returns a call ID and access token for establishing a WebRTC connection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | The agent ID to use for the web call | |
| metadata | No | Optional: Custom metadata to attach to the call | |
| retell_llm_dynamic_variables | No | Optional: Dynamic variables to pass to the LLM |
Implementation Reference
- src/index.ts:1125-1126 (handler)Handler case for retell_create_web_call tool. Makes a POST request to the Retell API's /v2/create-web-call endpoint using the generic retellRequest helper.case "retell_create_web_call": return retellRequest("/v2/create-web-call", "POST", args);
- src/index.ts:95-112 (schema)Input schema for retell_create_web_call defining required agent_id and optional metadata/llm variables.inputSchema: { type: "object", properties: { agent_id: { type: "string", description: "The agent ID to use for the web call" }, metadata: { type: "object", description: "Optional: Custom metadata to attach to the call" }, retell_llm_dynamic_variables: { type: "object", description: "Optional: Dynamic variables to pass to the LLM" } }, required: ["agent_id"] }
- src/index.ts:92-113 (registration)Tool registration in the tools array: defines name, description, and inputSchema for MCP tool listing.{ name: "retell_create_web_call", description: "Create a new web call session. Returns a call ID and access token for establishing a WebRTC connection.", inputSchema: { type: "object", properties: { agent_id: { type: "string", description: "The agent ID to use for the web call" }, metadata: { type: "object", description: "Optional: Custom metadata to attach to the call" }, retell_llm_dynamic_variables: { type: "object", description: "Optional: Dynamic variables to pass to the LLM" } }, required: ["agent_id"] } },
- src/index.ts:23-57 (helper)Generic helper function used by all Retell tools to make authenticated API requests to Retell AI servers.async function retellRequest( endpoint: string, method: string = "GET", body?: Record<string, unknown> ): Promise<unknown> { const apiKey = getApiKey(); const headers: Record<string, string> = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }; const options: RequestInit = { method, headers, }; if (body && method !== "GET") { options.body = JSON.stringify(body); } const response = await fetch(`${RETELL_API_BASE}${endpoint}`, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`Retell API error (${response.status}): ${errorText}`); } // Handle 204 No Content if (response.status === 204) { return { success: true }; } return response.json(); }
- src/index.ts:14-20 (helper)Helper to retrieve and validate the Retell API key from environment variable.function getApiKey(): string { const apiKey = process.env.RETELL_API_KEY; if (!apiKey) { throw new Error("RETELL_API_KEY environment variable is required"); } return apiKey; }