From f3c90166761861df987cc416653ad2cf7abbb64a Mon Sep 17 00:00:00 2001 From: ArthurErlich Date: Sun, 6 Sep 2026 16:54:43 +0200 Subject: [PATCH] Add README Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01CRnb5Gqdu7gVTQrwAqFdfJ --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bfbf303 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# delegate-ai-mcp + +An MCP server that lets Claude Code delegate light, low-stakes work to a local +[qwen-code](https://github.com/QwenLM/qwen-code) CLI instance, instead of spending its own +budget on it. + +## How it works + +- `src/qwen-delegate.ts` — core logic: spawns `qwen -p ""`, 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 + +```bash +npm install +npm test +``` + +## Register with Claude Code + +Global (available in every project): + +```bash +claude mcp add --scope user qwen-delegate -- node /absolute/path/to/src/qwen-delegate-server.ts +``` + +Verify it connected: + +```bash +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 + +```bash +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](https://git.arthurerlich.de/haylan/delegate-ai-mcp/issues/1) on this repo's +issue tracker — see `docs/agents/issue-tracker.md` for how issues/tickets work here.