NijiVoice MCP server

Enables high-quality text-to-speech generation with customizable voice characteristics through the NijiVoice API for content creation, accessibility features, and interactive voice experiences.
Back to servers
Provider
ryoooo
Release date
Apr 14, 2025
Language
Python
Stats
1 star

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.

Prerequisites

  • Python 3.12 or higher
  • NijiVoice API key
  • Internet connection

Installation

# Clone the repository
git clone https://github.com/YOUR_USERNAME/nijivoice-mcp.git
cd nijivoice-mcp

# Install dependencies
pip install -e .

Configuration

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.

Running the Server

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.

Using NijiVoice-MCP

Available MCP Tools

NijiVoice-MCP provides several tools that can be called by an LLM client:

Voice Actor Tools

# Get available voice actors
actors = await tools.call("actor/get_voice_actors")

Voice Generation Tools

# 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"
})

Credit Management

# Check your credit balance
balance = await tools.call("credit/get_credit_balance")

Special Tags in Scripts

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>少し間を置いて話します。"

Troubleshooting

If you encounter issues:

  1. Check the log file nijivoice_mcp.log for error messages
  2. Verify your API key is correctly set in the .env file
  3. Ensure you have a stable internet connection
  4. Check the status of the NijiVoice API service

Limitations

Please be aware of the following limitations:

  • The server may time out when generating long audio content
  • The emotional_level parameter ranges from 0.0 to 1.0
  • The speed parameter typically ranges from 0.5 to 2.0
  • Some voice actors may have specific limitations or characteristics

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later