@zhoujinandrew/fish-audio-mcp-server 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +430 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/services/fishAudioSDK.d.ts +29 -0
- package/dist/services/fishAudioSDK.d.ts.map +1 -0
- package/dist/services/fishAudioSDK.js +185 -0
- package/dist/services/fishAudioSDK.js.map +1 -0
- package/dist/tools/listReferences.d.ts +22 -0
- package/dist/tools/listReferences.d.ts.map +1 -0
- package/dist/tools/listReferences.js +40 -0
- package/dist/tools/listReferences.js.map +1 -0
- package/dist/tools/tts.d.ts +100 -0
- package/dist/tools/tts.d.ts.map +1 -0
- package/dist/tools/tts.js +328 -0
- package/dist/tools/tts.js.map +1 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/audioPlayer.d.ts +3 -0
- package/dist/utils/audioPlayer.d.ts.map +1 -0
- package/dist/utils/audioPlayer.js +35 -0
- package/dist/utils/audioPlayer.js.map +1 -0
- package/dist/utils/config.d.ts +4 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +119 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +27 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/realTimePlayer.d.ts +13 -0
- package/dist/utils/realTimePlayer.d.ts.map +1 -0
- package/dist/utils/realTimePlayer.js +92 -0
- package/dist/utils/realTimePlayer.js.map +1 -0
- package/dist/utils/referenceSelector.d.ts +35 -0
- package/dist/utils/referenceSelector.d.ts.map +1 -0
- package/dist/utils/referenceSelector.js +72 -0
- package/dist/utils/referenceSelector.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Daichi Okazaki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# Fish Audio MCP Server
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="./dcos/icon_fish-audio.webp" alt="Fish Audio Logo" width="300" height="300" />
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
[](https://badge.fury.io/js/@zhoujinandrew%2Ffish-audio-mcp-server) [](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
An MCP (Model Context Protocol) server that provides seamless integration between Fish Audio's Text-to-Speech API and LLMs like Claude, enabling natural language-driven speech synthesis.
|
|
11
|
+
|
|
12
|
+
## What is Fish Audio?
|
|
13
|
+
|
|
14
|
+
[Fish Audio](https://fish.audio/) is a cutting-edge Text-to-Speech platform that offers:
|
|
15
|
+
|
|
16
|
+
- 🌊 **State-of-the-art voice synthesis** with natural-sounding output
|
|
17
|
+
- 🎯 **Voice cloning capabilities** to create custom voice models
|
|
18
|
+
- 🌍 **Multilingual support** including English, Japanese, Chinese, and more
|
|
19
|
+
- ⚡ **Low-latency streaming** for real-time applications
|
|
20
|
+
- 🎨 **Fine-grained control** over speech prosody and emotions
|
|
21
|
+
|
|
22
|
+
This MCP server brings Fish Audio's powerful capabilities directly to your LLM workflows.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- 🎙️ **High-Quality TTS**: Leverage Fish Audio's state-of-the-art TTS models
|
|
27
|
+
- 🌊 **Streaming Support**: Real-time audio streaming for low-latency applications
|
|
28
|
+
- 🎨 **Multiple Voices**: Support for custom voice models via reference IDs
|
|
29
|
+
- 🎯 **Smart Voice Selection**: Select voices by ID, name, or tags
|
|
30
|
+
- 📚 **Voice Library Management**: Configure and manage multiple voice references
|
|
31
|
+
- 🔧 **Flexible Configuration**: Environment variable-based configuration
|
|
32
|
+
- 📦 **Multiple Audio Formats**: Support for MP3, WAV, PCM, and Opus
|
|
33
|
+
- 🚀 **Easy Integration**: Simple setup with any MCP-compatible client
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### Installation
|
|
38
|
+
|
|
39
|
+
You can run this MCP server directly using npx:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx @zhoujinandrew/fish-audio-mcp-server
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or install it globally:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @zhoujinandrew/fish-audio-mcp-server
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Configuration
|
|
52
|
+
|
|
53
|
+
1. Get your Fish Audio API key from [Fish Audio](https://fish.audio/)
|
|
54
|
+
|
|
55
|
+
2. Set up environment variables:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export FISH_API_KEY=your_fish_audio_api_key_here
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. Add to your MCP settings configuration:
|
|
62
|
+
|
|
63
|
+
#### Single Voice Mode (Simple)
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"fish-audio": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["-y", "@zhoujinandrew/fish-audio-mcp-server"],
|
|
70
|
+
"env": {
|
|
71
|
+
"FISH_API_KEY": "your_fish_audio_api_key_here",
|
|
72
|
+
"FISH_MODEL_ID": "speech-1.6",
|
|
73
|
+
"FISH_REFERENCE_ID": "your_voice_reference_id_here",
|
|
74
|
+
"FISH_OUTPUT_FORMAT": "mp3",
|
|
75
|
+
"FISH_STREAMING": "false",
|
|
76
|
+
"FISH_LATENCY": "balanced",
|
|
77
|
+
"FISH_MP3_BITRATE": "128",
|
|
78
|
+
"FISH_AUTO_PLAY": "false",
|
|
79
|
+
"AUDIO_OUTPUT_DIR": "~/.fish-audio-mcp/audio_output"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Multiple Voice Mode (Advanced)
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"fish-audio": {
|
|
91
|
+
"command": "npx",
|
|
92
|
+
"args": ["-y", "@zhoujinandrew/fish-audio-mcp-server"],
|
|
93
|
+
"env": {
|
|
94
|
+
"FISH_API_KEY": "your_fish_audio_api_key_here",
|
|
95
|
+
"FISH_MODEL_ID": "speech-1.6",
|
|
96
|
+
"FISH_REFERENCES": "[{'reference_id':'id1','name':'Alice','tags':['female','english']},{'reference_id':'id2','name':'Bob','tags':['male','japanese']},{'reference_id':'id3','name':'Carol','tags':['female','japanese','anime']}]",
|
|
97
|
+
"FISH_DEFAULT_REFERENCE": "id1",
|
|
98
|
+
"FISH_OUTPUT_FORMAT": "mp3",
|
|
99
|
+
"FISH_STREAMING": "false",
|
|
100
|
+
"FISH_LATENCY": "balanced",
|
|
101
|
+
"FISH_MP3_BITRATE": "128",
|
|
102
|
+
"FISH_AUTO_PLAY": "false",
|
|
103
|
+
"AUDIO_OUTPUT_DIR": "~/.fish-audio-mcp/audio_output"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Environment Variables
|
|
111
|
+
|
|
112
|
+
| Variable | Description | Default | Required |
|
|
113
|
+
|----------|-------------|---------|----------|
|
|
114
|
+
| `FISH_API_KEY` | Your Fish Audio API key | - | Yes |
|
|
115
|
+
| `FISH_MODEL_ID` | TTS model to use (s1, speech-1.5, speech-1.6) | `s1` | Optional |
|
|
116
|
+
| `FISH_REFERENCE_ID` | Default voice reference ID (single reference mode) | - | Optional |
|
|
117
|
+
| `FISH_REFERENCES` | Multiple voice references (see below) | - | Optional |
|
|
118
|
+
| `FISH_DEFAULT_REFERENCE` | Default reference ID when using multiple references | - | Optional |
|
|
119
|
+
| `FISH_OUTPUT_FORMAT` | Default audio format (mp3, wav, pcm, opus) | `mp3` | Optional |
|
|
120
|
+
| `FISH_STREAMING` | Enable streaming mode (HTTP/WebSocket) | `false` | Optional |
|
|
121
|
+
| `FISH_LATENCY` | Latency mode (normal, balanced) | `balanced` | Optional |
|
|
122
|
+
| `FISH_MP3_BITRATE` | MP3 bitrate (64, 128, 192) | `128` | Optional |
|
|
123
|
+
| `FISH_AUTO_PLAY` | Auto-play audio and enable real-time playback | `false` | Optional |
|
|
124
|
+
| `AUDIO_OUTPUT_DIR` | Directory for audio file output | `~/.fish-audio-mcp/audio_output` | Optional |
|
|
125
|
+
|
|
126
|
+
### Configuring Multiple Voice References
|
|
127
|
+
|
|
128
|
+
You can configure multiple voice references in two ways:
|
|
129
|
+
|
|
130
|
+
#### JSON Array Format (Recommended)
|
|
131
|
+
Use the `FISH_REFERENCES` environment variable with a JSON array:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
FISH_REFERENCES='[
|
|
135
|
+
{"reference_id":"id1","name":"Alice","tags":["female","english"]},
|
|
136
|
+
{"reference_id":"id2","name":"Bob","tags":["male","japanese"]},
|
|
137
|
+
{"reference_id":"id3","name":"Carol","tags":["female","japanese","anime"]}
|
|
138
|
+
]'
|
|
139
|
+
FISH_DEFAULT_REFERENCE="id1"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Individual Format (Backward Compatibility)
|
|
143
|
+
Use numbered environment variables:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
FISH_REFERENCE_1_ID=id1
|
|
147
|
+
FISH_REFERENCE_1_NAME=Alice
|
|
148
|
+
FISH_REFERENCE_1_TAGS=female,english
|
|
149
|
+
|
|
150
|
+
FISH_REFERENCE_2_ID=id2
|
|
151
|
+
FISH_REFERENCE_2_NAME=Bob
|
|
152
|
+
FISH_REFERENCE_2_TAGS=male,japanese
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Usage
|
|
156
|
+
|
|
157
|
+
Once configured, the Fish Audio MCP server provides two tools to LLMs.
|
|
158
|
+
|
|
159
|
+
### Tool 1: `fish_audio_tts`
|
|
160
|
+
|
|
161
|
+
Generates speech from text using Fish Audio's TTS API.
|
|
162
|
+
|
|
163
|
+
#### Parameters
|
|
164
|
+
|
|
165
|
+
- `text` (required): Text to convert to speech (max 10,000 characters)
|
|
166
|
+
- `reference_id` (optional): Voice model reference ID
|
|
167
|
+
- `reference_name` (optional): Select voice by name
|
|
168
|
+
- `reference_tag` (optional): Select voice by tag
|
|
169
|
+
- `streaming` (optional): Enable streaming mode
|
|
170
|
+
- `format` (optional): Output format (mp3, wav, pcm, opus)
|
|
171
|
+
- `mp3_bitrate` (optional): MP3 bitrate (64, 128, 192)
|
|
172
|
+
- `normalize` (optional): Enable text normalization (default: true)
|
|
173
|
+
- `latency` (optional): Latency mode (normal, balanced)
|
|
174
|
+
- `output_path` (optional): Custom output file path
|
|
175
|
+
- `auto_play` (optional): Automatically play the generated audio
|
|
176
|
+
- `websocket_streaming` (optional): Use WebSocket streaming instead of HTTP
|
|
177
|
+
- `realtime_play` (optional): Play audio in real-time during WebSocket streaming
|
|
178
|
+
- `speed` (optional): Speaking rate multiplier (0.5=half speed, 1.0=normal, 2.0=double speed)
|
|
179
|
+
- `volume` (optional): Volume adjustment in dB (0=no change, positive=louder, negative=quieter)
|
|
180
|
+
- `temperature` (optional): Expressiveness/emotion control (0=consistent, 1=emotional, default: 0.7)
|
|
181
|
+
|
|
182
|
+
**Voice Selection Priority**: reference_id > reference_name > reference_tag > default
|
|
183
|
+
|
|
184
|
+
### Tool 2: `fish_audio_list_references`
|
|
185
|
+
|
|
186
|
+
Lists all configured voice references.
|
|
187
|
+
|
|
188
|
+
#### Parameters
|
|
189
|
+
|
|
190
|
+
No parameters required.
|
|
191
|
+
|
|
192
|
+
#### Returns
|
|
193
|
+
|
|
194
|
+
- List of configured voice references with their IDs, names, and tags
|
|
195
|
+
- Default reference ID
|
|
196
|
+
|
|
197
|
+
### Examples
|
|
198
|
+
|
|
199
|
+
#### Basic Text-to-Speech
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
User: "Generate speech saying 'Hello, world! Welcome to Fish Audio TTS.'"
|
|
203
|
+
|
|
204
|
+
Claude: I'll generate speech for that text using Fish Audio TTS.
|
|
205
|
+
|
|
206
|
+
[Uses fish_audio_tts tool with text parameter]
|
|
207
|
+
|
|
208
|
+
Result: Audio file saved to ./audio_output/tts_2025-01-03T10-30-00.mp3
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Using Custom Voice by ID
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
User: "Generate speech with voice model xyz123 saying 'This is a custom voice test'"
|
|
215
|
+
|
|
216
|
+
Claude: I'll generate speech using the specified voice model.
|
|
217
|
+
|
|
218
|
+
[Uses fish_audio_tts tool with text and reference_id parameters]
|
|
219
|
+
|
|
220
|
+
Result: Audio generated with custom voice model xyz123
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### Using Voice by Name
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
User: "Use Alice's voice to say 'Hello from Alice'"
|
|
227
|
+
|
|
228
|
+
Claude: I'll generate speech using Alice's voice.
|
|
229
|
+
|
|
230
|
+
[Uses fish_audio_tts tool with reference_name: "Alice"]
|
|
231
|
+
|
|
232
|
+
Result: Audio generated with Alice's voice
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Using Voice by Tag
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
User: "Generate Japanese speech saying 'こんにちは' with an anime voice"
|
|
239
|
+
|
|
240
|
+
Claude: I'll generate Japanese speech with an anime-style voice.
|
|
241
|
+
|
|
242
|
+
[Uses fish_audio_tts tool with reference_tag: "anime"]
|
|
243
|
+
|
|
244
|
+
Result: Audio generated with anime voice style
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### List Available Voices
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
User: "What voices are available?"
|
|
251
|
+
|
|
252
|
+
Claude: I'll list all configured voice references.
|
|
253
|
+
|
|
254
|
+
[Uses fish_audio_list_references tool]
|
|
255
|
+
|
|
256
|
+
Result:
|
|
257
|
+
- Alice (id: id1) - Tags: female, english [Default]
|
|
258
|
+
- Bob (id: id2) - Tags: male, japanese
|
|
259
|
+
- Carol (id: id3) - Tags: female, japanese, anime
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### HTTP Streaming Mode
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
User: "Generate a long speech in streaming mode about the benefits of AI"
|
|
266
|
+
|
|
267
|
+
Claude: I'll generate the speech in streaming mode for faster response.
|
|
268
|
+
|
|
269
|
+
[Uses fish_audio_tts tool with streaming: true]
|
|
270
|
+
|
|
271
|
+
Result: Streaming audio saved to ./audio_output/tts_2025-01-03T10-35-00.mp3
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### WebSocket Real-time Streaming
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
User: "Stream and play in real-time: 'Welcome to the future of AI'"
|
|
278
|
+
|
|
279
|
+
Claude: I'll stream the speech via WebSocket and play it in real-time.
|
|
280
|
+
|
|
281
|
+
[Uses fish_audio_tts tool with websocket_streaming: true, realtime_play: true]
|
|
282
|
+
|
|
283
|
+
Result: Audio streamed and played in real-time via WebSocket
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### Adjusting Speed, Volume, and Expressiveness
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
User: "Generate speech saying 'Breaking news!' at 1.5x speed with high emotion"
|
|
290
|
+
|
|
291
|
+
Claude: I'll generate expressive, fast-paced speech.
|
|
292
|
+
|
|
293
|
+
[Uses fish_audio_tts tool with text, speed: 1.5, temperature: 0.9]
|
|
294
|
+
|
|
295
|
+
Result: Audio generated with increased speed and expressiveness
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Development
|
|
299
|
+
|
|
300
|
+
### Local Development
|
|
301
|
+
|
|
302
|
+
1. Clone the repository:
|
|
303
|
+
```bash
|
|
304
|
+
git clone https://github.com/da-okazaki/mcp-fish-audio-server.git
|
|
305
|
+
cd mcp-fish-audio-server
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
2. Install dependencies:
|
|
309
|
+
```bash
|
|
310
|
+
npm install
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
3. Create `.env` file:
|
|
314
|
+
```bash
|
|
315
|
+
cp .env.example .env
|
|
316
|
+
# Edit .env with your API key
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
4. Build the project:
|
|
320
|
+
```bash
|
|
321
|
+
npm run build
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
5. Run in development mode:
|
|
325
|
+
```bash
|
|
326
|
+
npm run dev
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Testing
|
|
330
|
+
|
|
331
|
+
Run the test suite:
|
|
332
|
+
```bash
|
|
333
|
+
npm test
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Project Structure
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
mcp-fish-audio-server/
|
|
340
|
+
├── src/
|
|
341
|
+
│ ├── index.ts # MCP server entry point
|
|
342
|
+
│ ├── tools/
|
|
343
|
+
│ │ └── tts.ts # TTS tool implementation
|
|
344
|
+
│ ├── services/
|
|
345
|
+
│ │ └── fishAudio.ts # Fish Audio API client
|
|
346
|
+
│ ├── types/
|
|
347
|
+
│ │ └── index.ts # TypeScript definitions
|
|
348
|
+
│ └── utils/
|
|
349
|
+
│ └── config.ts # Configuration management
|
|
350
|
+
├── tests/ # Test files
|
|
351
|
+
├── audio_output/ # Default audio output directory
|
|
352
|
+
├── package.json
|
|
353
|
+
├── tsconfig.json
|
|
354
|
+
└── README.md
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## API Documentation
|
|
358
|
+
|
|
359
|
+
### Fish Audio Service
|
|
360
|
+
|
|
361
|
+
The service provides two main methods:
|
|
362
|
+
|
|
363
|
+
1. **generateSpeech**: Standard TTS generation
|
|
364
|
+
- Returns audio buffer
|
|
365
|
+
- Suitable for short texts
|
|
366
|
+
- Lower memory usage
|
|
367
|
+
|
|
368
|
+
2. **generateSpeechStream**: Streaming TTS generation
|
|
369
|
+
- Returns audio stream
|
|
370
|
+
- Suitable for long texts
|
|
371
|
+
- Real-time processing
|
|
372
|
+
|
|
373
|
+
### Error Handling
|
|
374
|
+
|
|
375
|
+
The server handles various error scenarios:
|
|
376
|
+
|
|
377
|
+
- **INVALID_API_KEY**: Invalid or missing API key
|
|
378
|
+
- **NETWORK_ERROR**: Connection issues with Fish Audio API
|
|
379
|
+
- **INVALID_PARAMS**: Invalid request parameters
|
|
380
|
+
- **QUOTA_EXCEEDED**: API rate limit exceeded
|
|
381
|
+
- **SERVER_ERROR**: Fish Audio server errors
|
|
382
|
+
|
|
383
|
+
## Troubleshooting
|
|
384
|
+
|
|
385
|
+
### Common Issues
|
|
386
|
+
|
|
387
|
+
1. **"FISH_API_KEY environment variable is required"**
|
|
388
|
+
- Ensure you've set the `FISH_API_KEY` environment variable
|
|
389
|
+
- Check that the API key is valid
|
|
390
|
+
|
|
391
|
+
2. **"Network error: Unable to reach Fish Audio API"**
|
|
392
|
+
- Check your internet connection
|
|
393
|
+
- Verify Fish Audio API is accessible
|
|
394
|
+
- Check for proxy/firewall issues
|
|
395
|
+
|
|
396
|
+
3. **"Text length exceeds maximum limit"**
|
|
397
|
+
- Split long texts into smaller chunks
|
|
398
|
+
- Maximum supported length is 10,000 characters
|
|
399
|
+
|
|
400
|
+
4. **Audio files not appearing**
|
|
401
|
+
- Check the `AUDIO_OUTPUT_DIR` path exists
|
|
402
|
+
- Ensure write permissions for the directory
|
|
403
|
+
|
|
404
|
+
## Contributing
|
|
405
|
+
|
|
406
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
407
|
+
|
|
408
|
+
1. Fork the repository
|
|
409
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
410
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
411
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
412
|
+
5. Open a Pull Request
|
|
413
|
+
|
|
414
|
+
## License
|
|
415
|
+
|
|
416
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
417
|
+
|
|
418
|
+
## Acknowledgments
|
|
419
|
+
|
|
420
|
+
- [Fish Audio](https://fish.audio/) for providing the excellent TTS API
|
|
421
|
+
- [Anthropic](https://anthropic.com/) for creating the Model Context Protocol
|
|
422
|
+
- The MCP community for inspiration and examples
|
|
423
|
+
|
|
424
|
+
## Support
|
|
425
|
+
|
|
426
|
+
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/da-okazaki/mcp-fish-audio-server).
|
|
427
|
+
|
|
428
|
+
## Changelog
|
|
429
|
+
|
|
430
|
+
See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { TTSTool } from './tools/tts.js';
|
|
6
|
+
import { ListReferencesTool } from './tools/listReferences.js';
|
|
7
|
+
import { loadConfig } from './utils/config.js';
|
|
8
|
+
import { logger } from './utils/logger.js';
|
|
9
|
+
async function main() {
|
|
10
|
+
try {
|
|
11
|
+
// Validate configuration on startup
|
|
12
|
+
loadConfig();
|
|
13
|
+
// Create MCP server
|
|
14
|
+
const server = new Server({
|
|
15
|
+
name: 'fish-audio-mcp-server',
|
|
16
|
+
version: '0.1.0',
|
|
17
|
+
}, {
|
|
18
|
+
capabilities: {
|
|
19
|
+
tools: {},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
// Create and register tools
|
|
23
|
+
const ttsTool = new TTSTool();
|
|
24
|
+
const listRefTool = new ListReferencesTool();
|
|
25
|
+
const tools = [ttsTool, listRefTool];
|
|
26
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
27
|
+
tools: tools.map(tool => ({
|
|
28
|
+
name: tool.name,
|
|
29
|
+
description: tool.description,
|
|
30
|
+
inputSchema: tool.inputSchema,
|
|
31
|
+
})),
|
|
32
|
+
}));
|
|
33
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
34
|
+
const tool = tools.find(t => t.name === request.params.name);
|
|
35
|
+
if (tool) {
|
|
36
|
+
const result = await tool.run(request.params.arguments);
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: JSON.stringify(result, null, 2),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
47
|
+
});
|
|
48
|
+
// Start server with stdio transport
|
|
49
|
+
const transport = new StdioServerTransport();
|
|
50
|
+
await server.connect(transport);
|
|
51
|
+
logger.info('Fish Audio MCP Server started successfully');
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
logger.error('Failed to start Fish Audio MCP Server:', error);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Handle graceful shutdown
|
|
59
|
+
process.on('SIGINT', () => {
|
|
60
|
+
logger.info('Shutting down Fish Audio MCP Server...');
|
|
61
|
+
process.exit(0);
|
|
62
|
+
});
|
|
63
|
+
process.on('SIGTERM', () => {
|
|
64
|
+
logger.info('Shutting down Fish Audio MCP Server...');
|
|
65
|
+
process.exit(0);
|
|
66
|
+
});
|
|
67
|
+
// Run the server
|
|
68
|
+
main().catch((error) => {
|
|
69
|
+
logger.error('Unhandled error:', error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE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CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TTSParams, TTSResponse } from '../types/index.js';
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
export declare class FishAudioSDKService {
|
|
4
|
+
private apiKey;
|
|
5
|
+
private modelId;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Generate speech using standard HTTP API
|
|
9
|
+
*/
|
|
10
|
+
generateSpeech(params: TTSParams): Promise<TTSResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Generate speech with streaming to file
|
|
13
|
+
*/
|
|
14
|
+
generateSpeechStream(params: TTSParams, outputPath: string): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate speech using WebSocket for real-time streaming
|
|
17
|
+
*/
|
|
18
|
+
generateSpeechWebSocket(params: TTSParams, textChunks: string[] | AsyncGenerator<string>): AsyncGenerator<Buffer>;
|
|
19
|
+
/**
|
|
20
|
+
* Stream speech to a writable stream (for real-time playback)
|
|
21
|
+
*/
|
|
22
|
+
streamToPlayer(params: TTSParams, textChunks: string[] | AsyncGenerator<string>, playerStream: Writable): Promise<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Helper to convert array to async generator
|
|
25
|
+
*/
|
|
26
|
+
private arrayToAsyncGenerator;
|
|
27
|
+
private handleError;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fishAudioSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fishAudioSDK.d.ts","sourceRoot":"","sources":["../../src/services/fishAudioSDK.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAsBlC,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;;IAQxB;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAsC7D;;OAEG;IACG,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqClF;;OAEG;IACI,uBAAuB,CAC5B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC;IAkCzB;;OAEG;IACG,cAAc,CAClB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,EAC7C,YAAY,EAAE,QAAQ,GACrB,OAAO,CAAC,MAAM,CAAC;IAkBlB;;OAEG;YACY,qBAAqB;IAMpC,OAAO,CAAC,WAAW;CAuDpB"}
|