MCP Audio Server

MCP Audio Server

A Model Context Protocol (MCP) server that gives AI agents the ability to process audio files — transcribe speech to text, detect spoken languages, and extract audio metadata.

Category
访问服务器

README

🎙️ MCP Audio Server

A Model Context Protocol (MCP) server that gives AI agents the ability to process audio files — transcribe speech to text, detect spoken languages, and extract audio metadata. Built with OpenAI Whisper and served over SSE (Server-Sent Events) transport for seamless integration with any MCP-compatible client.


✨ Features

Tool Description
speech_to_text Transcribes spoken dialogue from an audio file into structured text using Whisper
detect_audio_language Analyzes the first 30 seconds of audio to predict the primary spoken language with a confidence score
get_audio_metadata Extracts technical specs — duration, bitrate, sample rate, channels, format, and file size via ffprobe

Highlights

  • 🧠 Thread-safe model caching — Whisper models are loaded once and reused across requests
  • 🔒 Strict input validation — All inputs are validated with Pydantic (file existence, extension support, model size)
  • 📡 SSE transport — HTTP-based transport accessible by any MCP client over the network
  • 🎛️ Multiple Whisper models — Choose from tiny, base, small, medium, or large depending on accuracy/speed tradeoff
  • 🎵 Wide format support.mp3, .wav, .flac, .m4a, .ogg, .mp4, .aac

📁 Project Structure

mcp-audio-server/
├── server.py              # MCP server entry point — registers tools, runs SSE transport
├── audio_processor.py     # Core processing logic — transcription, language detection, metadata
├── models.py              # Pydantic models — request validation & standardized response format
├── requirements.txt       # Python dependencies
├── speech-text-MCP.json   # Pre-built n8n workflow for AI agent integration
└── tests/
    └── test_models.py     # Unit tests for input validation and response serialization

🛠️ Prerequisites

  • Python 3.10+
  • ffmpeg (required for audio metadata extraction and Whisper audio loading)
    • Windows: winget install ffmpeg or download from ffmpeg.org
    • macOS: brew install ffmpeg
    • Linux: sudo apt install ffmpeg
  • GPU (optional) — Whisper will use CUDA if available, otherwise falls back to CPU

🚀 Getting Started

1. Clone the repository

git clone https://github.com/<your-username>/mcp-audio-server.git
cd mcp-audio-server

2. Create a virtual environment and install dependencies

Using uv (recommended):

uv venv
uv pip install -r requirements.txt

Or with standard pip:

python -m venv .venv

# Windows
.venv\Scripts\activate

# macOS / Linux
source .venv/bin/activate

pip install -r requirements.txt

3. Start the server

python server.py

The server starts on http://127.0.0.1:8000 with the following endpoints:

Endpoint Purpose
http://127.0.0.1:8000/sse SSE connection endpoint for MCP clients
http://127.0.0.1:8000/messages/ JSON-RPC message endpoint

🧪 Testing

MCP Inspector

The MCP Inspector is the easiest way to test the server interactively:

npx @modelcontextprotocol/inspector
  1. Open the Inspector UI in your browser
  2. Set Transport TypeSSE
  3. Set URLhttp://127.0.0.1:8000/sse
  4. Click Connect
  5. Select any tool and provide an absolute path to an audio file

Unit Tests

pytest tests/ -v

🔌 Integration

n8n Workflow

A pre-built n8n workflow is included in speech-text-MCP.json. It sets up a complete AI agent pipeline:

Chat Trigger → AI Agent → Google Gemini LLM
                  ↕              ↕
            MCP Client     Buffer Memory
        (this server)

To import:

  1. Start n8n (npx n8n)
  2. Go to WorkflowsImport from File
  3. Select speech-text-MCP.json
  4. Configure your Google Gemini API credentials in the Google Gemini Chat Model node
  5. Ensure this MCP server is running on http://127.0.0.1:8000
  6. Activate the workflow and start chatting — the AI agent can now transcribe audio, detect languages, and extract metadata on demand

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "audio-server": {
      "url": "http://127.0.0.1:8000/sse"
    }
  }
}

Any MCP Client

Connect to the SSE endpoint at http://127.0.0.1:8000/sse using any MCP-compatible client. The server exposes three tools that are automatically discoverable through the MCP protocol.


📖 API Reference

speech_to_text

Transcribes audio to text using OpenAI Whisper.

Parameters:

Parameter Type Default Description
audio_path string required Absolute path to the audio file
model_size string "base" Whisper model variant: tiny, base, small, medium, large

Response:

{
  "status": "success",
  "data": {
    "text": "The transcribed text content...",
    "language": "en"
  }
}

detect_audio_language

Identifies the spoken language from the first 30 seconds of audio.

Parameters:

Parameter Type Default Description
audio_path string required Absolute path to the audio file

Response:

{
  "status": "success",
  "data": {
    "detected_language": "en",
    "confidence_score": 0.9847
  }
}

get_audio_metadata

Extracts technical metadata using ffprobe.

Parameters:

Parameter Type Default Description
audio_path string required Absolute path to the audio file

Response:

{
  "status": "success",
  "data": {
    "format_name": "mp3",
    "duration_seconds": 245.67,
    "size_bytes": 3932160,
    "bit_rate": "128000",
    "sample_rate": "44100",
    "channels": 2
  }
}

Error Response

All tools return a standardized error format on failure:

{
  "status": "error",
  "message": "Validation failed: The path '/bad/path.mp3' does not exist on this machine."
}

⚙️ Architecture

┌─────────────────────────────────────────────────────────┐
│                     MCP Client                          │
│         (Claude, n8n, Inspector, etc.)                  │
└──────────────────────┬──────────────────────────────────┘
                       │ SSE (HTTP)
                       ▼
┌──────────────────────────────────────────────────────────┐
│  server.py — FastMCP Server                              │
│  ┌────────────────┬──────────────────┬────────────────┐  │
│  │ speech_to_text │ detect_language   │ get_metadata   │  │
│  └───────┬────────┴────────┬─────────┴───────┬────────┘  │
│          │                 │                 │            │
│          ▼                 ▼                 ▼            │
│  ┌───────────────────────────────────────────────────┐   │
│  │  models.py — Pydantic Validation Layer            │   │
│  │  (AudioPathMixin, TranscriptionRequest, etc.)     │   │
│  └───────────────────────┬───────────────────────────┘   │
│                          ▼                               │
│  ┌───────────────────────────────────────────────────┐   │
│  │  audio_processor.py — Processing Engine           │   │
│  │  ┌─────────────┐  ┌───────────┐  ┌────────────┐  │   │
│  │  │   Whisper    │  │  Whisper   │  │  ffprobe   │  │   │
│  │  │ transcribe() │  │ detect()  │  │  metadata  │  │   │
│  │  └─────────────┘  └───────────┘  └────────────┘  │   │
│  └───────────────────────────────────────────────────┘   │
└──────────────────────────────────────────────────────────┘

📝 License

This project is open source. See LICENSE for details.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选