retell_create_chat_completion
Send messages in existing chat sessions and receive AI agent responses to continue conversations.
Instructions
Send a message in an existing chat session and get the agent's response.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes | The chat session ID | |
| content | Yes | The message content to send |
Implementation Reference
- src/index.ts:1145-1146 (handler)The specific switch case in the executeTool function that handles the retell_create_chat_completion tool by calling the Retell API's /create-chat-completion endpoint with POST method and the input arguments.case "retell_create_chat_completion": return retellRequest("/create-chat-completion", "POST", args);
- src/index.ts:262-279 (schema)Defines the tool's metadata including name, description, and input schema (requiring chat_id and content) used for validation and listing.{ name: "retell_create_chat_completion", description: "Send a message in an existing chat session and get the agent's response.", inputSchema: { type: "object", properties: { chat_id: { type: "string", description: "The chat session ID" }, content: { type: "string", description: "The message content to send" } }, required: ["chat_id", "content"] } },
- src/index.ts:1283-1285 (registration)Registers the handler for listing all tools, exposing the schema for retell_create_chat_completion via the 'tools' array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:23-57 (helper)Generic helper function that performs authenticated HTTP requests to the Retell AI 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:1288-1313 (registration)Registers the MCP CallToolRequestSchema handler which invokes executeTool (containing the specific case for this tool) based on the 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, }; } });