Telephony MCP Server

Telephony MCP Server

Enables LLM applications to make voice calls and send SMS messages through the Vonage API, allowing AI assistants to perform real-world telephony operations with support for speech recognition and customizable voice parameters.

Category
访问服务器

README

Black Ruff

📖 Blog Post: Learn more about this project in the detailed blog post: Telephony MCP Server for Agentic AI and Language Models

Telephony MCP Server

Demo Using Claude Desktop

Agentic Telephony Conversation with Speech Recognition

<img src="./resources/demo-claude-agentic-call-speech-recognition.gif" alt="Agentic Telephony Conversation with Speech Recognition" style="border: 4px solid white; border-radius: 8px;"/>

<span style="color: yellow;">Use SMS during mid-conversation</span>

<img src="./resources/demo-claude-desktop.gif" alt="Telephony MCP Server Demo" style="border: 4px solid yellow; border-radius: 8px; display: block; margin-left: 0;"/>

<span style="color: #b5651d;">SMS Enquiry (Send and Receive)</span>

<img src="./resources/demo-claude-sms-enquiry.png" alt="SMS Enquiry" style="border: 4px solid #b5651d; border-radius: 8px; display: block; margin-left: 0;" width="800"/>

<span style="color: green;">Demo Using GitHub Copilot</span>

<img src="./resources/demo-copilot.gif" alt="Telephony MCP Server Demo" style="border: 4px solid green; border-radius: 8px; display: block; margin-left: 0;"/>

Introduction

This directory contains MCP (Model Context Protocol) Server tools for telephony operations, such as making voice calls and sending SMS messages using the Vonage API. These tools are designed to be integrated with Large Language Model (LLM) applications, enabling LLMs to perform real-world actions beyond simple text generation.

LLMs and Tool Integration

LLMs (Large Language Models) are advanced token generators—they can generate text, images, or even video based on input prompts. However, their core capability is limited to generating content; they cannot access external data or perform actions in the real world on their own.

To extend their functionality, LLMs can be connected to external tools. For example, when a user asks, "What's the weather today?" the LLM can invoke a backend API tool like get_weather(city) via a system prompt, parse the response, and return the result to the user. This tool-calling mechanism transforms a basic LLM into a powerful LLM Application.

Tool Calling with MCP and LangChain

  • LangChain is a popular framework for developing applications powered by LLMs. It provides a collection of pre-built tools (called a Toolkit) that LLMs can use to interact with external systems.
  • MCP (Model Context Protocol) follows the same concept: it offers a collection of pre-built tools and a framework for writing new tools and handling function calling.
  • Both frameworks allow LLMs to invoke tools, parse their outputs, and integrate the results into their responses.

How This Works

  1. Tool Definition: In this project, tools like voice_call and send_sms are defined using the MCP framework. Each tool is a function that can be called by an LLM application.
  2. LLM Application: When integrated with an LLM (such as OpenAI's GPT, Anthropic's Claude, etc.), the LLM can decide to call these tools based on user prompts.
  3. Execution Flow:
    • The LLM receives a prompt (e.g., "Call Alice and say hello").
    • The LLM determines that a tool invocation is needed and calls the appropriate MCP tool (e.g., voice_call).
    • The tool executes (e.g., initiates a phone call via Vonage) and returns the result.
    • The LLM parses the response and presents it to the user.

Running the MCP Tools

Prerequisites

  • Python 3.13+
  • MCP CLI (mcp[cli]), FastAPI, httpx, pyjwt, python-dotenv, uvicorn, pydantic (see pyproject.toml for details)
  • Vonage API credentials (API key, secret, application ID, private key)
  • Public URL for callback server (for production use)

Setup

  1. Install dependencies:

    pip install -r requirements.txt
    

    Or, if using Poetry:

    poetry install
    
  2. Configure environment variables:

    • Create a .env file with your Vonage credentials:

      VONAGE_API_KEY=your_api_key
      VONAGE_API_SECRET=your_api_secret
      VONAGE_APPLICATION_ID=your_app_id
      VONAGE_PRIVATE_KEY_PATH=path/to/private.key
      VONAGE_LVN=your_virtual_number
      VONAGE_API_URL=https://api.nexmo.com/v1/calls
      VONAGE_SMS_URL=https://rest.nexmo.com/sms/json
      CALLBACK_SERVER_URL=https://your-public-url  # URL for Vonage event callbacks
      

      For the CALLBACK_SERVER_URL:

      • In development: You can use http://localhost:8080 (default if not specified)
      • In production: Use a public URL (such as an ngrok URL or your deployed server)
  3. Run the MCP server:

    python telephony_server.py
    

    The server will start and expose the defined tools for LLM applications.

Running with Docker

You can also run the telephony MCP server using Docker:

  1. Build and start the Docker container:

    docker compose up --build
    

    Or to run in the background:

    docker compose up --build -d
    
  2. Stop the Docker container:

    docker compose down
    
  3. View logs from the Docker container:

    docker compose logs -f
    

Using with LLM Applications

  • Direct Integration: Connect your LLM application (e.g., using LangChain via Adapter or a custom MCP client) to the running MCP server. The LLM can now invoke telephony tools as needed.
  • Example: When the LLM receives a prompt like "Dial this number +123 and read latest news from today", it will call the voice_call tool, passing the required parameters.
  • Example: When the LLM receives a prompt like "Call this number using a British accent", it will call the voice_call tool with specific language and style parameters.
  • Example: When the LLM receives a prompt like "Text the news instead", it will call the send_sms tool, passing the required parameters.

Using with Claude Desktop or other MCP clients

To configure an MCP client (like Claude Desktop) to use your telephony MCP server:

  1. Update your MCP client configuration file (e.g., claude_desktop_config.json):

    {
      "mcpServers": {
        "telephony": {
          "command": "docker",
          "args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "telephony-mcp-server"]
        }
      }
    }
    
  2. Build the Docker image (if not using docker compose):

    docker build -t telephony-mcp-server .
    
  3. Restart your MCP client to apply the changes.

Key Concepts

  • LLMs are content generators: They generate text, images, or video, but need external tools for actions like web search, telephony, or database access.
  • Tool calling: LLMs can invoke backend APIs (tools) to fetch data or perform actions, then parse and present the results.
  • Frameworks: Both LangChain and MCP provide a structure for defining, registering, and invoking tools from LLMs.
  • MCP: Helps you write new tools and manage function calling, making it easy to extend LLM applications with custom capabilities.

Callback Server for Vonage Events

The Telephony MCP Server also includes a Vonage Callback Server that listens on port 8080. This server is used to receive event notifications from Vonage Voice API, which are sent when voice calls are initiated, completed, or encounter errors.

Features

  • Receives and stores Vonage event callbacks
  • Provides endpoints to view and manage stored events
  • Runs as a separate service within the same application

Endpoints

  • GET / - Health check endpoint
  • POST /event - Main endpoint for receiving Vonage callbacks
  • GET /events - List all stored events (with pagination)
  • GET /events/{event_id} - Get a specific event by ID
  • DELETE /events - Clear all stored events

Configuration

To use the callback server with Vonage Voice API, you need to set the CALLBACK_SERVER_URL environment variable to your server's public URL. This URL will be used as the event_url parameter in Vonage API calls.

export CALLBACK_SERVER_URL="https://your-public-url"

For local development, you can use a service like ngrok to expose your local server to the internet:

ngrok http 8080

Then set the CALLBACK_SERVER_URL to the ngrok URL.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选