This project is a TypeScript Node.js server designed to act as a Management Control Program (MCP) for an Asterisk server. It provides functionalities to interact with Asterisk.
Proof of Concept (POC) - Phase 1: The initial version primarily focuses on a proof-of-concept command: checking PJSIP endpoint registration status. This serves as the first round of testing and establishes the foundational connection and interaction with Asterisk.
Future Vision: The long-term goal is to develop this into a full-fledged MCP server. This advanced server will enable comprehensive control and management of an Asterisk instance, potentially through an interface suitable for interaction with Large Language Models (LLMs) like Claude. Planned capabilities include, but are not limited to:
- Creating and managing extensions (PJSIP and SIP)
- Configuring ring groups
- Setting up and managing call queues
- Modifying dialplan logic
- Real-time call monitoring and control
- And much more, providing a robust API for programmatic Asterisk administration.
This project aims to simplify complex Asterisk management tasks through a modern, programmatic interface.
- Node.js (v16 or later recommended)
- npm (usually comes with Node.js)
- An Asterisk server with AMI (Asterisk Manager Interface) enabled and configured.
- For local development, you can run Asterisk in Docker, WSL, or a VM.
-
Clone the repository (if applicable) or ensure all files are in your project directory.
-
Install dependencies:
npm install
-
Configure Environment Variables:
- Copy the
.env.example
file to a new file named.env
:# On Windows (PowerShell) Copy-Item .env.example .env # On macOS/Linux # cp .env.example .env
- Edit the
.env
file with your Asterisk AMI credentials:Ensure your AsteriskASTERISK_HOST=your_asterisk_ip_or_hostname ASTERISK_PORT=your_ami_port (default: 5038) ASTERISK_USERNAME=your_ami_username ASTERISK_SECRET=your_ami_secret
manager.conf
allows this user to connect from the host where this MCP server will run and has necessary read/write permissions (e.g.,system
,call
,config
,reporting
depending on future needs. ForPJSIPShowEndpoints
,system
orconfig
read permissions are typically needed).
- Copy the
-
Build the project:
npm run build
This compiles TypeScript to JavaScript in the
dist
directory. -
Start the server (production mode):
npm run start
This runs the compiled code from the
dist
directory. -
Start the server (development mode):
npm run dev
This uses
nodemon
andts-node
to run the server and automatically restart it on file changes in thesrc
directory. -
Lint the code:
npm run lint
This checks the code for linting errors using ESLint.
-
Format the code:
npm run format
This formats the code using Prettier.
-
Run tests:
npm run test
This executes tests using Jest.
-
Check PJSIP Registered Endpoints:
npm run check-endpoints
This script connects to the Asterisk server defined in your
.env
file, queries for PJSIP endpoints, and reports how many are currently considered registered.Note: This
check-endpoints
script is part of the initial proof-of-concept phase.
Ensure your Asterisk manager.conf
has a user configured with appropriate permissions. For example:
[mcp_user] ; Corresponds to ASTERISK_USERNAME
secret = your_ami_secret ; Corresponds to ASTERISK_SECRET
permit = 0.0.0.0/0 ; Or a more specific IP/subnet for security
read = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr,dialplan,originate
; Adjust read/write permissions as needed. For PJSIPShowEndpoints, 'system' or 'config' read is usually sufficient.
Reload Asterisk dialplan or manager settings after changes (manager reload
in Asterisk CLI).