gabriel / musehub public
README.md markdown
170 lines 6.0 KB
bb9e42df docs: update README + add full MCP reference guide Gabriel Cardona <gabriel@tellurstori.com> 6d ago
1 # MuseHub
2
3 **MuseHub** — the music composition version control platform powered by Muse VCS.
4
5 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.
6
7 ## URL scheme
8
9 ```
10 /{owner}/{slug} → repo home page
11 musehub://{owner}/{slug} → MCP resource URI (see MCP docs)
12 ```
13
14 ## Architecture
15
16 ```
17 musehub/
18 api/routes/musehub/ 44 route handlers (thin HTTP)
19 api/routes/mcp.py POST /mcp — HTTP Streamable MCP endpoint
20 services/ 26 musehub_*.py business logic modules
21 db/ SQLAlchemy ORM models (Postgres)
22 models/ Pydantic request/response models
23 mcp/
24 dispatcher.py Async JSON-RPC 2.0 engine (no SDK dependency)
25 tools/ 27-tool catalogue (15 read + 12 write)
26 resources.py 20 musehub:// resources (5 static + 15 templated)
27 prompts.py 6 workflow prompts
28 write_tools/ Write executor modules (repos, issues, PRs, releases, social)
29 stdio_server.py stdio transport for local dev / Cursor IDE
30 templates/musehub/ Jinja2 + HTMX + Alpine.js web UI
31 auth/ JWT auth dependencies
32 config.py Pydantic Settings (env vars)
33
34 tools/
35 typing_audit.py Static typing violation scanner (ratchet-safe)
36 ```
37
38 ## Running locally
39
40 ```bash
41 # Start with Docker Compose (Postgres + app)
42 docker compose up -d
43
44 # Run Alembic migrations
45 docker compose exec musehub alembic upgrade head
46
47 # Seed development data
48 docker compose exec musehub python3 scripts/seed_musehub.py
49 ```
50
51 ## API
52
53 Interactive docs available at `/docs` when `DEBUG=true`.
54
55 OpenAPI spec always available at `/api/v1/openapi.json`.
56
57 ## Auth
58
59 Write endpoints and private-repo reads require:
60
61 ```
62 Authorization: Bearer <jwt>
63 ```
64
65 Public repo reads and all MCP read tools are unauthenticated. MCP write tools require the same JWT in the `Authorization` header.
66
67 ---
68
69 ## MCP Integration
70
71 MuseHub implements the full [MCP 2025-03-26 specification](https://spec.modelcontextprotocol.io/) — no external MCP SDK, pure Python async. Agents get complete capability parity with the web UI.
72
73 ### Transports
74
75 | Transport | Endpoint | Use case |
76 |-----------|----------|----------|
77 | HTTP Streamable | `POST /mcp` | Production; any MCP client |
78 | stdio | `python -m musehub.mcp.stdio_server` | Local dev, Cursor IDE |
79
80 **Cursor IDE integration** — add to `.cursor/mcp.json`:
81
82 ```json
83 {
84 "mcpServers": {
85 "musehub": {
86 "command": "python",
87 "args": ["-m", "musehub.mcp.stdio_server"],
88 "cwd": "/path/to/musehub"
89 }
90 }
91 }
92 ```
93
94 ### Tools — 27 total
95
96 **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.
97
98 **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.
99
100 > All write tools require `Authorization: Bearer <jwt>`.
101
102 ### Resources — 20 total
103
104 Cacheable, URI-addressable reads via the `musehub://` scheme.
105
106 | URI | Description |
107 |-----|-------------|
108 | `musehub://trending` | Top public repos by star count |
109 | `musehub://me` | Authenticated user profile + pinned repos |
110 | `musehub://me/notifications` | Unread notification inbox |
111 | `musehub://me/starred` | Repos the user has starred |
112 | `musehub://me/feed` | Activity feed for watched repos |
113 | `musehub://repos/{owner}/{slug}` | Repo overview + stats |
114 | `musehub://repos/{owner}/{slug}/branches` | All branches |
115 | `musehub://repos/{owner}/{slug}/commits` | Commit list |
116 | `musehub://repos/{owner}/{slug}/commits/{commit_id}` | Single commit |
117 | `musehub://repos/{owner}/{slug}/tree/{ref}` | File tree at ref |
118 | `musehub://repos/{owner}/{slug}/blob/{ref}/{path}` | File metadata |
119 | `musehub://repos/{owner}/{slug}/issues` | Issue list |
120 | `musehub://repos/{owner}/{slug}/issues/{number}` | Issue + comment thread |
121 | `musehub://repos/{owner}/{slug}/pulls` | PR list |
122 | `musehub://repos/{owner}/{slug}/pulls/{number}` | PR + reviews |
123 | `musehub://repos/{owner}/{slug}/releases` | All releases |
124 | `musehub://repos/{owner}/{slug}/releases/{tag}` | Single release |
125 | `musehub://repos/{owner}/{slug}/analysis/{ref}` | Musical analysis |
126 | `musehub://repos/{owner}/{slug}/timeline` | Musical evolution timeline |
127 | `musehub://users/{username}` | User profile + public repos |
128
129 ### Prompts — 6 total
130
131 Workflow guides that teach agents how to chain tools and resources:
132
133 | Prompt | Purpose |
134 |--------|---------|
135 | `musehub/orientation` | Essential onboarding — what MuseHub is and which tool to use for what |
136 | `musehub/contribute` | End-to-end contribution: browse → issue → commit → PR → merge |
137 | `musehub/compose` | Musical composition workflow with MIDI push and analysis |
138 | `musehub/review_pr` | Musical PR review with track/region-level inline comments |
139 | `musehub/issue_triage` | Triage open issues: label, assign, link to milestones |
140 | `musehub/release_prep` | Prepare a release: merged PRs → release notes → publish |
141
142 ### What an agent can do
143
144 ```
145 1. Discover repos musehub://trending or musehub_search_repos
146 2. Understand a repo musehub_get_context → musehub://repos/{owner}/{slug}/analysis/{ref}
147 3. Open an issue musehub_create_issue
148 4. Push a fix musehub_browse_repo → compose MIDI → musehub_create_pr
149 5. Review a PR musehub_get_pr → musehub_compare → musehub_create_pr_comment → musehub_submit_pr_review
150 6. Publish musehub_create_release
151 7. Build social graph musehub_star_repo, musehub_fork_repo
152 ```
153
154 Full reference: [`docs/reference/mcp.md`](docs/reference/mcp.md)
155
156 ---
157
158 ## Developer Tools
159
160 ```bash
161 # Type violation audit (ratchet at 0 violations)
162 python tools/typing_audit.py --dirs musehub/ tests/ --max-any 0
163
164 # With JSON output
165 python tools/typing_audit.py --dirs musehub/ tests/ --json artifacts/typing_audit.json
166 ```
167
168 ## License
169
170 Proprietary — Muse VCS.