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