Connect the Vercel AI SDK to a NZ phone number, SMS and email

Checked · Markdown

Short answer

Create an MCP client with createMCPClient from @ai-sdk/mcp using transport type http, url https://agentline.nz/mcp and an Authorization: Bearer header, then pass await client.tools() to generateText or streamText. Your model can then text from a New Zealand 028 number, send and read email and wait for one-time codes.

Before you start

  • An Agentline NZ API key from Dashboard → API keys, set as AGENTLINE_KEY on the server. 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 packages. Add the AI SDK and its MCP package.
    npm install ai @ai-sdk/mcp
  2. Connect and call a model. Run this on the server, never in the browser, because it uses your API key.
    import { createMCPClient } from '@ai-sdk/mcp';
    import { streamText } from 'ai';
    
    const agentline = await createMCPClient({
      transport: {
        type: 'http',
        url: 'https://agentline.nz/mcp',
        headers: { Authorization: `Bearer ${process.env.AGENTLINE_KEY}` },
      },
    });
    
    const result = streamText({
      model: 'anthropic/claude-sonnet-5.5',
      tools: await agentline.tools(),
      prompt: "What's my Agentline NZ number?",
      onEnd: async () => {
        await agentline.close();
      },
    });
  3. Close the client. Close the MCP client when the response finishes, as above, so connections don't pile up.

Good to know

  • Older code imports experimental_createMCPClient from ai. The MCP client now lives in @ai-sdk/mcp.
  • Use any model your AI SDK setup supports.
  • 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.

Start free · Start free with an email inbox (no card), or take a 7-day trial of Starter or Pro to get a number.