pbx-mcp is an MCP (Model Context Protocol) server used to let AI assistants inspect and control Asterisk and FreeSWITCH phone systems. The problem it solves is: debugging a PBX usually requires remembering two completely different sets of commands—Asterisk uses AMI and a CLI with hundreds of verbs, FreeSWITCH uses ESL and its own vocabulary system; when running both at the same time, operators need to constantly switch contexts. pbx-mcp provides a unified, clearly described tool interface on top of both, enabling assistants to go directly from "call failed" to sofia status gateway without requiring manual step-by-step explanation.
[Main capabilities] The server exposes twelve read-only tools to AI assistants, six for each engine, and each tool's description is clear enough that the model can select the correct tool without additional prompting. The four write tools (asterisk_originate, asterisk_hangup, freeswitch_originate, freeswitch_hangup) remain hidden until PBX_MCP_ALLOW_WRITE=true is set, and will not appear in the tool list.
[Usage] Running requires Node 18 or higher, and most MCP client configurations run it directly with npx. A prebuilt Docker image can also be used (ictinnovations/pbx-mcp on Docker Hub). When using Docker there are three key points: -i is not optional, the server communicates over stdio, and if stdin is not connected the container will start with no output and look like the server is broken; there are no ports that need to be published; the PBX must be reachable from inside the container, and if Asterisk is running on the Docker host, use host.docker.internal on Mac and Windows, and add --network host on Linux. The image runs as a non-root user and, like the other run methods, is read-only by default.
Configuration is done entirely through environment variables. You can set the Asterisk block, the FreeSWITCH block, or both. The server only registers tools for the engines that are actually configured, so an environment using only Asterisk will not see FreeSWITCH tools. AMI The user needs at least read = system,call,command and write = command; add originate if you plan to enable write mode.
Add the configuration to claude_desktop_config.json to use it, and the same applies to any MCP client that supports stdio. When running a container instead of npx, keep the env block and point command to Docker; each -e NAME without a value forwards that variable from the environment into the container, avoiding secrets appearing in the argument list.
[Security design] Read-only by default, with multiple layers of protection. asterisk_cli only accepts a whitelist of inspection-type prefixes (such as core show, pjsip show, dialplan show, queue show, etc.), and freeswitch_api accepts a similar list (such as status, show, sofia status, db list, etc.), matched by the start of the command. The FreeSWITCH whitelist allows subcommands rather than rejecting dangerous words; for example, sofia status is a read, while sofia profile internal restart is not in the list and will be rejected. In read-only mode, write tools are not registered at all. The hangup preview tool is always available and can show which active channels a hangup would affect without actually executing it. Both transport channels reject shell metacharacters before sending, AMI header injection is blocked, and output is limited to 20000 characters. Even with these protections, it is recommended to give the AMI user minimal privileges and place the PBX behind a firewall rather than on the public internet.
[Provisioning features (Asterisk only, optional)] There are also six tools that create, list, and delete PJSIP trunks and SIP extensions via AMI UpdateConfig, registered only when PBX_MCP_ALLOW_PROVISION=true, independent of write mode. Codec support includes ulaw, alaw, g722, g729, opus; names and numbers match ^[A-Za-z0-9_-]{1,32}$. To use it, create managed files next to pjsip.conf and include them, and give the AMI user additional permissions (config, command; originate is only needed in write mode). All provisioning calls are serialized within the process, becauseUpdateConfig is read-modify-write, so only one provisioner can run per managed file. Extension registration names are mcp-<number>, and passwords are 24-character random URL-safe strings, shown only once in the creation response.
[Usage limitations] The project is tested on Asterisk 22 (certified 22.8). The PJSIP options and UpdateConfig features used need to be revalidated on other versions; TCP and TLS trunks can be generated but have not been verified against real peers. Because SIP trunks and registerable extensions may be used for long-distance fraud, PBX_MCP_CONTEXT_ALLOW should point to a context that cannot dial out to the PSTN, and PBX_MCP_TRUNK_ALLOW should be kept as narrow as possible (hostnames are compared literally, not resolved, and IPv6 is not supported); an empty allow list rejects everything. It is recommended to try it on a lab or test PBX, and do not expose SIP 5060 or AMI 5038 to the public internet.
[Underlying clients] If you do not use MCP and only want to communicate with the PBX from Node code, two underlying protocol clients have been released separately: asterisk-ami-node (npm install asterisk-ami-node) and freeswitch-esl-node (npm install freeswitch-esl-node). Both are zero-dependency, TypeScript, support both ESM and CommonJS, require Node 18 or later, and have been tested against simulated switches.
The project is developed and maintained by Tahir Almas of ICT Innovations and is licensed under MIT.