OneLi with Claude Agent SDK / Anthropic API
How to let an agent built with Claude Agent SDK / Anthropic API place Hebrew phone calls through OneLi, follow the call, answer consultations and read the result.
In the Claude Agent SDK, configure OneLi as an http MCP server with an Authorization header and allow its tools. With the Anthropic Messages API you can use the MCP connector, which calls the server itself.
Setup
- Create an API key at oneli.io/app/connect and store it on the server as
ONELI_API_KEY. - Install the packages:
npm i @anthropic-ai/claude-agent-sdk zod # or: pip install claude-agent-sdk httpxChecked against: @anthropic-ai/claude-agent-sdk 0.3.308 · claude-agent-sdk 0.2.172 (PyPI)
Agent SDK in TypeScript
import { query, tool, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';
import { z } from 'zod';
const createCallTask = tool('create_call_task', 'Create an outbound call task',
{ to_number: z.string(), goal: z.string() },
async (args) => {
const res = await fetch('https://api.oneli.io/v1/call-tasks', { method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.ONELI_API_KEY}` },
body: JSON.stringify({ idempotency_key: crypto.randomUUID(), ...args }) });
return { content: [{ type: 'text', text: await res.text() }], isError: !res.ok };
});
for await (const m of query({
prompt: "Call +972… and confirm tomorrow's appointment",
options: {
mcpServers: {
oneli: { type: 'http', url: 'https://mcp.oneli.io/mcp',
headers: { Authorization: `Bearer ${process.env.ONELI_API_KEY}` } },
// REST variant instead of the line above:
// oneli_rest: createSdkMcpServer({ name: 'oneli_rest', version: '1.0.0', tools: [createCallTask] }),
},
allowedTools: ['mcp__oneli__*'],
},
})) if (m.type === 'result' && m.subtype === 'success') console.log(m.result);Agent SDK in Python
import asyncio, os
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
async def main():
opts = ClaudeAgentOptions(
mcp_servers={"oneli": {"type": "http", "url": "https://mcp.oneli.io/mcp",
"headers": {"Authorization": f"Bearer {os.environ['ONELI_API_KEY']}"}}},
allowed_tools=["mcp__oneli__*"])
async for msg in query(prompt="Call +972… and confirm tomorrow's appointment", options=opts):
if isinstance(msg, ResultMessage) and msg.subtype == "success": print(msg.result)
asyncio.run(main())
# REST variant: @tool("create_call_task", "...", {"to_number": str, "goal": str}) + create_sdk_mcp_server(...)Messages API: MCP connector
import os, anthropic
resp = anthropic.Anthropic().beta.messages.create(
model="claude-opus-5-5", max_tokens=2000,
messages=[{"role": "user", "content": "Call +972… and book a table"}],
mcp_servers=[{"type": "url", "url": "https://mcp.oneli.io/mcp", "name": "oneli",
"authorization_token": os.environ["ONELI_API_KEY"]}],
tools=[{"type": "mcp_toolset", "mcp_server_name": "oneli"}],
betas=["mcp-client-2025-11-20"])Notes
- In the Agent SDK a server that fails to connect does not throw. Check the system/init message for failed or needs-auth.
- On the Messages API connector, authorization_token is sent as a Bearer token, so an oli_ key should work. This has not been tested against the live server.
- The connector supports tools only and cannot send arbitrary headers.
- Beta header mcp-client-2025-11-20; mcp-client-2026-09-15 also exists and adds pinned tool lists.
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: code.claude.com/docs/en/agent-sdk/mcp · code.claude.com/docs/en/agent-sdk/custom-tools · platform.claude.com/docs/en/agents-and-tools/mcp-connector