OneLi with LlamaIndex
How to let an agent built with LlamaIndex place Hebrew phone calls through OneLi, follow the call, answer consultations and read the result.
In LlamaIndex, create a BasicMCPClient with an Authorization header, turn it into a tool list with McpToolSpec and pass it to a FunctionAgent.
Setup
- Create an API key at oneli.io/app/connect and store it on the server as
ONELI_API_KEY. - Install the packages:
pip install llama-index-tools-mcp llama-index-llms-openaiChecked against: llama-index-tools-mcp 0.6.0 · llama-index-core 0.14.25
Connect over MCP (recommended)
import os, asyncio
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI
async def main():
client = BasicMCPClient("https://mcp.oneli.io/mcp",
headers={"Authorization": f"Bearer {os.environ['ONELI_API_KEY']}"})
tools = await McpToolSpec(client=client).to_tool_list_async()
agent = FunctionAgent(tools=tools, llm=OpenAI(model="gpt-4.1"), system_prompt="Use OneLi to place calls.")
print(await agent.run(user_msg="Call +972… and book a table"))
asyncio.run(main())
# REST: FunctionTool.from_defaults(fn=create_call_task) (same httpx function as in the other Python guides)Notes
- A URL ending in /mcp selects Streamable HTTP; /sse selects SSE.
- If you pass your own http_client, the headers argument is ignored.
- The headers argument is in the client source, not in the README.
Phone numbers: OneLi accepts an Israeli number in any common format (050-1234567, +972501234567). Once the call starts, the agent follows it with get_call_events or GET /v1/call-tasks/:id/events to answer consultations and get the summary.
Next steps
Sources: pypi.org/project/llama-index-tools-mcp/ · github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-mcp/llama_index/tools/mcp/client.py