retell_create_chat_agent
Create a text-based chat agent by configuring LLM engines and webhooks for conversational AI applications.
Instructions
Create a new chat agent for text-based conversations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| response_engine | Yes | The LLM engine configuration | |
| agent_name | No | Display name for the chat agent | |
| webhook_url | No | URL for receiving chat event webhooks |
Implementation Reference
- src/index.ts:1187-1188 (handler)Handler execution logic for the retell_create_chat_agent tool. Makes a POST request to the Retell API's /create-chat-agent endpoint using the generic retellRequest helper.case "retell_create_chat_agent": return retellRequest("/create-chat-agent", "POST", args);
- src/index.ts:608-641 (schema)Tool definition including name, description, and inputSchema for parameter validation.{ name: "retell_create_chat_agent", description: "Create a new chat agent for text-based conversations.", inputSchema: { type: "object", properties: { response_engine: { type: "object", description: "The LLM engine configuration", properties: { type: { type: "string", enum: ["retell-llm", "custom-llm"], description: "The type of response engine" }, llm_id: { type: "string", description: "The LLM ID to use" } }, required: ["type"] }, agent_name: { type: "string", description: "Display name for the chat agent" }, webhook_url: { type: "string", description: "URL for receiving chat event webhooks" } }, required: ["response_engine"] } },
- src/index.ts:1283-1285 (registration)Registers the tools array (which includes retell_create_chat_agent) for the MCP listTools capability.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:23-57 (helper)Generic helper function for making authenticated API requests to Retell AI, used by the tool handler.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 the Retell API key from environment variables, used by retellRequest.function getApiKey(): string { const apiKey = process.env.RETELL_API_KEY; if (!apiKey) { throw new Error("RETELL_API_KEY environment variable is required"); } return apiKey; }