Music21
π΅ Production-ready MCP server for music analysis & generation | FastMCP β’ music21 β’ OAuth2 β’ Docker | First music21 MCP integration with enterprise features
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
Maintainer
Works with
Installation
Manual Installation
npx music21Configuration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
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-serverConfigure 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.configureConfigure 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"]
}
}
}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 mcpUse 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"}'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 toolsMusic21 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.
Music21 Alternatives β Similar APIs Servers
Looking for alternatives to Music21? Here are other popular apis servers you can use with Claude, Cursor, and VS Code.
Kong
β 43.4kπ¦ The API and AI Gateway
API Mega List
β 5.4kThis GitHub repo is a powerhouse collection of APIs you can start using immediately to build everything from simple automations to full-scale applications. One of the most valuable API lists on GitHubβperiod. πͺ
Fetch
β 5.4kFetch web content and convert to markdown for AI consumption
Fusio
β 2.1kSelf-Hosted API Management for Builders
Korean Law
β 1.8kκ΅κ°λ²λ Ήμ 보MCP v4.0 | λ²μ μ² 41κ° API β 17κ° MCP λꡬ. λ²λ ΉΒ·νλ‘Β·μ‘°λ‘ κ²μ + LLM νκ° λ°©μ§ μΈμ©κ²μ¦ + μ‘°λ¬Έ μν₯ κ·Έλν(impact_map) + μμ λΉκ΅ μλ diff(time_travel) + μλ―Ό 5λ¨κ³ μ€ν κ°μ΄λ(action_plan) | 41 Korean legal APIs β 17 MCP tools
RuleGo
β 1.5kβοΈRuleGo is a lightweight, high-performance, embedded, next-generation component orchestration rule engine framework for Go.
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.
Set Up Music21 in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.