Music21

v1.0.0β€’APIsβ€’stable

🎡 Production-ready MCP server for music analysis & generation | FastMCP β€’ music21 β€’ OAuth2 β€’ Docker | First music21 MCP integration with enterprise features

ai-toolsdockerkubernetesmcp-servermusic-analysis
Share:
22
Stars
0
Downloads
0
Weekly
0/5

What is Music21?

Music21 is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 🎡 production-ready mcp server for music analysis & generation | fastmcp β€’ music21 β€’ oauth2 β€’ docker | first music21 mcp integration with enterprise features

🎡 Production-ready MCP server for music analysis & generation | FastMCP β€’ music21 β€’ OAuth2 β€’ Docker | First music21 MCP integration with enterprise features

This server falls under the APIs category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • 🎡 Production-ready MCP server for music analysis & generatio

Use Cases

Music analysis and generation
Score processing
Audio composition automation
LicenseMIT
Languagepython
Versionv1.0.0
UpdatedApr 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx music21

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Music21

The Music21 MCP Server is a production-ready Python server that brings the power of the music21 music analysis library to AI assistants via the Model Context Protocol. It exposes 13 analysis tools covering score import and export (MusicXML, MIDI, ABC, Lilypond, music21 corpus), key detection with multiple algorithms (Krumhansl, Aarden, Bellman-Budge), harmonic analysis with Roman numeral notation, voice leading checks, melodic and rhythmic pattern recognition, Bach chorale and jazz harmonization, species counterpoint generation, and style imitation. In addition to MCP, the server provides HTTP API, CLI, and Python library interfaces so analysis always has a working pathway even when MCP connectivity is unstable.

Prerequisites

  • Python 3.10 or higher
  • uv package manager (recommended) or pip for installation
  • music21 corpus configured locally (run `python -m music21.configure` after install)
  • An MCP client such as Claude Desktop or Claude Code
  • Optional: Docker for containerized deployment
1

Install the package

Install music21-mcp-server from PyPI using pip or uv. This provides the music21-mcp, music21-http, and music21-cli entry points.

pip install music21-mcp-server

# Or with uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install music21-mcp-server
2

Configure the music21 corpus

Run the music21 configuration step to set up the local corpus. This downloads the built-in score library including Bach chorales and other reference works used by the analysis tools.

python -m music21.configure
3

Configure Claude Desktop for MCP

Add the music21 analysis server to your Claude Desktop configuration. The server uses the music21_mcp.server_minimal module as its MCP entry point and requires PYTHONPATH to point to the src directory if installed from source.

{
  "mcpServers": {
    "music21-analysis": {
      "command": "python",
      "args": ["-m", "music21_mcp.server_minimal"]
    }
  }
}
4

Verify the MCP server starts

Start the MCP server directly to verify it initializes without errors before connecting it to a client.

music21-mcp
# Or via the unified launcher:
python -m music21_mcp.launcher mcp
5

Use the HTTP API as a fallback (optional)

If MCP connectivity is unreliable, start the FastAPI HTTP server on port 8000. This provides the same 13 analysis tools via REST endpoints with interactive docs at /docs.

music21-http
# Or:
python -m music21_mcp.launcher http

# Import a Bach chorale and analyze its key
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"}'
6

Use the CLI for automation (optional)

The music21-cli entry point provides access to all analysis tools from the command line without an MCP client.

# Import a Bach chorale from the corpus and analyze it
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 available tools
python -m music21_mcp.launcher cli tools

Music21 Examples

Client configuration

Claude Desktop configuration using the installed music21-mcp-server package. If installed from source, add an env block with PYTHONPATH pointing to the src directory.

{
  "mcpServers": {
    "music21-analysis": {
      "command": "python",
      "args": ["-m", "music21_mcp.server_minimal"]
    }
  }
}

Prompts to try

These prompts exercise the 13 music analysis tools available via MCP.

- "Import the Bach chorale bwv66.6 from the music21 corpus and identify its key"
- "Analyze the harmonic progression of the imported chorale using Roman numeral notation"
- "Generate a species counterpoint exercise in the style of Bach"
- "Harmonize this melody in a jazz style: C D E G A G E C"
- "Check for parallel fifths and voice crossing in the current score"
- "Detect melodic patterns in the chorale and list the top 5 recurring motifs"

Troubleshooting Music21

music21 corpus import fails with 'no corpus file found'

Run `python -m music21.configure` to download and configure the local corpus. If you are using a virtual environment, ensure music21 is installed in the same environment where the MCP server runs. The corpus files are stored in the music21 package directory.

MCP server starts but Claude Desktop shows no music21 tools

Verify the command in claude_desktop_config.json resolves to the correct Python interpreter that has music21-mcp-server installed. Run `python -c 'import music21_mcp'` to confirm the import works. If installed from source, add an env block: `"env": {"PYTHONPATH": "/path/to/music21-mcp-server/src"}`.

Key analysis or harmony analysis returns unexpected results

The server supports multiple key detection algorithms: Krumhansl, Aarden, and Bellman-Budge. If the default result seems wrong, ask Claude to try a different algorithm explicitly, e.g. 'analyze the key using the Bellman-Budge algorithm'. Tonal ambiguity in atonal or modulating pieces may cause variation between algorithms.

Frequently Asked Questions about Music21

What is Music21?

Music21 is a Model Context Protocol (MCP) server that 🎡 production-ready mcp server for music analysis & generation | fastmcp β€’ music21 β€’ oauth2 β€’ docker | first music21 mcp integration with enterprise features It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Music21?

Follow the installation instructions on the Music21 GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Music21?

Music21 works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Music21 free to use?

Yes, Music21 is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More APIs MCP Servers

Explore all apis servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

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

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide β†’

Ready to use Music21?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides