qwen-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@qwen-mcp-server Ask Qwen to review src/index.ts and list potential bugs"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
qwen-mcp-server
An MCP server that lets an MCP client such as Claude Code talk to the Qwen Code CLI: ask it a question, hand it a task, and continue the same conversation over several calls.
Qwen Code has no MCP-server mode of its own, so this server starts the qwen
CLI once per call in headless mode (--output-format json) and returns the
final answer.
The project structure and parts of the code come from tuannvm/codex-mcp-server, which does the same for the OpenAI Codex CLI.
Requirements
Node.js 20 or newer
Qwen Code installed and on
PATH(developed against 0.28.0), or its path inQWEN_MCP_BINWorking Qwen Code authentication: either Qwen Code's own settings, or an API key file configured below
Related MCP server: Claude Code Manager WAN
Install
git clone https://github.com/Theralley/qwen-mcp-server.git
cd qwen-mcp-server
npm install # also builds dist/Register it with your MCP client. For Claude Code:
claude mcp add qwen \
-e QWEN_MCP_API_KEY_FILE=/path/to/api.key \
-e QWEN_MCP_BASE_URL=https://api.example.com/v1 \
-e QWEN_MCP_DEFAULT_MODEL=your-model-id \
-- node /path/to/qwen-mcp-server/dist/index.jsor as JSON:
{
"mcpServers": {
"qwen": {
"command": "node",
"args": ["/path/to/qwen-mcp-server/dist/index.js"],
"env": {
"QWEN_MCP_API_KEY_FILE": "/path/to/api.key",
"QWEN_MCP_BASE_URL": "https://api.example.com/v1",
"QWEN_MCP_DEFAULT_MODEL": "your-model-id"
}
}
}
}If qwen already works when you run it yourself without extra flags, you need
no env at all.
Configuration
Everything is set through environment variables on the server process. All are optional.
Variable | Default | Meaning |
|
| The Qwen Code executable. |
| not set | File holding an API key. Its content is passed to Qwen Code as |
| not set | Further environment variable names that also receive the key, comma-separated (for example |
| not set | Passed to Qwen Code as |
|
| Value for |
| not set | Model used when a call names none. Without it Qwen Code's own default applies. |
|
| Approval mode used when a call names none. |
|
| Time budget per call when a call names none: seconds ( |
The key file is read at every call, so a rotated key works without a restart.
The key is given to Qwen Code through its environment only: it is never put on
a command line, never written to disk and never logged, and it is removed from
any output or error text the server returns. Keep the file readable by you
alone (chmod 600).
Apart from these variables, Qwen Code inherits the server's environment.
Tools
qwen
Runs Qwen Code on a prompt and returns its final answer.
Argument | Meaning |
| The task or question. Sent on stdin, so its length and content are not limited by the command line. |
| Your own name for a conversation (letters, digits, |
| Forget the Qwen session behind |
| Model for this call. |
|
|
| Directory Qwen Code runs in. Defaults to the server's own. |
| Time budget for this call. |
| Extra instructions appended to the system prompt. |
The result's _meta carries qwenSessionId, sessionId, resumed,
workingDirectory, model, approvalMode, durationMs, numTurns and
usage.
Approval modes. plan lets Qwen Code read and analyze but not edit files
or run commands. auto-edit approves file edits, auto lets a classifier
approve safe actions, and yolo approves everything. default asks for
approval, and a headless run has nobody to give it. Raise the mode only for
work where Qwen Code should change things.
Sessions. The first call with a new sessionId creates a Qwen session
(--session-id <uuid>); later calls continue it (--resume <uuid>). A Qwen
session belongs to the directory it was started in, so the session keeps the
working directory of its first call, and a different workingDirectory on a
later call is rejected. If Qwen Code cannot resume the session, the call fails
and says so. It does not quietly start a new conversation; pass
resetSession: true to do that. Calls on one sessionId run one after
another.
The mapping from sessionId to Qwen session lives in the server's memory: up
to 100 sessions, each dropped 24 hours after its last use, and all of them
when the server restarts. The Qwen sessions themselves stay in Qwen Code's own
history.
Time limit. Qwen Code stops itself at the wall-time budget (exit code 55, reported as an exceeded budget). If it has not exited 30 seconds after that, the server kills it and the processes it started. A cancelled MCP request stops the run as well.
listSessions
Lists the sessions the server knows: sessionId, qwenSessionId,
workingDirectory, creation and last-use time, and the number of turns.
ping
Returns pong, or the message you pass.
help
Returns qwen --help, or the installed version with command: "version".
Development
npm run build # compile to dist/
npm test # builds, then runs the jest suite
npm run lintThe tests use a fake qwen executable and need neither Qwen Code nor a
network connection.
scripts/e2e.mjs checks a real installation: it calls ping, then qwen
twice on one session to prove that resume works. It uses the QWEN_MCP_*
variables of the shell it is started from and spends a few model calls:
npm run build
QWEN_MCP_API_KEY_FILE=/path/to/api.key \
QWEN_MCP_BASE_URL=https://api.example.com/v1 \
QWEN_MCP_DEFAULT_MODEL=your-model-id \
node scripts/e2e.mjsLimits
One CLI process per call. Qwen Code loads its settings, context files, extensions and MCP servers each time, which costs a few seconds and some tokens per call.
No streaming: the answer arrives when the run ends. Clients that send a progress token get a progress notification every 15 seconds.
Developed and tested on macOS. The Windows code path is carried over from codex-mcp-server and has not been run.
License
ISC. See LICENSE.
Available Tools
4 toolshelpARead-onlyIdempotent
Get the Qwen Code CLI help text or installed version
Inputs: command.
listSessionsARead-onlyIdempotent
List the active conversation sessions with their Qwen session IDs and working directories
Inputs: no named parameters.
pingARead-onlyIdempotent
Test MCP server connection
Inputs: message.
qwenADestructive
Run the Qwen Code CLI non-interactively for AI assistance. Read-only (approval mode "plan") unless configured or asked otherwise.
Inputs: prompt (required), model, sessionId, maxWallTime, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct role: qwen executes the CLI, listSessions lists active sessions, ping tests connectivity, and help returns CLI help/version. There is no meaningful overlap between them.
listSessions uses camelCase while qwen, ping, and help are lowercase single-word names, so conventions are mixed. The names remain readable and understandable, but there is no consistent verb_noun pattern.
Four tools is well-scoped for a thin wrapper around the Qwen Code CLI. Each tool serves a clear purpose and none feels redundant or missing from the core surface.
The set covers execution, session listing, connectivity testing, and help/version retrieval. A minor gap exists around explicit session management (e.g., terminate, resume, or inspect a specific session), but the core workflow is workable through qwen execution.
Maintenance
Related MCP Connectors
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables MCP clients to spawn and control Codex CLI and Claude Code sessions on the host machine, with session management and filesystem access.4MIT
- FlicenseNot gradedqualityCmaintenanceEnables ISLI agents and MCP clients to dispatch natural-language coding and terminal tasks to a locally-installed Claude Code CLI, supporting both one-shot execution and persistent sessions with workspace and security controls.-
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients like Claude Code to delegate coding tasks to the local Cursor Agent CLI, with persistent per-workspace sessions that resume across calls.12 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables voice assistants to start, monitor, message, and approve local Claude Code sessions on your computer, including sessions already open in a terminal. It exposes session management, recaps, approvals, and history search as MCP tools.8GPL 3.0