Set up this project for multi-agent DJ Claude jam sessions. This starts the HTTP MCP server (if not already running) and writes the project .mcp.json so all Claude Code sessions share the same audio engine.
Your Task
Parse $ARGUMENTS for an optional port number. Default to 4321 if none provided.
Workflow
IMPORTANT: Steps 1-3 use Bash and file I/O. Step 5 uses mcp__dj-claude-http__* MCP tools to play through the shared HTTP server.
1. Health check
Check if the HTTP server is already running:
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:{PORT}/mcp
400= server is running (MCP endpoint rejects bare GET with 400, which is expected)000or connection refused = not running
2. Start server if needed
If the server is NOT running:
DJ_CLAUDE_PORT={PORT} nohup npx -y --package dj-claude@latest dj-claude-mcp-http > /tmp/dj-claude-http.log 2>&1 &
Wait 3 seconds, then re-check with the same curl health check. If it still isn't responding, show the user the last 10 lines of /tmp/dj-claude-http.log for debugging.
3. Write .mcp.json
Read the existing .mcp.json in the project root (if it exists). Merge a dj-claude-http entry into mcpServers, preserving any other server entries. Write the result back.
The dj-claude-http entry should be:
{
"mcpServers": {
"dj-claude-http": {
"type": "http",
"url": "http://127.0.0.1:{PORT}/mcp"
}
}
}
Use the jq approach via Bash to merge safely:
# If .mcp.json exists, merge; otherwise create from scratch
if [ -f .mcp.json ]; then
jq --arg url "http://127.0.0.1:{PORT}/mcp" \
'.mcpServers["dj-claude-http"] = {"type": "http", "url": $url}' \
.mcp.json > .mcp.json.tmp && mv .mcp.json.tmp .mcp.json
else
echo '{"mcpServers":{"dj-claude-http":{"type":"http","url":"http://127.0.0.1:{PORT}/mcp"}}}' | jq . > .mcp.json
fi
Replace {PORT} with the actual port number in all commands.
4. Communicate
Tell the user (keep it concise — a few short lines):
- Whether the HTTP server was already running or just started (and on which port)
- That
.mcp.jsonhas been configured — new Claude Code sessions in this project will auto-connect - Other agents (Cursor, Windsurf, etc.) can connect by pointing their MCP config at
http://127.0.0.1:{PORT}/mcp
5. Join the jam (or tell the user to restart)
Before calling any mcp__dj-claude-http__* tools, check whether they exist in this session. Try calling mcp__dj-claude-http__jam_status. If the tool call succeeds, the HTTP tools are available — proceed to the jam loop below. If the tool call fails with an unknown-tool error (or you can see that mcp__dj-claude-http__* tools are not in your tool list), the MCP server hasn't been picked up yet. This is expected on the first run.
First run (tools NOT available):
Tell the user:
- The HTTP server is running and
.mcp.jsonis configured - They need to restart MCP (run
/mcpthen click restart, or open a new Claude Code session) for thedj-claude-httptools to appear - After restarting, run
/dj-claude:connectagain and the jam will start automatically
Do NOT attempt to call mcp__dj-claude-http__* tools that don't exist. Stop here.
Returning run (tools available):
IMPORTANT: Use mcp__dj-claude-http__* tools (NOT mcp__dj-claude__*). The dj-claude-http tools route through the shared HTTP server so all agents hear the same audio and see each other's layers. The dj-claude tools route through a local stdio server that nobody else can hear.
You are jamming live with other Claude Code agents using DJ Claude. You're connected via the dj-claude-http MCP server — a shared audio engine where all agents' layers combine in real-time. Keep it musical. Don't ask the user anything — just play.
Run this loop forever until the user stops you (Esc / Ctrl+C / "stop"):
- Call
mcp__dj-claude-http__jam_statusto see what's already playing - React musically — pick a role that's missing or evolve an existing layer with
mcp__dj-claude-http__jamusing thecodeparameter. Always passkey,tempo,notes, andadded_byso other agents know what you're playing and can stay in sync. - Wait 15-20 seconds (use Bash
sleep) to let the music breathe - Go back to step 1 — check what changed, react, evolve, add
Never stop on your own. Never ask "what should I play next?" or "would you like me to continue?" You are a musician in a live session — listen, play, evolve, repeat. The user will interrupt you when they want you to stop.