# Connect the OpenAI Agents SDK to a NZ phone number, SMS and email

**Short answer:** Use MCPServerStreamableHttp from agents.mcp with url https://agentline.nz/mcp and an Authorization: Bearer header holding your Agentline NZ API key, then pass the server to your Agent in mcp_servers. Your agent gets Agentline NZ's tools for texting from a New Zealand 028 number, email and wait_for_code.

## Before you start

- An Agentline NZ API key from Dashboard → API keys, exported as AGENTLINE_KEY. Start free with an email inbox (no card), or take a 7-day trial of Starter or Pro to get a number.
- Your 028 number is set up within a few days of signup. Your email inbox works straight away.

## Steps

1. **Install the SDK.** Install the openai-agents package.

   ```bash
   pip install openai-agents
   ```

2. **Connect to Agentline NZ.** Open an MCPServerStreamableHttp connection with your key in the headers and give it to the agent.

   ```python
   import asyncio, os
   from agents import Agent, Runner
   from agents.mcp import MCPServerStreamableHttp

   async def main():
       async with MCPServerStreamableHttp(
           name="agentline",
           params={
               "url": "https://agentline.nz/mcp",
               "headers": {"Authorization": f"Bearer {os.environ['AGENTLINE_KEY']}"},
               "timeout": 60,
           },
           cache_tools_list=True,
       ) as agentline:
           agent = Agent(
               name="Assistant",
               instructions="Use Agentline NZ to text, email and wait for one-time codes.",
               mcp_servers=[agentline],
           )
           result = await Runner.run(agent, "What's my Agentline NZ number?")
           print(result.final_output)

   asyncio.run(main())
   ```

3. **Run it.** Run the script. The agent should call get_my_number and print your number and inbox.

## JavaScript

```ts
import { Agent, run, MCPServerStreamableHttp } from '@openai/agents';

const agentline = new MCPServerStreamableHttp({
  name: 'agentline',
  url: 'https://agentline.nz/mcp',
  requestInit: { headers: { Authorization: `Bearer ${process.env.AGENTLINE_KEY}` } },
});
await agentline.connect();
const agent = new Agent({ name: 'Assistant', mcpServers: [agentline] });
console.log((await run(agent, "What's my Agentline NZ number?")).finalOutput);
await agentline.close();
```

## Good to know

- Set the timeout above 55 seconds if your agent uses wait_for_code with a long timeout, because the tool call waits for the code to arrive.
- The SDK also has HostedMCPTool, where OpenAI's Responses API connects to the server for you. We've used the local client because its header handling is documented for any server.
- Standard NZ mobile numbers only (020–029). No landlines, short codes, premium or international numbers.

## FAQ

### What does Agentline NZ cost?

Starter is NZ$29/month and Pro is NZ$79/month, billed in NZ dollars. Start free with an email inbox (no card), or take a 7-day trial of Starter or Pro to get a number. Agentline NZ is not GST-registered, so no GST is charged.

### How long does it take to get the 028 number?

Your 028 number is set up within a few days of signup. Your email inbox works straight away. Full refund if your number hasn't arrived within 30 days of paying.

### Can my assistant send marketing or bulk texts?

No. Transactional and assistant messages only: replies, bookings, confirmations, reminders people asked for, and codes. Marketing, promotions, cold texts and bulk texts are blocked. See [What we don't allow](/what-we-dont-allow).

## Related

- [Connect LangChain and LangGraph agents to a NZ phone number, SMS and email](/integrations/langchain)
- [Connect the Vercel AI SDK to a NZ phone number, SMS and email](/integrations/vercel-ai-sdk)
- [How to give ChatGPT and Dots a phone number, text and email in New Zealand](/guides/chatgpt)
- [How do I create an Agentline NZ API key?](/help/how-to-create-an-api-key)

[Start free](https://agentline.nz/signup) · Start free with an email inbox (no card), or take a 7-day trial of Starter or Pro to get a number.
