1.0.0 • Published 6 months ago
@passelin/mcp-server-speak v1.0.0
@passelin/mcp-server-speak
A Model Context Protocol (MCP) server that provides the ability to speak text using the system's text-to-speech engine.
Features
- Converts text to speech using the system's native text-to-speech capabilities (uses the
saypackage) - Supports customizable voices (when available on your system)
- Adjustable speech speed
- Ability to stop speech mid-playback
- Uses stdio transport
Installation
npm install @passelin/mcp-server-speakOr install globally:
npm install -g @passelin/mcp-server-speakUsage
Starting the Server
Start the MCP server:
npx @passelin/mcp-server-speakIf installed globally:
mcp-server-speakUsing as a Library
You can also use this package as a dependency in your own MCP-compatible project:
import { spawn } from "child_process";
// Spawn the MCP server process
const mcpServer = spawn("npx", ["@passelin/mcp-server-speak"], {
stdio: ["pipe", "pipe", "inherit"],
});
// Send a request to speak text
const request = {
jsonrpc: "2.0",
id: "123",
method: "tools/call",
params: {
name: "speak",
arguments: {
text: "Hello world! This is a test message spoken through the MCP server.",
},
},
};
mcpServer.stdin.write(JSON.stringify(request) + "\n");API
This MCP server provides the following tools:
1. speak
Speaks the provided text using the system's text-to-speech engine.
Parameters:
text(string, required): The text to speakvoice(string, optional): Optional voice to use for speech (depends on available system voices)speed(number, optional): Speed of speech (defaults to 1.0)
Example request:
{
"jsonrpc": "2.0",
"id": "123",
"method": "tools/call",
"params": {
"name": "speak",
"arguments": {
"text": "Hello! This is a test message.",
"voice": "Alex",
"speed": 1.2
}
}
}2. stop
Stops any ongoing speech.
Parameters: None
Example request:
{
"jsonrpc": "2.0",
"id": "456",
"method": "tools/call",
"params": {
"name": "stop",
"arguments": {}
}
}Quick Test
Test the server with a simple command:
npm run test:quickThis will send a test message to be spoken through the MCP server.
Running Tests
To run comprehensive tests:
npm testThis will:
- Build the project
- Start the MCP server
- Run several test cases for different features
- Generate a test report
Development
Prerequisites
- Node.js 18.0.0 or higher
- npm 7.0.0 or higher
Setting Up the Development Environment
# Clone the repository
git clone https://github.com/your-username/mcp-server-say.git
cd mcp-server-say
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run devScripts
npm run build: Compiles TypeScript to JavaScriptnpm run start: Starts the MCP servernpm run dev: Builds and starts the server in development modenpm run test: Runs comprehensive tests for all features
Dependencies
- @modelcontextprotocol/sdk: Model Context Protocol SDK
- say: A simple text-to-speech library for Node.js
- zod: TypeScript-first schema validation library
License
This project is licensed under the MIT License.
Author
Pierre Asselin pierre@asselin.info
1.0.0
6 months ago