@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for MCP environment
|
|
3
|
+
* Writes debug messages to stderr only when DEBUG environment variable is set
|
|
4
|
+
* This prevents interfering with MCP's JSON communication
|
|
5
|
+
*/
|
|
6
|
+
export declare const logger: {
|
|
7
|
+
debug: (message: string, ...args: any[]) => void;
|
|
8
|
+
error: (message: string, error?: any) => void;
|
|
9
|
+
info: (message: string, ...args: any[]) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,MAAM;qBACA,MAAM,WAAW,GAAG,EAAE;qBAMtB,MAAM,UAAU,GAAG;oBASpB,MAAM,WAAW,GAAG,EAAE;CAKvC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for MCP environment
|
|
3
|
+
* Writes debug messages to stderr only when DEBUG environment variable is set
|
|
4
|
+
* This prevents interfering with MCP's JSON communication
|
|
5
|
+
*/
|
|
6
|
+
const isDebug = process.env.DEBUG === 'true' || process.env.DEBUG === '1';
|
|
7
|
+
export const logger = {
|
|
8
|
+
debug: (message, ...args) => {
|
|
9
|
+
if (isDebug) {
|
|
10
|
+
process.stderr.write(`[DEBUG] ${message} ${args.length > 0 ? JSON.stringify(args) : ''}\n`);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
error: (message, error) => {
|
|
14
|
+
if (isDebug) {
|
|
15
|
+
const errorInfo = error instanceof Error ?
|
|
16
|
+
`${error.message}\n${error.stack}` :
|
|
17
|
+
error ? JSON.stringify(error) : '';
|
|
18
|
+
process.stderr.write(`[ERROR] ${message} ${errorInfo}\n`);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
info: (message, ...args) => {
|
|
22
|
+
if (isDebug) {
|
|
23
|
+
process.stderr.write(`[INFO] ${message} ${args.length > 0 ? JSON.stringify(args) : ''}\n`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC;AAE1E,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;IAED,KAAK,EAAE,CAAC,OAAe,EAAE,KAAW,EAAE,EAAE;QACtC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC;gBACxC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;gBACpC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PassThrough } from 'stream';
|
|
2
|
+
export declare class RealTimeAudioPlayer {
|
|
3
|
+
private process;
|
|
4
|
+
private stream;
|
|
5
|
+
private isPlaying;
|
|
6
|
+
private os;
|
|
7
|
+
constructor();
|
|
8
|
+
start(format?: string): PassThrough;
|
|
9
|
+
write(chunk: Buffer): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
isSupported(): boolean;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=realTimePlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realTimePlayer.d.ts","sourceRoot":"","sources":["../../src/utils/realTimePlayer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,WAAW,EAAE,MAAM,QAAQ,CAAC;AAG/C,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,EAAE,CAAS;;IAMnB,KAAK,CAAC,MAAM,GAAE,MAAe,GAAG,WAAW;IAoE3C,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM1B,IAAI,IAAI,IAAI;IAcZ,WAAW,IAAI,OAAO;CAGvB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { platform } from 'os';
|
|
3
|
+
import { PassThrough } from 'stream';
|
|
4
|
+
import { logger } from './logger.js';
|
|
5
|
+
export class RealTimeAudioPlayer {
|
|
6
|
+
process = null;
|
|
7
|
+
stream = null;
|
|
8
|
+
isPlaying = false;
|
|
9
|
+
os;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.os = platform();
|
|
12
|
+
}
|
|
13
|
+
start(format = 'opus') {
|
|
14
|
+
if (this.isPlaying) {
|
|
15
|
+
throw new Error('Audio player is already running');
|
|
16
|
+
}
|
|
17
|
+
this.stream = new PassThrough();
|
|
18
|
+
let command;
|
|
19
|
+
let args;
|
|
20
|
+
switch (this.os) {
|
|
21
|
+
case 'darwin': // macOS
|
|
22
|
+
if (format === 'opus' || format === 'mp3') {
|
|
23
|
+
// Use ffplay for opus/mp3 streaming
|
|
24
|
+
command = 'ffplay';
|
|
25
|
+
args = ['-f', format, '-nodisp', '-autoexit', '-i', 'pipe:0'];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Use afplay for other formats
|
|
29
|
+
command = 'afplay';
|
|
30
|
+
args = ['-'];
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
case 'win32': // Windows
|
|
34
|
+
// Use ffplay on Windows
|
|
35
|
+
command = 'ffplay';
|
|
36
|
+
args = ['-f', format, '-nodisp', '-autoexit', '-i', 'pipe:0'];
|
|
37
|
+
break;
|
|
38
|
+
case 'linux':
|
|
39
|
+
// Try mpv first, then ffplay
|
|
40
|
+
command = 'mpv';
|
|
41
|
+
args = ['--no-cache', '--no-terminal', '--', 'fd://0'];
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Unsupported platform: ${this.os}`);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
this.process = spawn(command, args, {
|
|
48
|
+
stdio: ['pipe', 'ignore', 'ignore']
|
|
49
|
+
});
|
|
50
|
+
this.process.on('error', (error) => {
|
|
51
|
+
logger.error(`Audio player error:`, error);
|
|
52
|
+
// Try alternative player on Linux
|
|
53
|
+
if (this.os === 'linux' && command === 'mpv') {
|
|
54
|
+
this.process = spawn('ffplay', ['-f', format, '-nodisp', '-autoexit', '-i', 'pipe:0'], {
|
|
55
|
+
stdio: ['pipe', 'ignore', 'ignore']
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.process.on('exit', (code) => {
|
|
60
|
+
this.isPlaying = false;
|
|
61
|
+
this.process = null;
|
|
62
|
+
});
|
|
63
|
+
// Pipe stream to player
|
|
64
|
+
this.stream.pipe(this.process.stdin);
|
|
65
|
+
this.isPlaying = true;
|
|
66
|
+
return this.stream;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new Error(`Failed to start audio player: ${error}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
write(chunk) {
|
|
73
|
+
if (this.stream && this.isPlaying) {
|
|
74
|
+
this.stream.write(chunk);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
stop() {
|
|
78
|
+
if (this.stream) {
|
|
79
|
+
this.stream.end();
|
|
80
|
+
this.stream = null;
|
|
81
|
+
}
|
|
82
|
+
if (this.process) {
|
|
83
|
+
this.process.kill();
|
|
84
|
+
this.process = null;
|
|
85
|
+
}
|
|
86
|
+
this.isPlaying = false;
|
|
87
|
+
}
|
|
88
|
+
isSupported() {
|
|
89
|
+
return ['darwin', 'win32', 'linux'].includes(this.os);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=realTimePlayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realTimePlayer.js","sourceRoot":"","sources":["../../src/utils/realTimePlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAY,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,mBAAmB;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,KAAK,CAAC,KAAa;QACjB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,WAAW;QACT,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReferenceConfig } from '../types/index.js';
|
|
2
|
+
export declare class ReferenceSelector {
|
|
3
|
+
private references;
|
|
4
|
+
private defaultReference?;
|
|
5
|
+
constructor(references: ReferenceConfig[], defaultReference?: string);
|
|
6
|
+
/**
|
|
7
|
+
* Find reference by ID
|
|
8
|
+
*/
|
|
9
|
+
findById(id: string): ReferenceConfig | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Find reference by name
|
|
12
|
+
*/
|
|
13
|
+
findByName(name: string): ReferenceConfig | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Find reference by tag
|
|
16
|
+
*/
|
|
17
|
+
findByTag(tag: string): ReferenceConfig | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Select reference based on parameters
|
|
20
|
+
*/
|
|
21
|
+
selectReference(params: {
|
|
22
|
+
id?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
tag?: string;
|
|
25
|
+
}): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get all available references
|
|
28
|
+
*/
|
|
29
|
+
getAllReferences(): ReferenceConfig[];
|
|
30
|
+
/**
|
|
31
|
+
* Get reference summary for logging
|
|
32
|
+
*/
|
|
33
|
+
getReferenceSummary(): string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=referenceSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceSelector.d.ts","sourceRoot":"","sources":["../../src/utils/referenceSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,gBAAgB,CAAC,CAAS;gBAEtB,UAAU,EAAE,eAAe,EAAE,EAAE,gBAAgB,CAAC,EAAE,MAAM;IAKpE;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIjD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAMrD;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAMnD;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE;QACtB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,MAAM,GAAG,SAAS;IAqBtB;;OAEG;IACH,gBAAgB,IAAI,eAAe,EAAE;IAIrC;;OAEG;IACH,mBAAmB,IAAI,MAAM;CAY9B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class ReferenceSelector {
|
|
2
|
+
references;
|
|
3
|
+
defaultReference;
|
|
4
|
+
constructor(references, defaultReference) {
|
|
5
|
+
this.references = references;
|
|
6
|
+
this.defaultReference = defaultReference;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Find reference by ID
|
|
10
|
+
*/
|
|
11
|
+
findById(id) {
|
|
12
|
+
return this.references.find(ref => ref.id === id);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Find reference by name
|
|
16
|
+
*/
|
|
17
|
+
findByName(name) {
|
|
18
|
+
return this.references.find(ref => ref.name?.toLowerCase() === name.toLowerCase());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Find reference by tag
|
|
22
|
+
*/
|
|
23
|
+
findByTag(tag) {
|
|
24
|
+
return this.references.find(ref => ref.tags?.some(t => t.toLowerCase() === tag.toLowerCase()));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Select reference based on parameters
|
|
28
|
+
*/
|
|
29
|
+
selectReference(params) {
|
|
30
|
+
// Priority: ID > Name > Tag > Default
|
|
31
|
+
if (params.id) {
|
|
32
|
+
const ref = this.findById(params.id);
|
|
33
|
+
if (ref)
|
|
34
|
+
return ref.id;
|
|
35
|
+
}
|
|
36
|
+
if (params.name) {
|
|
37
|
+
const ref = this.findByName(params.name);
|
|
38
|
+
if (ref)
|
|
39
|
+
return ref.id;
|
|
40
|
+
}
|
|
41
|
+
if (params.tag) {
|
|
42
|
+
const ref = this.findByTag(params.tag);
|
|
43
|
+
if (ref)
|
|
44
|
+
return ref.id;
|
|
45
|
+
}
|
|
46
|
+
// Return default if no match found
|
|
47
|
+
return this.defaultReference;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all available references
|
|
51
|
+
*/
|
|
52
|
+
getAllReferences() {
|
|
53
|
+
return this.references;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get reference summary for logging
|
|
57
|
+
*/
|
|
58
|
+
getReferenceSummary() {
|
|
59
|
+
if (this.references.length === 0) {
|
|
60
|
+
return 'No references configured';
|
|
61
|
+
}
|
|
62
|
+
return this.references.map(ref => {
|
|
63
|
+
const parts = [ref.id];
|
|
64
|
+
if (ref.name)
|
|
65
|
+
parts.push(`name: ${ref.name}`);
|
|
66
|
+
if (ref.tags && ref.tags.length > 0)
|
|
67
|
+
parts.push(`tags: ${ref.tags.join(', ')}`);
|
|
68
|
+
return `- ${parts.join(', ')}`;
|
|
69
|
+
}).join('\n');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=referenceSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceSelector.js","sourceRoot":"","sources":["../../src/utils/referenceSelector.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IACpB,UAAU,CAAoB;IAC9B,gBAAgB,CAAU;IAElC,YAAY,UAA6B,EAAE,gBAAyB;QAClE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAChC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAC/C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAChC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,CAC3D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe,C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,IAAI,CAAC,EAAE,CAAC,CAAC;YAChF,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhoujinandrew/fish-audio-mcp-server",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "MCP server for Fish Audio Text-to-Speech integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"fish-audio-mcp-server": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsx src/index.ts",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"lint": "eslint src --ext .ts",
|
|
16
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"model-context-protocol",
|
|
22
|
+
"fish-audio",
|
|
23
|
+
"tts",
|
|
24
|
+
"text-to-speech",
|
|
25
|
+
"ai",
|
|
26
|
+
"llm"
|
|
27
|
+
],
|
|
28
|
+
"author": "Daichi Okazaki",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@modelcontextprotocol/sdk": "^0.6.0",
|
|
32
|
+
"axios": "^1.6.2",
|
|
33
|
+
"dotenv": "^16.3.1",
|
|
34
|
+
"fish-audio-sdk": "^2025.6.8",
|
|
35
|
+
"msgpackr": "^1.11.4",
|
|
36
|
+
"ws": "^8.18.3",
|
|
37
|
+
"zod": "3.23.8"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^20.11.24",
|
|
41
|
+
"@types/ws": "^8.18.1",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
43
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
44
|
+
"eslint": "^8.57.0",
|
|
45
|
+
"jest": "^29.7.0",
|
|
46
|
+
"prettier": "^3.2.5",
|
|
47
|
+
"ts-jest": "^29.1.2",
|
|
48
|
+
"tsx": "^4.7.1",
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE"
|
|
55
|
+
],
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/zjandrew/mcp-fish-audio-server.git"
|
|
62
|
+
},
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/zjandrew/mcp-fish-audio-server/issues"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://github.com/zjandrew/mcp-fish-audio-server#readme",
|
|
67
|
+
"icon": "./dcos/icon_fish-audio.webp"
|
|
68
|
+
}
|