Connect the Vercel AI SDK to an agent email inbox

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 send and read email from its own @agentline.nz inbox and wait for one-time codes sent by email.

Before you start

  • An Agentline NZ API key from Dashboard → API keys, set as AGENTLINE_KEY on the server. No credit card needed to sign up. Start free with an email inbox, or try Starter or Pro free for 7 days.
  • Your @agentline.nz email inbox works straight away. Texting and phone numbers are coming soon.

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 email address?",
      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.
  • Texting and phone numbers are coming soon. To hear when they're ready, join the waitlist.

FAQ

What does Agentline NZ cost?

Starter is NZ$29/month and Pro is NZ$79/month, billed in NZ dollars. No credit card needed to sign up. Start free with an email inbox, or try Starter or Pro free for 7 days. You can cancel anytime, and your plan stops at the end of the billing period you've paid for. Refunds follow section 5 of our Terms: fees already paid aren't refunded, except where the Terms or the law say so. Agentline NZ is not GST-registered, so no GST is charged.

When does the inbox work, and can my assistant send texts yet?

Your @agentline.nz email inbox works straight away. Texting and phone numbers are coming soon. To hear when texting is ready, join the waitlist.

Can my assistant send marketing or bulk email?

No. Transactional and assistant messages only: replies, bookings, confirmations, reminders people asked for, and codes. Marketing, promotions, cold messages and bulk messages aren't allowed. See What we don't allow.

Start free · No credit card needed to sign up. Start free with an email inbox, or try Starter or Pro free for 7 days.