Connect LangChain and LangGraph agents to a NZ phone number, SMS and email

Checked · Markdown

Short answer

Install langchain[mcp] 1.4 or later, wrap a FastMCP Client pointed at https://agentline.nz/mcp with your Agentline NZ API key as auth in langchain.mcp.MCPAdapter, and pass adapter.list_tools() to create_agent. The agent can then text from a New Zealand 028 number, use an @agentline.nz inbox and wait for one-time codes.

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 LangChain with MCP support. langchain.mcp replaces the separate langchain-mcp-adapters package. If you have the old package, uninstall it.
    pip install "langchain[mcp]>=1.4.0"
    pip uninstall langchain-mcp-adapters
  2. Connect and build the agent. A string passed as auth is sent as Authorization: Bearer, and an https URL selects Streamable HTTP.
    import asyncio, os
    from fastmcp.client import Client
    from langchain.agents import create_agent
    from langchain.mcp import MCPAdapter
    
    async def main():
        client = Client("https://agentline.nz/mcp", auth=os.environ["AGENTLINE_KEY"])
        async with MCPAdapter(client) as adapter:
            tools = await adapter.list_tools()
            agent = create_agent("claude-sonnet-5", tools)
            result = await agent.ainvoke(
                {"messages": [{"role": "user", "content": "What's my Agentline NZ number?"}]}
            )
            print(result["messages"][-1].content)
    
    asyncio.run(main())
  3. Run it. Run the script. The agent should call get_my_number.

Good to know

  • langchain.mcp is in beta and raises LangChainBetaWarning. It doesn't wrap MCP prompts or resources yet, but Agentline NZ only uses tools.
  • LangGraph's create_react_agent is replaced by langchain.agents.create_agent, which runs on LangGraph.
  • Use any chat model your LangChain install supports in create_agent.
  • Standard NZ mobile numbers only (020–029). No landlines, short codes, premium or international numbers.

FAQ

Can I still use MultiServerMCPClient?

LangChain's migration guide replaces langchain-mcp-adapters and MultiServerMCPClient with langchain.mcp.MCPAdapter. Existing code with transport http and a headers entry keeps working until you migrate.

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.