Dev.to Security 🔐 Cybersecurity 👁 2 📖 3 min read

Giving an AI agent a phone: five rules for safe MCP tools

AI disclosure: this article was written with the help of AI and checked by a human before publishing. Giving an AI agent the ability to send a text or place a call takes about ten minutes with the Model Context Protocol

AI disclosure: this article was written with the help of AI and checked by a human before publishing.

Giving an AI agent the ability to send a text or place a call takes about ten minutes with the Model Context Protocol. Making it safe takes longer. After wiring phone tools into a few agents, these are the design rules I would not ship without.

What MCP gives you

An MCP server exposes tools: a name, a description and a JSON schema for the arguments. The client (Claude, Cursor, your own agent loop) shows the tools to the model, the model decides to call one, and the server runs it. For telecom that usually means tools such as send_sms, start_verification, check_verification and place_call.

The model only sees the description and the schema. Everything it knows about how to use your tool comes from those two things, so they are part of your safety design, not just documentation.

Rule 1: narrow tools beat a general one

Do not expose http_request to your telecom API and hope for the best. Expose one tool per action, with tight arguments.

{
  "name": "send_sms",
  "description": "Send one SMS to one number the user has confirmed. Never use for marketing. Max 320 characters.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "to": { "type": "string", "pattern": "^\\+[1-9][0-9]{7,14}$", "description": "E.164 number" },
      "text": { "type": "string", "maxLength": 320 }
    },
    "required": ["to", "text"]
  }
}

The pattern forces E.164, the length cap stops runaway messages, and the description tells the model when not to use it.

Rule 2: put limits on the server, not in the prompt

A prompt that says "never send more than five messages" is a suggestion. The server is where limits belong:

  • A per-session and per-day message cap.
  • An allow-list of destination countries.
  • A cooldown per destination number, so a confused loop cannot text the same person twenty times.
  • A hard block on premium-rate and short-code destinations.

Rule 3: verification codes never go through the model

For one-time codes, the agent should call start_verification and later check_verification with what the user typed. The code itself is generated and checked on the server. It never appears in a tool result, so it never ends up in the model's context or your logs.

Rule 4: return results the model can act on

Return the message ID and a clear status ("queued", "rejected: destination not allowed"). Do not return a raw stack trace. The model will try to fix whatever you show it, so show it something it can actually fix.

Rule 5: a human confirms anything that costs money

Calls and international messages cost real money. Have the client ask the user to confirm the number and the text before the tool runs. Most MCP clients already show a confirmation for tool calls; do not turn that off for these tools.

Try it yourself

Our hosted MCP server for SMS, verification, calls and numbers is built along these lines. The API key goes in a header and no tool takes it as an argument, so it never passes through the model. Tools that spend money say so in their descriptions. Verification is split into a start tool and a check tool. Three public tools work with no key at all.

Add https://packetexchange.io/mcp/http to Claude, Cursor or any MCP client and try a public tool. When you want to send, sign up for a key; test keys simulate calls and messages. Read the MCP overview.

The code is open on GitHub:

What limits do you put on tools that let an agent act in the real world?

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.