README.md
markdown
| 1 | # MuseHub |
| 2 | |
| 3 |  |
| 4 |  |
| 5 |  |
| 6 | |
| 7 | **MuseHub** — the music composition version control platform powered by Muse VCS. |
| 8 | |
| 9 | GitHub for music. Push commits, open pull requests, track issues, browse public repos, publish releases, and give AI agents complete programmatic access via a best-in-class MCP integration. |
| 10 | |
| 11 | > **Requirements:** Python 3.14+ · PostgreSQL 16+ · Node.js 22+ |
| 12 | |
| 13 | ## URL scheme |
| 14 | |
| 15 | ``` |
| 16 | /{owner}/{slug} → repo home page |
| 17 | musehub://{owner}/{slug} → MCP resource URI (see MCP docs) |
| 18 | ``` |
| 19 | |
| 20 | ## Architecture |
| 21 | |
| 22 | ``` |
| 23 | musehub/ |
| 24 | api/routes/musehub/ 44 route handlers (thin HTTP) |
| 25 | api/routes/mcp.py POST /mcp — HTTP Streamable MCP endpoint |
| 26 | services/ 26 musehub_*.py business logic modules |
| 27 | db/ SQLAlchemy ORM models (Postgres) |
| 28 | models/ Pydantic request/response models |
| 29 | mcp/ |
| 30 | dispatcher.py Async JSON-RPC 2.0 engine (no SDK dependency) |
| 31 | tools/ 27-tool catalogue (15 read + 12 write) |
| 32 | resources.py 20 musehub:// resources (5 static + 15 templated) |
| 33 | prompts.py 6 workflow prompts |
| 34 | write_tools/ Write executor modules (repos, issues, PRs, releases, social) |
| 35 | stdio_server.py stdio transport for local dev / Cursor IDE |
| 36 | templates/musehub/ Jinja2 + HTMX + Alpine.js web UI |
| 37 | auth/ JWT auth dependencies |
| 38 | config.py Pydantic Settings (env vars) |
| 39 | |
| 40 | tools/ |
| 41 | typing_audit.py Static typing violation scanner (ratchet-safe) |
| 42 | ``` |
| 43 | |
| 44 | ## Running locally |
| 45 | |
| 46 | ```bash |
| 47 | # Start with Docker Compose (Postgres + app) |
| 48 | docker compose up -d |
| 49 | |
| 50 | # Run Alembic migrations |
| 51 | docker compose exec musehub alembic upgrade head |
| 52 | |
| 53 | # Seed development data |
| 54 | docker compose exec musehub python3 scripts/seed_musehub.py |
| 55 | ``` |
| 56 | |
| 57 | ## API |
| 58 | |
| 59 | Interactive docs available at `/docs` when `DEBUG=true`. |
| 60 | |
| 61 | OpenAPI spec always available at `/api/v1/openapi.json`. |
| 62 | |
| 63 | ## Auth |
| 64 | |
| 65 | Write endpoints and private-repo reads require: |
| 66 | |
| 67 | ``` |
| 68 | Authorization: Bearer <jwt> |
| 69 | ``` |
| 70 | |
| 71 | Public repo reads and all MCP read tools are unauthenticated. MCP write tools require the same JWT in the `Authorization` header. |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ## MCP Integration |
| 76 | |
| 77 | MuseHub implements the full [MCP 2025-11-25 specification](https://modelcontextprotocol.io/specification/2025-11-25) — no external MCP SDK, pure Python async. Agents get complete capability parity with the web UI. |
| 78 | |
| 79 | ### Transports |
| 80 | |
| 81 | | Transport | Endpoint | Use case | |
| 82 | |-----------|----------|----------| |
| 83 | | HTTP Streamable | `POST /mcp` | Production; any MCP client | |
| 84 | | stdio | `python -m musehub.mcp.stdio_server` | Local dev, Cursor IDE | |
| 85 | |
| 86 | **Cursor IDE integration** — add to `.cursor/mcp.json`: |
| 87 | |
| 88 | ```json |
| 89 | { |
| 90 | "mcpServers": { |
| 91 | "musehub": { |
| 92 | "command": "python", |
| 93 | "args": ["-m", "musehub.mcp.stdio_server"], |
| 94 | "cwd": "/path/to/musehub" |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | ``` |
| 99 | |
| 100 | ### Tools — 32 total |
| 101 | |
| 102 | **Read tools (15):** browse repos, list branches, list/get commits, compare refs, read files, get musical analysis, search in-repo, list/get issues, list/get PRs, list releases, search public repos, get full AI context. |
| 103 | |
| 104 | **Write tools (12):** create/fork repos, create/update issues, comment on issues, create/merge PRs, inline PR comments, submit PR reviews, create releases, star repos, create labels. |
| 105 | |
| 106 | **Elicitation-powered tools (5, MCP 2025-11-25):** interactive composition planner, interactive PR review, streaming platform OAuth connect, cloud DAW OAuth connect, interactive release creator. |
| 107 | |
| 108 | > Write and elicitation tools require `Authorization: Bearer <jwt>`. Elicitation tools also require an active session (`Mcp-Session-Id`). They degrade gracefully for stateless clients. |
| 109 | |
| 110 | ### Transports — Full Streamable HTTP (2025-11-25) |
| 111 | |
| 112 | | Verb | Endpoint | Purpose | |
| 113 | |------|----------|---------| |
| 114 | | `POST` | `/mcp` | All client→server requests; SSE stream for elicitation-powered tools | |
| 115 | | `GET` | `/mcp` | Persistent SSE push channel for server→client notifications | |
| 116 | | `DELETE` | `/mcp` | Client-initiated session termination | |
| 117 | | stdio | `python -m musehub.mcp.stdio_server` | Local dev, Cursor IDE | |
| 118 | |
| 119 | **Session lifecycle:** `POST initialize` → receive `Mcp-Session-Id` → include on all subsequent requests → `DELETE /mcp` to close. |
| 120 | |
| 121 | ### Resources — 20 total |
| 122 | |
| 123 | Cacheable, URI-addressable reads via the `musehub://` scheme. |
| 124 | |
| 125 | | URI | Description | |
| 126 | |-----|-------------| |
| 127 | | `musehub://trending` | Top public repos by star count | |
| 128 | | `musehub://me` | Authenticated user profile + pinned repos | |
| 129 | | `musehub://me/notifications` | Unread notification inbox | |
| 130 | | `musehub://me/starred` | Repos the user has starred | |
| 131 | | `musehub://me/feed` | Activity feed for watched repos | |
| 132 | | `musehub://repos/{owner}/{slug}` | Repo overview + stats | |
| 133 | | `musehub://repos/{owner}/{slug}/branches` | All branches | |
| 134 | | `musehub://repos/{owner}/{slug}/commits` | Commit list | |
| 135 | | `musehub://repos/{owner}/{slug}/commits/{commit_id}` | Single commit | |
| 136 | | `musehub://repos/{owner}/{slug}/tree/{ref}` | File tree at ref | |
| 137 | | `musehub://repos/{owner}/{slug}/blob/{ref}/{path}` | File metadata | |
| 138 | | `musehub://repos/{owner}/{slug}/issues` | Issue list | |
| 139 | | `musehub://repos/{owner}/{slug}/issues/{number}` | Issue + comment thread | |
| 140 | | `musehub://repos/{owner}/{slug}/pulls` | PR list | |
| 141 | | `musehub://repos/{owner}/{slug}/pulls/{number}` | PR + reviews | |
| 142 | | `musehub://repos/{owner}/{slug}/releases` | All releases | |
| 143 | | `musehub://repos/{owner}/{slug}/releases/{tag}` | Single release | |
| 144 | | `musehub://repos/{owner}/{slug}/analysis/{ref}` | Musical analysis | |
| 145 | | `musehub://repos/{owner}/{slug}/timeline` | Musical evolution timeline | |
| 146 | | `musehub://users/{username}` | User profile + public repos | |
| 147 | |
| 148 | ### Prompts — 8 total |
| 149 | |
| 150 | Workflow guides that teach agents how to chain tools and resources: |
| 151 | |
| 152 | | Prompt | Purpose | |
| 153 | |--------|---------| |
| 154 | | `musehub/orientation` | Essential onboarding — what MuseHub is and which tool to use for what | |
| 155 | | `musehub/contribute` | End-to-end contribution: browse → issue → commit → PR → merge | |
| 156 | | `musehub/compose` | Musical composition workflow with analysis and MIDI push | |
| 157 | | `musehub/review_pr` | Musical PR review with track/region-level inline comments | |
| 158 | | `musehub/issue_triage` | Triage open issues: label, assign, link to milestones | |
| 159 | | `musehub/release_prep` | Prepare a release: merged PRs → release notes → publish | |
| 160 | | `musehub/onboard` | **New** — interactive artist onboarding via elicitation | |
| 161 | | `musehub/release_to_world` | **New** — full release + streaming distribution pipeline | |
| 162 | |
| 163 | ### What an agent can do |
| 164 | |
| 165 | ``` |
| 166 | 1. Discover repos musehub://trending or musehub_search_repos |
| 167 | 2. Understand a repo musehub_get_context → musehub://repos/{owner}/{slug}/analysis/{ref} |
| 168 | 3. Open an issue musehub_create_issue |
| 169 | 4. Push a fix musehub_browse_repo → compose MIDI → musehub_create_pr |
| 170 | 5. Review a PR musehub_review_pr_interactive (elicitation-powered) |
| 171 | 6. Create release musehub_create_release_interactive (form + platform OAuth) |
| 172 | 7. Build social graph musehub_star_repo, musehub_fork_repo |
| 173 | 8. Connect platforms musehub_connect_streaming_platform (Spotify, SoundCloud, …) |
| 174 | 9. Connect cloud DAW musehub_connect_daw_cloud (LANDR, Splice, Soundtrap, …) |
| 175 | 10. Compose with AI musehub_compose_with_preferences (interviews user, returns plan) |
| 176 | ``` |
| 177 | |
| 178 | Full reference: [`docs/reference/mcp.md`](docs/reference/mcp.md) |
| 179 | |
| 180 | --- |
| 181 | |
| 182 | ## Developer Tools |
| 183 | |
| 184 | ```bash |
| 185 | # Type violation audit (ratchet at 0 violations) |
| 186 | python tools/typing_audit.py --dirs musehub/ tests/ --max-any 0 |
| 187 | |
| 188 | # With JSON output |
| 189 | python tools/typing_audit.py --dirs musehub/ tests/ --json artifacts/typing_audit.json |
| 190 | ``` |
| 191 | |
| 192 | ## License |
| 193 | |
| 194 | Proprietary — Muse VCS. |