NijiVoice-MCP is an implementation of the Model Context Protocol (MCP) for the NijiVoice API. It enables Large Language Models (LLMs) to access the NijiVoice API for easy text-to-speech generation, allowing seamless integration of voice synthesis capabilities.
# Clone the repository
git clone https://github.com/YOUR_USERNAME/nijivoice-mcp.git
cd nijivoice-mcp
# Install dependencies
pip install -e .
Create a .env
file in the project root with the following content:
NIJIVOICE_API_KEY=your_api_key_here
DEFAULT_VOICE_ACTOR_ID=default_voice_actor_id_optional
LOG_LEVEL=INFO
You can obtain your API key from the official NijiVoice website.
Start the MCP server with the following command:
python main.py
This will launch the MCP server and make it ready to accept requests from LLMs.
NijiVoice-MCP provides several tools that can be called by an LLM client:
# Get available voice actors
actors = await tools.call("actor/get_voice_actors")
# Generate voice and get URL to audio file
voice_result = await tools.call("voice/generate_voice", {
"script": "こんにちは、にじボイスのテストです。",
"voice_actor_id": "90031163-c497-44f3-a8a6-e45e4d0cb8f6",
"speed": 1.0,
"emotional_level": 0.5,
"sound_duration": 0.1,
"format": "mp3"
})
# Generate voice and get Base64 encoded audio data
encoded_voice = await tools.call("voice/generate_encoded_voice", {
"script": "Base64エンコードされた音声データです。",
"voice_actor_id": "90031163-c497-44f3-a8a6-e45e4d0cb8f6",
"speed": 1.0,
"emotional_level": 0.5,
"sound_duration": 0.1,
"format": "mp3"
})
# Check your credit balance
balance = await tools.call("credit/get_credit_balance")
NijiVoice-MCP supports special tags in your voice scripts:
<sp 1.0>text here</sp>
: Changes the speed of the text within the tags<wait 0.3>
: Inserts a pause of the specified duration (in seconds)Example:
script = "通常の速さで話します。<sp 0.8>ここはゆっくり話します。</sp><wait 0.5>少し間を置いて話します。"
If you encounter issues:
nijivoice_mcp.log
for error messages.env
filePlease be aware of the following limitations:
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.