retell_create_knowledge_base
Create a knowledge base to provide context for AI agents, enabling them to access and use relevant information during conversations.
Instructions
Create a new knowledge base for providing context to agents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| knowledge_base_name | Yes | Name for the knowledge base | |
| enable_auto_refresh | No | Whether to automatically refresh sources |
Implementation Reference
- src/index.ts:1229-1230 (handler)The handler logic for the tool within the executeTool switch statement. It simply forwards the input arguments as a POST request to the Retell API endpoint /create-knowledge-base using the retellRequest helper.case "retell_create_knowledge_base": return retellRequest("/create-knowledge-base", "POST", args);
- src/index.ts:890-906 (schema)The tool definition in the tools array, including name, description, and inputSchema for validation (requires knowledge_base_name string, optional enable_auto_refresh boolean). This serves as both schema and registration entry.{ name: "retell_create_knowledge_base", description: "Create a new knowledge base for providing context to agents.", inputSchema: { type: "object", properties: { knowledge_base_name: { type: "string", description: "Name for the knowledge base" }, enable_auto_refresh: { type: "boolean", description: "Whether to automatically refresh sources" } }, required: ["knowledge_base_name"] }
- src/index.ts:23-57 (helper)The retellRequest helper function that performs authenticated HTTP requests to the Retell API using fetch, handling headers, body, errors, and JSON parsing.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 server registration for listing available tools, which returns the tools array including the definition for retell_create_knowledge_base.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:1288-1313 (registration)MCP server registration for tool execution (CallToolRequestSchema), which parses the request, calls executeTool (containing the handler), and returns the result or error.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, }; } });