Skip to main content
Glama

Set number routing

set_number_routing
DestructiveIdempotent

Set where a phone number should route incoming calls: to a voice agent (mode "agent" + agentId), to another phone number (mode "forward" + forwardTo), to your own SIP PBX (mode "sip" + sipUri, optionally with sipUsername/sipPassword), or turn routing off entirely (mode "none"). Mode "forward" needs at least one credit top-up first: on an account that has never topped up, turning forwarding on returns insufficient_credit (the agent and inbound calls keep working; a number that is already forwarded can change its target). For mode "sip": we first send an unauthenticated INVITE; if the target challenges it with 401/407 and rejects the call without credentials, set sipUsername and sipPassword - verified with a live call to Vapi's native SIP number, which challenges and accepts credentials regardless of their content, so this alone fixed a call that never rang. Exception: a Vapi BYO SIP trunk address (.sip.vapi.ai, or .sip.eu.vapi.ai for a Vapi organization in the EU region) takes NO credentials - Vapi recognises our calls by the source IP in the trunk's gateways (ip 81.31.45.0, netmask 24; the default netmask 32 lets in a single address only) and with a login the call never connects, so sipUsername/sipPassword together with such an address are rejected with validation. Whether your own PBX also connects the call is up to it; a target that never challenges, or challenges but rejects the credentials, still needs a different fix - allow our signalling by IP instead: 81.31.45.0/24, in practice 81.31.45.51 and 81.31.45.56. Leave both fields empty for an unauthenticated PBX (the current default). Each of sipUsername/sipPassword is retained independently when the field is omitted from the call (e.g. omitting both while only changing sipUri keeps the saved credentials unchanged; list_numbers returns sipUsername, and hasSipPassword tells you a password is stored). One exception: if the new sipUri points at a different server than the stored one (the host after the @ sign), the saved password is NOT reused and the call is rejected until you send sipPassword again - a stored password is never forwarded to a server the customer did not enter it for. Sending a field as an explicit empty string clears just that field - so to remove authentication entirely, send both sipUsername and sipPassword as empty strings. A non-empty sipUsername with no password saved (and no sipPassword sent) - or vice versa - is rejected: fill in both fields together the first time you set up authentication. Same data as PATCH /v1/numbers/{e164} (response schema in /openapi.json).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "e164": "<e164>",
      "mode": "<mode>"
    },
    "name": "set_number_routing"
  }
}

Input Schema

NameRequiredDescriptionDefault
e164YesPhone number to configure, in E.164 format with the country code, for example +420777123456. Must already belong to this account, from list_numbers.
modeYesWhere calls to this number go: agent (an AI agent answers, needs agentId), forward (rings another number, needs forwardTo), sip (your own PBX, needs sipUri), none (unrouted).
sipUriNoSIP URI of your own PBX to route calls to, for example sip:100@pbx.example.com. Required when mode is sip, ignored otherwise.
agentIdNoId of the agent that should answer calls to this number, from list_agents. Required when mode is agent, ignored otherwise.
forwardToNoPhone number to forward calls to, in E.164 format with the country code, for example +420777123456. Required when mode is forward, ignored otherwise.
sipPasswordNoSIP digest password matching sipUsername. Send together with sipUsername; sending both as empty strings clears stored credentials, omitting both keeps them unchanged. Never returned by list_numbers.
sipUsernameNoSIP digest username for the target in sipUri, only if it challenges the call with 401 or 407 - never for a Vapi BYO trunk address, which is rejected. Send together with sipPassword; sending both as empty strings clears stored credentials, omitting both keeps them unchanged.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true, idempotentHint=true, and openWorldHint=true, so mutation semantics are covered structurally. The description adds genuinely useful non-annotation behavior: insufficient_credit on forwarding, per-field credential retention, empty-string clearing, and rejection when sipUri changes server. However, some of this duplicates the schema and the length dilutes the signal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The opening sentence is well front-loaded with the four modes, but the SIP section sprawls into troubleshooting narrative ('verified with a live call to Vapi's native SIP number, ... so this alone fixed a call that never rang') and IP/netmask trivia that an agent configuring a number rarely needs verbatim.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-parameter mutation tool with no output schema, the description covers preconditions, per-mode requirements, credential lifecycle, clearing semantics, and error conditions. An agent has everything needed to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning beyond the schema: independent retention of sipUsername/sipPassword when omitted, the explicit-empty-string clearing rule, the rejection of credentials with a Vapi BYO trunk address, and the different-server password non-reuse rule. It does not add much for e164, agentId, or forwardTo.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Set where a phone number should route incoming calls') and then enumerates every mode (agent, forward, sip, none) with the parameter each mode requires, so an agent can distinguish this tool's four behaviors at a glance.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit conditional guidance: mode 'forward' requires at least one credit top-up first and otherwise returns insufficient_credit; mode 'sip' should only get credentials when the target challenges with 401/407; Vapi BYO trunk addresses must never receive credentials. It also states which sibling (list_numbers) to consult for saved state.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.