Skip to content

Move the MCP protocol into a demucs-mcp library crate - #7

Merged
setoelkahfi merged 1 commit into
mainfrom
feat/demucs-mcp-crate
Oct 11, 2026
Merged

setoelkahfi merged 1 commit into
mainfrom
feat/demucs-mcp-crate

Conversation

@setoelkahfi

Copy link
Copy Markdown
Collaborator

The NDJSON JSON-RPC server in demucs-cli/src/mcp.rs mixed the protocol with the CLI's separation engine. The SplitFire AI Audio Separator needs the same protocol over its own engine, so the protocol moves into a new demucs-mcp crate behind a StemEngine trait (list_models, separate). demucs --mcp now calls demucs_mcp::serve with the CLI's engine.

Wire behavior is unchanged: tool schemas, notifications/progress, notifications/cancelled, the busy rule, the 8 MB worker thread and serverInfo.name = "demucs".

Two small differences:

  • list_models is answered by the worker thread, because the engine lives there. During a running separation the answer now waits for the job. Cancels are still handled right away.
  • The model cache is a thread_local on the worker. The wgpu model types overflow the Send check that StemEngine asks for, so the cache can't be a field of the engine.

demucs-mcp depends only on anyhow, serde and serde_json. Its tests run against a fake engine (initialize, tools/list, progress, cancel, busy, malformed line). The 8 existing demucs --mcp integration tests in demucs-cli still pass.

The NDJSON JSON-RPC server in demucs-cli/src/mcp.rs mixed the protocol
with the CLI's separation engine. The protocol now lives in demucs-mcp
behind a StemEngine trait (list_models, separate), and `demucs --mcp`
calls demucs_mcp::serve with the CLI's engine. Wire behavior is the
same: tool schemas, progress, cancel, the busy rule and the 8 MB worker.

One difference: list_models is answered by the worker thread, because
the engine lives there. During a running separation the answer now
waits for the job instead of coming back immediately. Cancels are
still handled right away.

The model cache moved to a thread_local on the worker, since the wgpu
model types overflow the Send check StemEngine requires.

demucs-mcp depends only on anyhow, serde and serde_json and has
protocol tests against a fake engine.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sigit-code-review

Copy link
Copy Markdown

siGit Code Review is paused because the linked siGit account has reached its monthly cloud allowance. On siGit Code Unlimited, reviews don't count toward it: https://sigit.si/billing

@setoelkahfi setoelkahfi self-assigned this Oct 11, 2026
@setoelkahfi
setoelkahfi merged commit 088aa56 into main Oct 11, 2026
7 checks passed
@setoelkahfi
setoelkahfi deleted the feat/demucs-mcp-crate branch October 11, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants