Skip to main content
Glama

Fonoster MCP Server

Official
by fonoster
MIT License
118
7,325
  • Apple
  • Linux
.intro.md2.87 kB
streams ================= [![Streams](https://img.shields.io/badge/streams-api-brightgreen.svg)](https://fonoster.com) [![Version](https://img.shields.io/npm/v/@fonoster/streams.svg)](https://npmjs.org/package/@fonoster/streams) [![Downloads/week](https://img.shields.io/npm/dw/@fonoster/streams.svg)](https://npmjs.org/package/@fonoster/streams) [![License](https://img.shields.io/npm/l/@fonoster/streams.svg)](https://github.com/fonoster/fonoster/blob/main/package.json) This is a NodeJS implementation of the AudioSocket protocol, which is a simple protocol for accessing bidirectional audio streams from Asterisk. * [Installation](#installation) * [Example](#example) * [APIs](#apis) ## Installation ```sh-session $ npm install --save @fonoster/streams ``` ## Example While the AudioSocket is a utility for Fonoster Streams, it can be used as a standalone module. To use this library with Asterisk, you must configure your dialplan to use the `AudioSocket` application. Here is an example of how to use the AudioSocket with Asterisk: ``` exten = 100,1,Verbose("Call to AudioSocket via Dialplan Application") same = n,Answer() same = n,AudioSocket(40325ec2-5efd-4bd3-805f-53576e581d13,server.example.com:9092) same = n,Hangup() ``` Or with the `Dial` application: ``` exten = 100,1,Verbose("Call to AudioSocket via Dialplan Application") same = n,Answer() same = n,Dial(SIP/100,30,A(AudioSocket(40325ec2-5efd-4bd3-805f-53576e581d13,server.example.com:9092))) same = n,Hangup() ``` Connecting to the AudioSocket server using ARI with the `externalMedia` endpoint is also possible. You must ensure you set the transport to `TCP` the UUID in the data field. > Currently, the payload towards Asterisk is limited to signed linear, 16-bit, 8kHz, mono PCM (little-endian). However, the payload from Asterisk can be changed with the `format` parameter when using ARI. Please see the [AudioSocket Server](https://github.com/silentindark/audiosocket_server) implementation, for interesting notes about AudioSocket. Once Asterisk is configured, you can use the `AudioSocket` class to create a server that listens for connections. Here is an example of how to use the `AudioSocket` class: ```js const { AudioSocket } = require("@fonoster/streams"); const audioSocket = new AudioSocket(); audioSocket.onConnection(async (req, res) => { console.log("new connection from:", req.ref); res.on("data", (data) => { // Do something with the audio data ); res.on("end", () => { // Do something when the stream ends }); res.on("error", (err) => { // Do something when an error occurs }); // Utility for playing audio files await res.play("/path/to/audio/file"); }); audioSocket.listen(9092, () => { console.log("server listening on port 9092"); }); ``` ## APIs * [`AudioSocket`](#AudioSocket) * [`AudioStream`](#AudioStream)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fonoster/fonoster'

If you have feedback or need assistance with the MCP directory API, please join our Discord server