Logo: Music21 MCP Server

Music21 MCP Server

Communautéit
brightlikethelight

đŸŽ” Production-ready MCP server for music analysis & generation | FastMCP ‱ music21 ‱ OAuth2 ‱ Docker | First music21 MCP integration with enterprise features

Editeurbrightlikethelight
Repositorymusic21-mcp-server
SproochPython
Forks
9
StÀren
26
Disponibel Tools
0
Transporttypstdio, streamable-http
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    Music21 MCP Server bitt MCP-Funktiounen un, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • Disponibel Tools: 0

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopĂ©ieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an deem MCP-Client ze konfiguréieren, deen Dir am léifste benotzt.

  • Interessi vun der CommunautĂ©it um Open-Source-Projet

    Zuele vum verlinkte Repository – StĂ€ren: 26, Forks: 9.

Music21 Analysis - Multi-Interface Music Server

CI/CD Pipeline CI Coverage Python 3.10+ License: MIT Ruff MCP

Professional music analysis with 4 different interfaces - MCP server, HTTP API, CLI tools, and Python library. Built on the powerful music21 library with protocol-independent architecture for maximum reliability.

🎯 Why Multiple Interfaces?

Based on 2025 research showing MCP has 40-50% production success rate, this project provides multiple pathways to the same powerful music21 analysis functionality:

  • 📡 MCP Server - For Claude Desktop integration (when it works)
  • 🌐 HTTP API - For web applications (reliable backup)
  • đŸ’» CLI Tools - For automation (always works)
  • 🐍 Python Library - For direct programming access

đŸŽ” Core Music Analysis Features

Analysis Tools (13 Available)

  • Import & Export: MusicXML, MIDI, ABC, Lilypond, music21 corpus
  • Key Analysis: Multiple algorithms (Krumhansl, Aarden, Bellman-Budge)
  • Harmony Analysis: Roman numerals, chord progressions, cadence detection
  • Voice Leading: Parallel motion detection, voice crossing analysis
  • Pattern Recognition: Melodic, rhythmic, and harmonic patterns

Advanced Capabilities

  • Harmonization: Bach chorale and jazz style harmonization
  • Counterpoint: Species counterpoint generation (1-5)
  • Style Imitation: Learn and generate music in composer styles
  • Score Manipulation: Transposition, time stretching, orchestration

🚀 Quick Start

Installation

Install from PyPI (Recommended)

bash
# Install the package
pip install music21-mcp-server

# Start the server
music21-mcp          # MCP server for Claude Desktop
music21-http         # REST API at localhost:8000
music21-cli          # Interactive CLI
music21-analysis mcp          # Unified launcher (positional arg)

Install from Source

bash
# Clone repository
git clone https://github.com/brightlikethelight/music21-mcp-server.git
cd music21-mcp-server

# Install with UV (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync

# Or with pip
pip install .

# Configure music21 corpus
python -m music21.configure

Usage - Pick Your Interface

🎯 Show All Available Interfaces

bash
python -m music21_mcp.launcher

📡 MCP Server (for Claude Desktop)

bash
# Start MCP server
python -m music21_mcp.launcher mcp

# Configure Claude Desktop with:
# ~/.config/claude-desktop/config.json
{
  "mcpServers": {
    "music21-analysis": {
      "command": "python",
      "args": ["-m", "music21_mcp.server_minimal"],
      "env": {
        "PYTHONPATH": "/path/to/music21-mcp-server/src"
      }
    }
  }
}

🌐 HTTP API Server (for web apps)

bash
# Start HTTP API server
python -m music21_mcp.launcher http
# Opens: http://localhost:8000
# API docs: http://localhost:8000/docs

# Example usage:
curl -X POST "http://localhost:8000/scores/import" \
  -H "Content-Type: application/json" \
  -d '{"score_id": "chorale", "source": "bach/bwv66.6", "source_type": "corpus"}'

curl -X POST "http://localhost:8000/analysis/key" \
  -H "Content-Type: application/json" \
  -d '{"score_id": "chorale"}'

đŸ’» CLI Tools (for automation)

bash
# Show CLI status
python -m music21_mcp.launcher cli status

# Import and analyze a Bach chorale
python -m music21_mcp.launcher cli import chorale bach/bwv66.6 corpus
python -m music21_mcp.launcher cli key-analysis chorale
python -m music21_mcp.launcher cli harmony chorale roman

# List all tools
python -m music21_mcp.launcher cli tools

🐍 Python Library (for programming)

python
from music21_mcp import create_sync_analyzer

# Create analyzer
analyzer = create_sync_analyzer()

# Import and analyze
analyzer.import_score("chorale", "bach/bwv66.6", "corpus")
key_result = analyzer.analyze_key("chorale")
harmony_result = analyzer.analyze_harmony("chorale", "roman")

print(f"Key: {key_result}")
print(f"Harmony: {harmony_result}")

# Quick comprehensive analysis
analysis = analyzer.quick_analysis("chorale")

đŸ§Ș Testing & Development

Run Tests

bash
# Run all tests
python -m pytest tests/ -v

# Run with coverage threshold
python -m pytest tests/ --cov=src/music21_mcp --cov-fail-under=82

Development Setup

bash
# Install development dependencies
uv sync --dev

# Set up pre-commit hooks
pre-commit install

# Run linting
ruff check src/
ruff format src/

# Type checking
mypy src/

đŸ—ïž Architecture

Protocol-Independent Design

Core Value Layer:
├── services.py              # Music21 analysis service (protocol-independent)
└── tools/                   # 13 music analysis tools

Protocol Adapter Layer:
├── adapters/mcp_adapter.py   # MCP protocol isolation
├── adapters/http_adapter.py  # HTTP/REST API
├── adapters/cli_adapter.py   # Command-line interface  
└── adapters/python_adapter.py # Direct Python access

Unified Entry Point:
└── launcher.py              # Single entry point for all interfaces

Design Philosophy

  • Core Value First: Music21 analysis isolated from protocol concerns
  • Protocol Apocalypse Survival: Works even when MCP fails (30-40% of time)
  • Multiple Escape Hatches: Always have a working interface
  • Reality-Based: Built for today's MCP ecosystem, not enterprise dreams

📊 Interface Reliability

InterfaceSuccess RateBest For
MCP40-50%AI assistant integration
HTTP95%+Web applications
CLI99%+Automation & scripting
Python99%+Direct programming

📚 Documentation

Discord Webhook Integration

🔧 Configuration

Environment Variables

bash
# Server host and port (used by HTTP adapter and launcher)
export MUSIC21_MCP_HOST=127.0.0.1
export MUSIC21_MCP_PORT=8000

# Operation timeouts (seconds)
export MUSIC21_MCP_TIMEOUT=30          # General async operation timeout
export MUSIC21_TOOL_TIMEOUT=30         # Per-tool execution timeout
export MUSIC21_CHORD_ANALYSIS_TIMEOUT=60  # Chord analysis timeout
export MUSIC21_BATCH_TIMEOUT=30        # Batch processing timeout

# CORS origins for HTTP adapter (comma-separated)
export MUSIC21_CORS_ORIGINS="http://localhost:*"

Music21 Setup

bash
# Configure corpus path (one-time setup)
python -m music21.configure

đŸ› ïž Available Analysis Tools

  1. import_score - Import from corpus, files, URLs
  2. list_scores - List all imported scores
  3. get_score_info - Detailed score information
  4. export_score - Export to MIDI, MusicXML, etc.
  5. delete_score - Remove scores from storage
  6. analyze_key - Key signature analysis
  7. analyze_chords - Chord progression analysis
  8. analyze_harmony - Roman numeral/functional harmony
  9. analyze_voice_leading - Voice leading quality analysis
  10. recognize_patterns - Melodic/rhythmic patterns
  11. harmonize_melody - Automatic harmonization
  12. generate_counterpoint - Counterpoint generation
  13. imitate_style - Style imitation and generation

🚀 Quick Examples

Analyze a Bach Chorale

bash
# CLI approach
python -m music21_mcp.launcher cli import chorale bach/bwv66.6 corpus
python -m music21_mcp.launcher cli key-analysis chorale

# Python approach  
analyzer = create_sync_analyzer()
analyzer.import_score("chorale", "bach/bwv66.6", "corpus")
print(analyzer.analyze_key("chorale"))

Start Services

bash
# For Claude Desktop
python -m music21_mcp.launcher mcp

# For web development
python -m music21_mcp.launcher http

# For command-line work
python -m music21_mcp.launcher cli status

🔄 Migration from v1.0

The previous enterprise version has been simplified for reliability:

  • ✅ Kept: All music21 analysis functionality
  • ✅ Added: HTTP API, CLI, Python library interfaces
  • ❌ Removed: Docker, K8s, complex auth, monitoring (too unstable for MCP ecosystem)
  • 🔄 Changed: Focus on core value delivery through multiple interfaces

🔔 Discord Webhook Integration

Get real-time notifications for CI/CD pipeline status, pull requests, and releases:

đŸ€ Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Development setup and requirements
  • Code style guidelines (Ruff, MyPy)
  • Testing requirements (maintain >82% coverage)
  • Pull request process
  • Branch protection rules

Quick start:

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Run tests: pytest tests/ --cov=src/music21_mcp --cov-fail-under=82
  4. Commit changes: git commit -m 'feat: Add amazing feature'
  5. Push branch: git push origin feature/amazing-feature
  6. Submit pull request

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

  • Built on the excellent music21 library
  • Uses FastMCP for MCP protocol support
  • Inspired by the need for reliable music analysis tools

Choose the interface that works for you. All provide the same powerful music21 analysis capabilities! đŸŽ”

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "brightlikethelight-music21-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "music21-mcp-server"
      ]
    }
  }
}

Music21 MCP Server MCP mat verschiddene KI-Modeller benotzen

TypingMind verbĂ«nnt MCP-Tools um Niveau vum AarbechtsberĂ€ich. Soubal Music21 MCP Server verbonnen ass, kĂ«nnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dir kĂ«nnt MCP lokal op Ärem Apparat ausfĂ©ieren oder Iech iwwer d'URL mat engem externen MCP-Server verbannen.

Optioun 1: De lokale Connector benotzen

Benotzt dĂ«s Optioun, wann den MCP-Server ZougrĂ«ff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „DĂ«sen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector: D'Optioun „DĂ«sen Apparat“ ass ausgewielt
2

De Connector-Befeel ausféieren

Wielt „DĂ«sen Apparat“, kopĂ©iert de Befeel aus TypingMind a fĂ©iert en am Terminal aus. Loosst de Prozess lafen, wĂ€rend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Setzt de kopéierte Befeel an a féiert en aus.
  4. BestÀtegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wÀrend Dir MCP-Tools benotzt.
3

Music21 MCP Server als Server derbÀisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren Ă€nneren“ a setzt d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren Ă€nneren“.
  3. Setzt d'MCP-Serverkonfiguratioun fir Music21 MCP Server an.
  4. SpÀichert d'Serverlëscht.
  5. Aktualiséiert d'SÀit, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem KnĂ€ppchen „Serveren Ă€nneren“
{
  "mcpServers": {
    "brightlikethelight-music21-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "music21-mcp-server"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

SpĂ€ichert d'ServerlĂ«scht, maacht „Plugins“ op an aktivĂ©iert d'MCP-Tools vun der Integratioun Music21 MCP Server. Wielt dann e belibegen Ă«nnerstĂ«tzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'SĂ€it „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vun der Integratioun Music21 MCP Server.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat Music21 MCP Server bei dëser Aufgab hëllefen?
Music21 MCP Server
Jo. Ech hunn et gelies.
Dat hunn ech mat Music21 MCP Server fonnt.

Optioun 2: Eng MCP-Server-URL derbÀisetzen

Benotzt dĂ«s Optioun, wann Music21 MCP Server schonn op engem externe Server gehost gĂ«tt oder Är Ekipp ee gemeinsame Connector wĂ«llt, op dee mĂ©i Benotzer kĂ«nne zougrĂ€ifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbĂ€isetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbĂ€isetzen“.
TypingMind-Formulaire, fir eng benotzerdefinéiert MCP-Server-URL derbÀizesetzen
2

Déi kopéiert Server-URL asetzen

Gitt Är Server-URL am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinĂ©iert HTTP-Headeren oder OAuth-Clientastellungen derbĂ€i, wann de Server se erfuerdert.

  1. Setzt Är Server-URL an d'Feld „Server-URL“ an.
  2. Gitt en Numm fir d'Verbindung mat Music21 MCP Server an.
  3. Wann Dir d'Verbindung méi einfach erëmerkenne wëllt, setzt eng Beschreiwung an e Symbol derbÀi.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbÀi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zerĂ©ck op d'Plugin-LĂ«scht a kontrollĂ©iert, ob dĂ©i nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat Music21 MCP Server als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen, ouni MCP nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivĂ©iert d'Tools vun der Integratioun Music21 MCP Server Ă«nner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-AarbechtsberĂ€ich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. AktivĂ©iert d'Tools vun der Integratioun Music21 MCP Server Ă«nner „Plugins“.
  4. Biet de Modell, d'Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat Music21 MCP Server bei dëser Aufgab hëllefen?
Music21 MCP Server
Jo. Ech hunn et gelies.
Dat hunn ech mat Music21 MCP Server fonnt.

Heefeg gestallte Froen

Fir wat gëtt den MCP-Server Music21 MCP Server benotzt?

Music21 MCP Server ass en MCP-Server, deen et kompatibele KI-Clienten erlaabt, op extern Tools a Kontextinformatioune zouzegrĂ€ifen. An TypingMind kĂ«nnt Dir dĂ«sen MCP-Server eemol derbĂ€isetzen a seng Tools an Ärem KI-AarbechtsberĂ€ich zur VerfĂŒgung stellen.

Kann ech Music21 MCP Server MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum AarbechtsberÀich. Sou kënnt Dir Music21 MCP Server mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni den MCP-Server fir all Modell separat anzeriichten.

Firwat Music21 MCP Server MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte BenotzeruewerflĂ€che fir LLM-Chat, well et mĂ©i KI-Modeller, Prompts, Plugins, KI-Agenten, API-SchlĂ«sselen a MCP-Tools an engem AarbechtsberĂ€ich zesummebrĂ©ngt. Wann Music21 MCP Server verbonnen ass, kĂ«nnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a glĂ€ichzĂ€iteg Ären Aarbechtsoflaf beim Chatten an TypingMind organisĂ©ieren.

Wéi verbannen ech Music21 MCP Server MCP mat TypingMind?

Dir kĂ«nnt Music21 MCP Server iwwer de lokale MCP-Connector oder iwwer d'URL vun engem Remote-MCP-Server mat TypingMind verbannen. Benotzt de lokale Connector, wann de Server ZougrĂ«ff op Fichieren, Apps oder privat Ressourcen op Ärem Apparat brauch, an eng Server-URL, wann den MCP-Server op Distanz gehost gĂ«tt.

WĂ©i eng Tools stellt Music21 MCP Server MCP an TypingMind zur VerfĂŒgung?

Music21 MCP Server stellt MCP-Funktioune zur VerfĂŒgung, dĂ©i Dir op der Plugins-SĂ€it vun TypingMind aktivĂ©iere kĂ«nnt, fir se am Chat ze benotzen oder KI-Agente zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Music21 MCP Server MCP ze benotzen?

Nee. TypingMind ass nom Local-first-Prinzip opgebaut a lĂ©isst Iech d'Kontroll iwwer Är Modellubidder, API-SchlĂ«sselen, Prompts a MCP-Konfiguratioun. Wann Music21 MCP Server eng AuthentifizĂ©ierung verlaangt, setzt dĂ©i nĂ©ideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir deen MCP-Server derbĂ€i, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

Alleguer weisen

Elo Ären eegene KI-AarbechtsberĂ€ich ariichten

AbonnĂ©iert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukĂŒnfteg GewĂ«nnspiller informĂ©iert ze ginn 👇