Hooktheory MCP Server
Enables AI agents to interact with the Hooktheory API for chord progression generation, song analysis, and music theory data retrieval.
README
Hooktheory MCP Server
A Model Context Protocol (MCP) server that enables AI agents to interact with the Hooktheory API for chord progression generation, song analysis, and music theory data retrieval.
Quick Start
Get up and running in 3 simple steps:
-
Set up authentication using your Hooktheory account credentials:
export HOOKTHEORY_USERNAME="your-username" export HOOKTHEORY_PASSWORD="your-password" -
Install and run:
uvx hooktheory-mcp -
Try these examples with your AI assistant:
- "Find songs with the chord progression I-V-vi-IV"
- "Analyze the song 'Wonderwall' by Oasis"
- "Show me popular chord progressions in C major"
- "Find songs similar to 'Let It Be' by The Beatles"
That's it! Your AI can now access music theory data and chord progressions.
Common Usage Examples
Search for Songs by Chord Progression
Find songs using the progression 1,5,6,4 in the key of C major
Analyze Any Song
What are the chords in "Someone Like You" by Adele?
Discover Popular Progressions
What are the most common chord progressions in pop music?
Find Similar Songs
Find songs that have similar chord progressions to "Hotel California"
Features
The server provides the following tools for music analysis and generation:
- Chord Progression Search: Find songs with specific chord progressions
- Song Analysis: Analyze specific songs to get chord progressions and key information
- Popular Progressions: Discover the most popular chord progressions
- Similar Songs: Find songs with similar chord progressions
- Progression Generation: Generate chord progressions based on music theory patterns
Installation
Prerequisites
- Python 3.11 or higher
- A Hooktheory account (Sign up at https://www.hooktheory.com)
Setup
-
Install with uvx (recommended):
uvx hooktheory-mcp -
Or install from source:
git clone <repository-url> cd hooktheory-mcp uv sync -
Set up authentication:
export HOOKTHEORY_USERNAME="your-username" export HOOKTHEORY_PASSWORD="your-password"Or create a
.envfile:HOOKTHEORY_USERNAME=your-username HOOKTHEORY_PASSWORD=your-password -
Test the installation:
uvx hooktheory-mcp --help # Or if installed from source: uv run hooktheory-mcp --help
Usage
Command Line
The server can be run in different modes:
Standard MCP mode (stdio transport):
uvx hooktheory-mcp
# Or from source: uv run hooktheory-mcp
Streamable HTTP mode for web integration:
uvx hooktheory-mcp --transport streamable-http
# Or from source: uv run hooktheory-mcp --transport streamable-http
Server-Sent Events (SSE) mode:
uvx hooktheory-mcp --transport sse
# Or from source: uv run hooktheory-mcp --transport sse
MCP Client Configuration
For Claude Desktop, add this to your configuration:
{
"mcpServers": {
"hooktheory": {
"command": "uvx",
"args": ["hooktheory-mcp"],
"env": {
"HOOKTHEORY_USERNAME": "your-username",
"HOOKTHEORY_PASSWORD": "your-password"
}
}
}
}
Alternative for development/local install:
{
"mcpServers": {
"hooktheory": {
"command": "uv",
"args": ["run", "hooktheory-mcp"],
"cwd": "/path/to/hooktheory-mcp",
"env": {
"HOOKTHEORY_USERNAME": "your-username",
"HOOKTHEORY_PASSWORD": "your-password"
}
}
}
}
Available Tools
1. get_chord_progressions
Search for songs with specific chord progressions.
Parameters:
cp(required): Chord progression in Roman numeral notation (e.g., "1,5,6,4")key(optional): Musical key (e.g., "C", "Am")mode(optional): Scale mode ("major", "minor")artist(optional): Filter by artist namesong(optional): Filter by song title
Example:
Find songs with the progression I-V-vi-IV in the key of C major
2. analyze_song
Analyze a specific song to get its chord progression and music theory data.
Parameters:
artist(required): Artist namesong(required): Song title
Example:
Analyze "Wonderwall" by Oasis
3. get_popular_progressions
Get the most popular chord progressions from the database.
Parameters:
key(optional): Filter by musical keymode(optional): Filter by scale modelimit(optional): Max results (default: 20)
Example:
Show me the most popular chord progressions in C major
4. find_similar_songs
Find songs with similar chord progressions to a reference song.
Parameters:
artist(required): Reference artist namesong(required): Reference song titlesimilarity_threshold(optional): Similarity score 0.0-1.0 (default: 0.7)
Example:
Find songs similar to "Let It Be" by The Beatles
5. generate_progression
Generate chord progressions based on music theory patterns.
Parameters:
key(optional): Starting key (default: "C")mode(optional): Scale mode (default: "major")length(optional): Number of chords (default: 4)style(optional): Musical style hint ("pop", "rock", "jazz")
Example:
Generate a 4-chord pop progression in A minor
API Integration
The server integrates with the Hooktheory API using OAuth 2.0 authentication:
- Base URL:
https://www.hooktheory.com/api - Authentication: OAuth 2.0 with username/password → Bearer token
- Rate Limiting: 1.5 requests/second with exponential backoff
- Token Management: Automatic token caching and refresh (24-hour expiry)
- Error Recovery: Automatic retry with backoff on rate limits and auth failures
Authentication Flow
- Server exchanges username/password for Bearer token via
POST /users/auth - Token is cached and automatically refreshed when expired
- All API requests use Bearer token authentication
- Rate limiting prevents exceeding API limits with intelligent backoff
Development
Project Structure
hooktheory-mcp/
├── src/hooktheory_mcp/
│ └── __init__.py # Main MCP server implementation
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
└── README.md # This file
Adding New Tools
To add new tools, edit src/hooktheory_mcp/__init__.py and add new functions decorated with @mcp.tool():
@mcp.tool()
async def your_new_tool(param1: str, param2: Optional[int] = None) -> str:
"""
Description of your tool.
Args:
param1: Description of parameter
param2: Optional parameter description
Returns:
Description of return value
"""
# Implementation here
return result
Testing
# Run basic connectivity test
uv run python -c "
import asyncio
from hooktheory_mcp import hooktheory_client
asyncio.run(hooktheory_client._make_request('test'))
"
Troubleshooting
Common Issues
-
Authentication Credentials Not Set
Error: HOOKTHEORY_USERNAME and HOOKTHEORY_PASSWORD environment variables are requiredSolution: Set both
HOOKTHEORY_USERNAMEandHOOKTHEORY_PASSWORDenvironment variables -
HTTP 401 Unauthorized
HTTP error calling https://www.hooktheory.com/api/trends/...: 401Solution: Verify your username and password are correct. The server will automatically retry authentication.
-
Rate Limited (HTTP 429)
Rate limited. Waiting X seconds before retrySolution: This is normal - the server automatically handles rate limiting with exponential backoff
-
Connection Errors
HTTP error calling https://www.hooktheory.com/api/trends/...: ConnectErrorSolution: Check internet connection and Hooktheory API status
Debug Mode
Enable debug logging:
export PYTHONPATH=src
python -c "
import logging
logging.basicConfig(level=logging.DEBUG)
from hooktheory_mcp import main
main()
"
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。