Music Lyric Cutter MCP Server
README.md
<div align="center">
# π΅ Music Lyric Cutter MCP Server
[](https://www.python.org/)
[](https://github.com/jlowin/fastmcp)
[](https://opensource.org/licenses/MIT)
[](https://github.com/david-evaristo/music-lyric-cutter-mcp/releases)
[](https://github.com/astral-sh/ruff)
**An MCP server for song transcription and per-line MP3 audio segmentation over `stdio` transport.**
[Overview](#-overview) β’ [Features](#-key-features) β’ [Architecture](#-architecture) β’ [Quickstart](#-quickstart) β’ [Tools & Resources](#-tools-resources--prompts) β’ [Configuration](#-configuration) β’ [Development](#-development)
</div>
---
## β‘ Overview
The **Music Lyric Cutter MCP Server** connects AI assistants and MCP clients (such as **Claude Desktop**, **Claude Code**, and **Cursor**) to an automated audio transcription and segmentation pipeline using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/).
Given a song title and artistβeither from a local audio file or an authorized YouTube downloadβit transcribes lyrics into `.srt` subtitles using `faster-whisper`, merges short intervals, and cuts individual MP3 segments per lyric line with `ffmpeg`.
---
## β¨ Key Features
- π§ **Flexible Audio Resolution**: Process a local `audio_path` directly or search YouTube via `yt-dlp` and download the best matching audio when `allow_download=True`.
- π **Accurate Lyric Transcription**: Transcribes audio to `.srt` subtitles using `faster-whisper` with configurable model, device, compute type, and optional ISO `language` hint.
- βοΈ **Per-Line MP3 Segmentation**: Merges short intervals (`MIN_SEGMENT_DURATION_SECONDS`) and cuts clean per-line `.mp3` clips using `ffmpeg`.
- π **Predictable Artifact Layout**: Organizes outputs automatically under `<output_root>/<artist-slug>/<song-slug>/` and returns structured `SongSegmentationResult` metadata.
- π **Navigable MCP Resources & Prompts**: Exposes server config, processed artists/tracks as JSON resources, and a `segment_song` prompt template.
---
## π Architecture
```mermaid
flowchart LR
subgraph Clients ["MCP Clients"]
CD["Claude Desktop"]
CC["Claude Code"]
CR["Cursor / IDEs"]
end
subgraph Server ["Music Lyric Cutter MCP"]
Transport["FastMCP (stdio)"]
Pipeline["Services (pipeline.py / srt.py)"]
Adapters["Adapters (yt-dlp / faster-whisper / ffmpeg)"]
Transport --> Pipeline --> Adapters
end
subgraph Output ["Output Root"]
FS["<artist-slug>/<song-slug>/\n(full-audio, subtitles, segments)"]
end
Clients <-->|MCP Protocol| Transport
Adapters --> FS
```
### Module Layout
- `server.py`: `FastMCP` server factory (`create_server`), entrypoint (`main`), and `stderr` logging configuration.
- `config.py`: `pydantic-settings` configuration (`MUSIC_LYRIC_CUTTER_MCP_` prefix).
- `mcp/`: MCP protocol layer (`schemas.py`, `tools.py`, `resources.py`, `prompts.py`).
- `services/`: Domain orchestration (`pipeline.py`, `srt.py`).
- `adapters/`: External media and processing integrations (`youtube.py`, `transcription.py`, `ffmpeg.py`).
- `utils/`: Shared generic utilities (`text.py`).
---
## π Quickstart
### Prerequisites
- [uv / uvx](https://docs.astral.sh/uv/) installed on your machine (`curl -LsSf https://astral.sh/uv/install.sh | sh`)
- `ffmpeg` available in your `PATH`
- Network access when searching/downloading from YouTube or downloading the `faster-whisper` model on first run
---
### Configuration by Client
<details open>
<summary><b>Claude Desktop</b></summary>
Edit your `claude_desktop_config.json`:
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
```json
{
"mcpServers": {
"music-lyric-cutter": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/david-evaristo/music-lyric-cutter-mcp.git@v0.1.1",
"music-lyric-cutter-mcp"
],
"env": {
"MUSIC_LYRIC_CUTTER_MCP_OUTPUT_ROOT": "~/music-lyric-cutter-output"
}
}
}
}
```
> [!TIP]
> On the first transcription, `faster-whisper` downloads the configured model (`tiny` by default) if it is not cached locally.
</details>
<details>
<summary><b>Claude Code (CLI)</b></summary>
Register the server using `claude mcp add`:
```bash
claude mcp add music-lyric-cutter -s user \
--env MUSIC_LYRIC_CUTTER_MCP_OUTPUT_ROOT=~/music-lyric-cutter-output \
-- uvx --from git+https://github.com/david-evaristo/music-lyric-cutter-mcp.git@v0.1.1 music-lyric-cutter-mcp
```
</details>
<details>
<summary><b>Cursor & Other MCP Clients</b></summary>
In Cursor Settings > Features > MCP Servers:
- **Name**: `music-lyric-cutter`
- **Type**: `command`
- **Command**: `uvx --from git+https://github.com/david-evaristo/music-lyric-cutter-mcp.git@v0.1.1 music-lyric-cutter-mcp`
- Configure `MUSIC_LYRIC_CUTTER_MCP_*` environment variables via your `.env` or client settings.
</details>
---
## π οΈ Tools, Resources & Prompts
### MCP Tools
| Tool | Parameters | Description |
|---|---|---|
| `music_lyric_cutter` | `title: str, artist: str, audio_path?: str, allow_download?: bool, language?: str` | Resolves local or authorized YouTube audio, transcribes to SRT, and cuts per-line MP3 segments. |
### MCP Resources
- `config://server` β Returns server name, version, and configured `output_root`.
- `music://artists` β Lists processed artist slugs available under `output_root`.
- `music://{artist}/tracks` β Lists processed song slugs for a given artist under `output_root`.
### MCP Prompts
- `segment_song` β Generates a structured prompt to transcribe and segment a song per line with `music_lyric_cutter`.
### Output Layout
Artifacts are written under `<output_root>/<artist-slug>/<song-slug>/` (directories are created automatically if missing):
```text
<output_root>/
βββ <artist-slug>/
βββ <song-slug>/
βββ full-audio/ # Downloaded source audio (when downloaded)
βββ subtitles/ # Generated .srt subtitle file
βββ segments/ # Per-line MP3 files (segment_000.mp3, ...)
```
---
## βοΈ Configuration
Environment variables use the `MUSIC_LYRIC_CUTTER_MCP_` prefix (loaded from `.env` if present):
| Category | Variable | Default | Description |
|---|---|---|---|
| **Server** | `MUSIC_LYRIC_CUTTER_MCP_SERVER_NAME` | `Music Lyric Cutter MCP` | MCP server display name |
| | `MUSIC_LYRIC_CUTTER_MCP_LOG_LEVEL` | `INFO` | Logging level (written to `stderr`) |
| **Pipeline & Output** | `MUSIC_LYRIC_CUTTER_MCP_OUTPUT_ROOT` | `~/music-lyric-cutter-output` | Root directory for generated artifacts |
| | `MUSIC_LYRIC_CUTTER_MCP_SEGMENTATION_TIMEOUT_SECONDS` | `900.0` | MCP tool execution timeout in seconds |
| | `MUSIC_LYRIC_CUTTER_MCP_MIN_SEGMENT_DURATION_SECONDS` | `1.0` | Minimum segment duration before merging |
| **Whisper** | `MUSIC_LYRIC_CUTTER_MCP_WHISPER_MODEL` | `tiny` | `faster-whisper` model identifier |
| | `MUSIC_LYRIC_CUTTER_MCP_WHISPER_DEVICE` | `cpu` | Compute device for `faster-whisper` |
| | `MUSIC_LYRIC_CUTTER_MCP_WHISPER_COMPUTE_TYPE` | `int8` | Compute/quantization type for `faster-whisper` |
---
## π» Development
### Local Setup
```bash
git clone https://github.com/david-evaristo/music-lyric-cutter-mcp.git
cd music-lyric-cutter-mcp
uv sync
cp .env.example .env
```
### Running Tests & Quality Checks
```bash
# Lint & format checks
uv run ruff check .
uv run ruff format --check .
# Run unit tests with coverage (no network required)
uv run pytest -q --cov=music_lyric_cutter_mcp
# Verify lockfile & run server locally
uv lock --locked
uv run fastmcp run src/music_lyric_cutter_mcp/server.py
uv run music-lyric-cutter-mcp
```
### Releasing
Releases follow [Semantic Versioning](https://semver.org/):
```bash
git tag v0.1.1
git push origin v0.1.1
```
---
## π License
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues