mcp-audio-server

A powerful Model Context Protocol (MCP) server that provides text-to-speech and audio playback capabilities for Claude Desktop and other MCP clients.

GitHub Stars

1

User Rating

Not Rated

Favorites

0

Views

31

Forks

0

Issues

0

README
MCP Audio Server ๐Ÿ”Š

English | ไธญๆ–‡

A powerful Model Context Protocol (MCP) server that provides text-to-speech and audio playback capabilities for Claude Desktop and other MCP clients.

โœจ Features
  • ๐Ÿ—ฃ๏ธ High-Quality TTS:
    • Smart Language Detection: Automatically uses Google's TTS for high-quality Chinese speech and falls back to the system's TTS for other languages.
    • Voice Selection: For non-Chinese text, list and select from various system-installed voices.
    • Customizable Speech: Adjust rate and volume for a tailored listening experience.
  • ๐ŸŽต Audio File Playback: Play various audio formats (WAV, MP3, OGG, etc.).
  • โน๏ธ Audio Control: Stop playback and get real-time audio status.
  • ๐Ÿ”Œ MCP Compliant: Fully compatible with Claude Desktop and MCP specification 2024-11-05.
  • ๐Ÿ›ก๏ธ Error Handling: Robust error handling and validation.
  • ๐Ÿ“Š Status Monitoring: Real-time audio system status and playback information.
๐Ÿš€ Quick Start
Prerequisites
  • Python 3.8+
  • Claude Desktop (for MCP integration)
  • System audio capabilities
Installation
  1. Clone the repository:
git clone https://github.com/yourusername/mcp-audio-server.git
cd mcp-audio-server
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure Claude Desktop:
    Add to your claude_desktop_config.json:
{
  "mcpServers": {
    "audio-server": {
      "command": "/path/to/your/python",
      "args": ["/path/to/mcp-audio-server/audio_server.py"]
    }
  }
}
  1. Restart Claude Desktop and start using audio features!
๐Ÿ› ๏ธ Available Tools
Tool Description Parameters
speak_text Convert text to speech. Automatically uses Google TTS for Chinese. text (required), rate (optional), volume (optional), voice_id (optional, for non-Chinese)
list_voices List available TTS voices for non-Chinese languages. None
play_audio_file Play an audio file. file_path (required), volume (optional)
stop_audio Stop current audio playback. None
get_audio_status Get audio system status. None
๐Ÿ“– Usage Examples
Text-to-Speech (Chinese)
"่ฏท็”จ่ฏญ้Ÿณ่ฏดๅ‡บ 'ไฝ ๅฅฝ๏ผŒไธ–็•Œ'"

This will automatically use Google TTS for a natural-sounding voice.

Text-to-Speech (English, with a specific voice)
  1. First, list available voices:
    "List all available voices"
    
  2. Then, use a specific voice ID from the list:
    "Use the voice with ID 'com.apple.speech.synthesis.voice.daniel' to say 'Hello, this is a test.'"
    
Play Audio File
"Play the audio file at /path/to/music.mp3"
Stop Audio
"Stop the current audio playback"
Check Status
"What's the current audio status?"
๐Ÿงช Testing

Run the comprehensive test suite:

# Test all MCP methods
python test_all_mcp_methods.py

# Test Claude Desktop format compatibility
python test_claude_desktop_format.py

# Test audio functionality
python test_audio_server.py

# Interactive testing mode
python audio_server.py --interactive
๐Ÿ“ Project Structure
mcp-audio-server/
โ”œโ”€โ”€ audio_server.py              # Main MCP server
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ README.md                   # English documentation (default)
โ”œโ”€โ”€ README_CN.md                # Chinese documentation
โ”œโ”€โ”€ .gitignore                  # Git ignore rules
โ”œโ”€โ”€ tests/                      # Test files
โ”‚   โ”œโ”€โ”€ test_*.py               # Various tests
โ”‚   โ””โ”€โ”€ validate_*.py           # Validation scripts
โ”œโ”€โ”€ examples/                   # Configuration examples
โ”‚   โ”œโ”€โ”€ claude_desktop_config.json
โ”‚   โ””โ”€โ”€ other config files
โ”œโ”€โ”€ scripts/                    # Utility scripts
โ”‚   โ”œโ”€โ”€ install_and_setup.sh
โ”‚   โ””โ”€โ”€ other shell scripts
โ””โ”€โ”€ docs/                       # Additional documentation
    โ”œโ”€โ”€ INTEGRATION_GUIDE.md    # Integration guide
    โ”œโ”€โ”€ USAGE_GUIDE.md          # Usage guide
    โ””โ”€โ”€ FINAL_INTEGRATION_REPORT.md
๐Ÿ”ง Configuration
Claude Desktop Configuration

The server integrates seamlessly with Claude Desktop. Make sure your configuration file is properly set up:

Location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Example configuration:

{
  "mcpServers": {
    "audio-server": {
      "command": "/Users/yourusername/miniconda3/envs/mcp_agent/bin/python",
      "args": ["/path/to/mcp-audio-server/audio_server.py"]
    }
  }
}
๐Ÿ› Troubleshooting
Common Issues
  1. Audio not playing: Check system audio settings and permissions
  2. TTS not working: Ensure pyttsx3 is properly installed
  3. MCP connection issues: Verify Claude Desktop configuration path
  4. Permission errors: Check file permissions for audio files
Debug Mode

Run in interactive mode for debugging:

python audio_server.py --interactive
๐Ÿค Contributing
  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request
๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments
  • Built with the Model Context Protocol (MCP)
  • Uses pyttsx3 for text-to-speech
  • Uses pygame for audio playback
  • Compatible with Claude Desktop
๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section
  2. Review the integration guide
  3. Open an issue on GitHub
  4. Check Claude Desktop documentation

Made with โค๏ธ for the MCP community