main
1package main
2
3import (
4 "context"
5 "flag"
6 "fmt"
7 "log"
8
9 "github.com/xlgmokha/mcp/pkg/speech"
10)
11
12func main() {
13 var showHelp bool
14 flag.BoolVar(&showHelp, "help", false, "Show help information")
15 flag.Parse()
16
17 if showHelp {
18 showHelpText()
19 return
20 }
21
22 server, err := speech.New()
23 if err != nil {
24 log.Fatalf("Failed to create speech server: %v", err)
25 }
26 if err := server.Run(context.Background()); err != nil {
27 log.Fatalf("Server error: %v", err)
28 }
29}
30
31func showHelpText() {
32 fmt.Printf(`Speech MCP Server
33
34A cross-platform Model Context Protocol server that provides text-to-speech
35capabilities. Uses the native TTS system on each platform: macOS 'say' command
36or Linux espeak-ng/espeak. Enables LLMs to speak their responses with customizable
37voices, rates, and output options.
38
39USAGE:
40 mcp-speech [OPTIONS]
41
42OPTIONS:
43 --help Show this help message
44
45SUPPORTED PLATFORMS:
46 • macOS - Uses built-in 'say' command (already available)
47 • Linux - Uses espeak-ng or espeak (install required)
48
49TOOLS PROVIDED:
50
51Speech Synthesis:
52 say Speak text with customizable voice, rate, and volume
53 list_voices List all available system voices with filtering
54 speak_file Read and speak the contents of a text file
55 stop_speech Stop any currently playing speech synthesis
56 speech_settings Get detailed information about speech options and backend
57
58EXAMPLES:
59
60Basic Speech:
61 # Simple text-to-speech
62 {"name": "say", "arguments": {"text": "Hello, this is a test"}}
63
64 # Custom voice and speed (macOS)
65 {"name": "say", "arguments": {"text": "Hello world", "voice": "Samantha", "rate": 150}}
66
67 # Custom voice and speed (Linux)
68 {"name": "say", "arguments": {"text": "Hello world", "voice": "en-gb", "rate": 150}}
69
70 # Adjust volume
71 {"name": "say", "arguments": {"text": "Quiet speech", "volume": 0.3}}
72
73Voice Management:
74 # List all voices
75 {"name": "list_voices", "arguments": {}}
76
77 # List English voices only
78 {"name": "list_voices", "arguments": {"language": "en"}}
79
80 # Get detailed voice information
81 {"name": "list_voices", "arguments": {"detailed": true}}
82
83File Operations:
84 # Speak file contents
85 {"name": "speak_file", "arguments": {"file_path": "/path/to/document.txt"}}
86
87 # Speak first 10 lines only
88 {"name": "speak_file", "arguments": {"file_path": "README.md", "max_lines": 10}}
89
90Audio Output:
91 # Save speech to file (macOS: .aiff, .wav, .m4a)
92 {"name": "say", "arguments": {"text": "Recording test", "output": "~/speech.wav"}}
93
94 # Save speech to file (Linux: .wav only)
95 {"name": "say", "arguments": {"text": "Recording test", "output": "~/speech.wav"}}
96
97Control:
98 # Stop any playing speech
99 {"name": "stop_speech", "arguments": {}}
100
101 # Get help with settings and backend info
102 {"name": "speech_settings", "arguments": {}}
103
104VOICE OPTIONS:
105
106macOS (built-in voices):
107 • Alex (default male voice)
108 • Samantha (clear female voice)
109 • Victoria (British female voice)
110 • Fred (older male voice)
111 • Fiona (Scottish female voice)
112 • Moira (Irish female voice)
113
114Linux (espeak-ng voices):
115 • en-gb (British English)
116 • en-us (American English)
117 • en-gb-scotland (Scottish English)
118 • Various other languages and accents
119
120PARAMETERS:
121 text - Text to speak (required for 'say')
122 voice - Voice name (use list_voices to see options)
123 rate - Speech rate in words per minute (80-500, default ~200)
124 volume - Volume level from 0.0 to 1.0 (default: system volume)
125 output - Save audio to file (formats vary by platform)
126 file_path - Path to text file to speak
127 max_lines - Limit number of lines to speak from file
128 language - Filter voices by language code (e.g., "en", "es")
129 detailed - Show detailed voice information
130
131INSTALLATION:
132
133Linux Requirements:
134 # Ubuntu/Debian
135 sudo apt install espeak-ng
136
137 # Fedora/RHEL
138 sudo dnf install espeak-ng
139
140 # Arch Linux
141 sudo pacman -S espeak-ng
142
143macOS Requirements:
144 # Built-in 'say' command - no installation needed
145
146BACKEND DETECTION:
147The server automatically detects the appropriate TTS backend:
148 • macOS: Uses 'say' command
149 • Linux: Uses 'espeak-ng' (preferred) or 'espeak' (fallback)
150 • Other: Shows helpful installation instructions
151
152For support or issues, see: https://github.com/xlgmokha/mcp
153`)
154}