delegate-ai-mcp

An MCP server that lets Claude Code delegate light, low-stakes work to a local qwen-code CLI instance, instead of spending its own budget on it.

How it works

  • src/qwen-delegate.ts — core logic: spawns qwen -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.

Prerequisites

  • Node.js 24+ (the server runs .ts source directly via Node's native TypeScript type-stripping — no build step, no compiler)
  • qwen on PATH and 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 / roadmap

Project conventions (build/typecheck strategy, lint/format tooling, multi-tool source structure, publish-shaped package.json) 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.

S
Description
No description provided
Readme
62 KiB
Languages
TypeScript 82.2%
JavaScript 17.8%