{
  "markdown": "# pbx-mcp\n\n[![pbx-mcp MCP server](https://glama.ai/mcp/servers/ictinnovations/pbx-mcp/badges/score.svg)](https://glama.ai/mcp/servers/ictinnovations/pbx-mcp)\n[![Documentation Status](https://app.readthedocs.org/projects/pbx-mcp/badge/?version=latest)](https://pbx-mcp.readthedocs.io/en/latest/)\n\nAn [MCP](https://modelcontextprotocol.io) server that lets an AI assistant inspect and control **Asterisk** and **FreeSWITCH**.\n\nAsk \"which extensions are offline right now?\" or \"why is my SIP trunk not registering?\" and get a real answer from the live switch, not a guess.\n\nDeveloped by **Tahir Almas** at [ICT Innovations](https://ictinnovations.com), the team behind [ICTCore](https://github.com/ictinnovations/ictcore), ICTContact, ICTDialer, ICTFax and ICTPBX. The AMI and ESL clients in this repo are the same protocol groundwork those products run on.\n\n## Why\n\nDebugging a PBX means memorising two very different command sets. Asterisk speaks AMI and a CLI with hundreds of verbs. FreeSWITCH speaks ESL with its own vocabulary. If you run both, you're context switching all day.\n\npbx-mcp puts a single, well described tool surface in front of both, so your assistant can go from \"calls are failing\" to `sofia status gateway` without you spelling out each step.\n\n**New here?** The [user guide](https://pbx-mcp.readthedocs.io/en/latest/) walks through PBX setup, client config, worked examples and troubleshooting. This README is the quick reference.\n\n## What your assistant sees\n\nTwelve read-only tools, six per engine, each one described well enough that the model picks the right one without being told. This is the server running under the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):\n\n![pbx-mcp tools listed in the MCP Inspector](https://raw.githubusercontent.com/ictinnovations/pbx-mcp/main/docs/images/mcp-inspector-tools.png)\n\nThe four write tools, `asterisk_originate`, `asterisk_hangup`, `freeswitch_originate` and `freeswitch_hangup`, stay hidden until you set `PBX_MCP_ALLOW_WRITE=true`.\n\n## Install\n\n```bash\nnpm install -g pbx-mcp\n```\n\nOr run it straight from npx, which is what most MCP client configs do:\n\n```bash\nnpx -y pbx-mcp\n```\n\nYou need Node 18 or newer.\n\n## Docker\n\nThere's a prebuilt image if you'd rather not put Node on the machine that talks to your PBX.\n\n```bash\ndocker run -i --rm \\\n  -e ASTERISK_AMI_HOST=10.0.0.10 \\\n  -e ASTERISK_AMI_USERNAME=mcp \\\n  -e ASTERISK_AMI_PASSWORD=change-me \\\n  ghcr.io/ictinnovations/pbx-mcp\n```\n\nThe same image is on Docker Hub as [`ictinnovations/pbx-mcp`](https://hub.docker.com/r/ictinnovations/pbx-mcp) if that registry is an easier pull for you.\n\nThree things to know:\n\n- `-i` is not optional. The server speaks MCP over stdio, so without stdin attached the container starts and then sits there saying nothing, which looks exactly like a broken server.\n- There is no port to publish. Nothing listens.\n- Your PBX has to be reachable from inside the container. If Asterisk runs on the Docker host itself, swap the IP above for `host.docker.internal` on Mac and Windows, or add `--network host` on Linux.\n\nThe image runs as a non-root user and, like every other way of running this, starts read only.\n\n## Configure\n\nEverything comes from environment variables. Set the Asterisk block, the FreeSWITCH block, or both. The server only registers tools for what you've actually configured, so an Asterisk-only shop never sees a FreeSWITCH tool.\n\n### Asterisk\n\n| Variable | Default | Notes |\n|---|---|---|\n| `ASTERISK_AMI_HOST` | *(required to enable)* | Hostname or IP of the Asterisk box |\n| `ASTERISK_AMI_PORT` | `5038` | AMI port from `manager.conf` |\n| `ASTERISK_AMI_USERNAME` | | AMI user |\n| `ASTERISK_AMI_PASSWORD` | | AMI secret |\n| `ASTERISK_AMI_TLS` | `false` | Set `true` if `tlsenable=yes` |\n\nYour `manager.conf` user needs at least `read = system,call,command` and `write = command`. Add `originate` only if you plan to turn on write mode.\n\n```ini\n[mcp]\nsecret = change-me\nread = system,call,command\nwrite = command\n```\n\n### FreeSWITCH\n\n| Variable | Default | Notes |\n|---|---|---|\n| `FREESWITCH_ESL_HOST` | *(required to enable)* | Hostname or IP of the switch |\n| `FREESWITCH_ESL_PORT` | `8021` | Inbound ESL port |\n| `FREESWITCH_ESL_PASSWORD` | `ClueCon` | From `event_socket.conf.xml` |\n\n### Shared\n\n| Variable | Default | Notes |\n|---|---|---|\n| `PBX_MCP_ALLOW_WRITE` | `false` | Unlocks call control. Read the safety section first |\n| `PBX_MCP_TIMEOUT_MS` | `10000` | Per command timeout |\n\n## Claude Desktop\n\nAdd this to `claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"pbx\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"pbx-mcp\"],\n      \"env\": {\n        \"ASTERISK_AMI_HOST\": \"10.0.0.10\",\n        \"ASTERISK_AMI_USERNAME\": \"mcp\",\n        \"ASTERISK_AMI_PASSWORD\": \"change-me\",\n        \"FREESWITCH_ESL_HOST\": \"10.0.0.11\",\n        \"FREESWITCH_ESL_PASSWORD\": \"ClueCon\"\n      }\n    }\n  }\n}\n```\n\nThe same shape works for any MCP client that speaks stdio. There's a copy in [`examples/claude_desktop_config.json`](examples/claude_desktop_config.json).\n\nTo run the container instead of npx, keep the `env` block and point `command` at Docker:\n\n```json\n{\n  \"mcpServers\": {\n    \"pbx\": {\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\", \"-i\", \"--rm\",\n        \"-e\", \"ASTERISK_AMI_HOST\",\n        \"-e\", \"ASTERISK_AMI_USERNAME\",\n        \"-e\", \"ASTERISK_AMI_PASSWORD\",\n        \"ghcr.io/ictinnovations/pbx-mcp\"\n      ],\n      \"env\": {\n        \"ASTERISK_AMI_HOST\": \"10.0.0.10\",\n        \"ASTERISK_AMI_USERNAME\": \"mcp\",\n        \"ASTERISK_AMI_PASSWORD\": \"change-me\"\n      }\n    }\n  }\n}\n```\n\nEach `-e NAME` with no value forwards that variable from `env` into the container, which keeps the secrets out of the argument list.\n\n## Tools\n\n### Asterisk\n\n| Tool | What it does |\n|---|---|\n| `asterisk_status` | Version, uptime, active calls and calls processed |\n| `asterisk_channels` | Every live channel with caller ID, state, bridge, duration and dialplan position. Optional substring filter |\n| `asterisk_endpoints` | PJSIP endpoints with device state and contact count. Falls back to `chan_sip` peers on older installs |\n| `asterisk_dialplan` | Dumps a context, or one extension inside a context |\n| `asterisk_cli` | Any CLI command, subject to the safety policy below |\n| `asterisk_hangup_preview` | Shows which live channels a hangup would drop, without dropping them |\n| `asterisk_originate` | Places a call. Write mode only |\n| `asterisk_hangup` | Kills a channel by name. Write mode only |\n\n### FreeSWITCH\n\n| Tool | What it does |\n|---|---|\n| `freeswitch_status` | Version, uptime, current and maximum sessions |\n| `freeswitch_channels` | Every live call leg from `show channels`. Optional substring filter that keeps the header row |\n| `freeswitch_registrations` | Registered users on a Sofia profile, with contact URI, user agent and expiry |\n| `freeswitch_sofia_status` | Every SIP profile and gateway, including whether trunks are registered upstream |\n| `freeswitch_api` | Any API command, subject to the safety policy below |\n| `freeswitch_hangup_preview` | Shows which live legs a hangup would drop, without dropping them |\n| `freeswitch_originate` | Places a call. Write mode only |\n| `freeswitch_hangup` | `uuid_kill` on a channel UUID. Write mode only |\n\n## Safety\n\nA PBX is not a scratch pad. Reloading a profile drops registrations, and an originate spends real money on a live trunk. So the default posture is read-only and the guards are layered:\n\n**Read-only by default.** `asterisk_cli` accepts an allow list of inspection prefixes (`core show`, `pjsip show`, `dialplan show`, `queue show` and friends). `freeswitch_api` accepts the same kind of list (`status`, `show`, `sofia status`, `db list` and friends), matched on the start of the command so the subcommand counts.\n\n**The FreeSWITCH list allows subcommands, it does not deny scary words.** `sofia status` reads, `sofia profile internal restart` isn't on the list, so it's refused. This used to work the other way around, scanning each word against a list of state changing verbs, and that only ever catches the words somebody thought of. `conference 3001 kick all` walked straight through it. Reported by `Electrical-Place-458` on r/mcp.\n\n**Write tools aren't registered at all in read-only mode.** `asterisk_originate` and the other three never appear in `tools/list` unless you set `PBX_MCP_ALLOW_WRITE=true`. A model can't call a tool it can't see.\n\n**The hangup preview tools are always available.** `asterisk_hangup_preview` and `freeswitch_hangup_preview` show which live channels a hangup would drop without touching them, so you can see the blast radius before setting the write flag, or catch a typo in a channel name before running the real thing. They're read-only by contract but exercise the same matching the write path uses.\n\n**Shell metacharacters are rejected** on both transports before a command is sent.\n\n**AMI header injection is blocked.** Every field that lands in an AMI action is checked for carriage returns and newlines, so a caller ID string can't smuggle in an extra header.\n\n**Output is clamped** to 20,000 characters. One `show channels` on a busy switch won't flood the context window.\n\nEven with all that, give the AMI user the narrowest permission set that answers your questions, and put the PBX behind a firewall rather than on the public internet.\n\n## Build from source\n\n```bash\ngit clone https://github.com/ictinnovations/pbx-mcp.git\ncd pbx-mcp\nnpm install\nnpm run build\nnpm start\n```\n\nThe AMI and ESL clients have no third party dependencies. Both protocols are just framed text over TCP, and hand rolling them keeps the install small and the behaviour predictable. The only runtime dependencies are the MCP SDK and Zod.\n\n## The protocol clients, on their own\n\nIf you want to talk to a PBX from your own Node code and don't need MCP at all, the two clients underneath this server are published separately. Same protocol work, no MCP SDK, no Zod, nothing:\n\n- **[asterisk-ami-node](https://github.com/ictinnovations/asterisk-ami-node)** - Asterisk Manager Interface client. `npm install asterisk-ami-node`\n- **[freeswitch-esl-node](https://github.com/ictinnovations/freeswitch-esl-node)** - FreeSWITCH Event Socket client, inbound mode. `npm install freeswitch-esl-node`\n\nBoth are zero dependency, TypeScript, ESM and CommonJS, Node 18 or newer, and tested against mock switches so you can run the suite without a PBX.\n\n## Layout\n\n```\nsrc/\n  index.ts          entry point, config to transport wiring\n  ami.ts            Asterisk Manager Interface client\n  esl.ts            FreeSWITCH Event Socket Layer client\n  config.ts         environment config and the command safety policy\n  tools/\n    asterisk.ts     Asterisk tool definitions\n    freeswitch.ts   FreeSWITCH tool definitions\n    format.ts       text table and truncation helpers\n```\n\n## Contributing\n\nIssues and pull requests are welcome. If you're adding a tool, describe it the way you'd describe it to a colleague who has never seen your dialplan. The model picks tools from those descriptions, so a vague one is a broken one.\n\n## About\n\nBuilt and maintained by **Tahir Almas**, founder of [ICT Innovations](https://ictinnovations.com).\n\nICT Innovations has shipped open source and commercial telephony since 2005. If pbx-mcp is useful to you, the wider stack behind it might be too:\n\n- **[ICTCore](https://github.com/ictinnovations/ictcore)** - open source telephony framework, the base for the products below\n- **[ICTPBX](https://ictpbx.com)** - white label multi tenant IP PBX, with a free community edition on GitHub\n- **[ICTContact](https://ictcontact.com)** - contact center and unified communications\n- **[ICTDialer](https://ictdialer.com)** - auto and predictive dialer\n- **[ICTFax](https://ictfax.org)** - open source fax server\n- **[asterisk-ami-node](https://github.com/ictinnovations/asterisk-ami-node)** and **[freeswitch-esl-node](https://github.com/ictinnovations/freeswitch-esl-node)** - the protocol clients from this repo, published on their own\n\nQuestions about the commercial products go through [the ICT Innovations support portal](https://service.ictinnovations.com/contact.php). Questions about pbx-mcp itself belong in GitHub issues, where everyone can read the answer.\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n",
  "bytes": 12317,
  "sha": "ff908428e7b4817007eb1538557096a7509fda5593df44954b1e9c269b28b70e",
  "repo_slug": "ictinnovations/pbx-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_ictinnovations_pbx_mcp_a5e927f6/readme"
}