retell_create_chat
Start a new chat session with a Retell AI agent to handle conversations, configure flows, and manage interactions through the MCP server platform.
Instructions
Create a new chat session with a chat agent.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | The chat agent ID to use for the session | |
| metadata | No | Optional: Custom metadata for the chat session | |
| retell_llm_dynamic_variables | No | Optional: Dynamic variables for personalized responses |
Implementation Reference
- src/index.ts:1139-1140 (handler)Handler implementation in the executeTool switch statement: proxies the request to Retell API endpoint /create-chat with POST method and input arguments.case "retell_create_chat": return retellRequest("/create-chat", "POST", args);
- src/index.ts:201-221 (schema)Tool schema definition including name, description, and inputSchema used for validation and tool listing.name: "retell_create_chat", description: "Create a new chat session with a chat agent.", inputSchema: { type: "object", properties: { agent_id: { type: "string", description: "The chat agent ID to use for the session" }, metadata: { type: "object", description: "Optional: Custom metadata for the chat session" }, retell_llm_dynamic_variables: { type: "object", description: "Optional: Dynamic variables for personalized responses" } }, required: ["agent_id"] } },
- src/index.ts:23-57 (helper)Core helper function that performs authenticated HTTP requests to the Retell API, 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:1283-1285 (registration)MCP request handler for listing tools, returns the tools array containing the retell_create_chat schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:1288-1313 (registration)MCP request handler for calling tools, dispatches to executeTool based on tool name.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await executeTool(name, args as Record<string, unknown>); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${errorMessage}`, }, ], isError: true, }; } });