delegate-ai-mcp
MCP servers that let Claude Code delegate light, low-stakes work to local AI CLI backends, instead of spending its own budget on it. Currently one backend: qwen-code.
How it works
src/qwen-delegate.ts— core logic: spawnsqwen -p "<prompt>", captures stdout, handles timeouts and errors. Exported separately from the MCP wiring so it's unit-testable without a live MCP connection or a live qwen endpoint.src/qwen-delegate-server.ts— thin MCP stdio server exposing one tool,qwen_delegate.
qwen-code runs natively on Windows here (no WSL), backed by a local OpenAI-compatible model
proxy configured in ~/.qwen/settings.json. See research/qwen-mcp-delegation.md for how that
was confirmed. Replies can take several minutes on a cold local model, so the tool uses a
generous (10 min) timeout rather than trying to enforce "light work" in code — that's a
judgment call left to whoever's calling the tool.
Each backend is its own MCP server process with its own claude mcp add registration —
there's no single multi-tool server. Adding a second backend means adding its own
src/<backend>-delegate.ts + src/<backend>-delegate-server.ts pair and registering it
separately (see Status below — the shared subprocess helper this implies isn't extracted yet).
No build step: everything runs as plain .ts source via Node's native TypeScript
type-stripping. No tsconfig.json, no dist/, no lint/format tooling — deliberate choices,
not oversights (see the wayfinder map linked below).
Prerequisites
- Node.js 24+ (native TypeScript type-stripping)
qwenonPATHand working (qwen -p "test"should return a reply)
Setup
npm install
npm test
Register with Claude Code
Global (available in every project):
claude mcp add --scope user qwen-delegate -- node /absolute/path/to/src/qwen-delegate-server.ts
Verify it connected:
claude mcp list
Usage
Once registered, Claude Code can call the qwen_delegate tool directly. The routing
convention — when to delegate — lives in ~/.claude/CLAUDE.md under "Delegating light work
to qwen": simple lookups, quick research, boilerplate text, small single-file edits. Claude
decides per-request; there's no enforced dispatcher.
Testing
npm test
Runs test/qwen-delegate.test.ts on Node's built-in test runner (node --test) — no test
framework dependency. The subprocess spawn is mocked, so tests run in milliseconds and don't
require a live qwen install.
Status
Project conventions are being worked through a
wayfinder map on this repo's
issue tracker (see docs/agents/issue-tracker.md for how issues/tickets work here). Decided
so far: no build process, ever; separate MCP server process + registration per backend, with a
shared src/lib/spawn-cli.ts helper once a second backend exists (not extracted yet — still
just qwen-delegate.ts); no lint/format tooling for now. Still open: a publish-shaped
package.json.