Skip to main content
Glama

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
NameRequiredDescriptionDefault
agent_idYesThe chat agent ID to use for the session
metadataNoOptional: Custom metadata for the chat session
retell_llm_dynamic_variablesNoOptional: Dynamic variables for personalized responses

Implementation Reference

  • 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);
  • 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"]
      }
    },
  • 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,
        };
      }
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/itsanamune/retellsimp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server