v2.0.1: Add /qwenclaw slash commands for Qwen Code CLI

This commit is contained in:
AI Agent
2026-02-26 21:18:00 +04:00
Unverified
parent 69cf7e8a05
commit c2a97e0995
5 changed files with 1388 additions and 5 deletions

View File

@@ -64,6 +64,8 @@ qwenclaw send "Check my tasks"
## Commands
### Terminal Commands
```bash
qwenclaw start # Start daemon
qwenclaw status # Check status
@@ -73,6 +75,35 @@ qwenclaw setup # Setup wizard
qwenclaw help # Show help
```
### Inside Qwen Code CLI (Slash Commands)
After setup, use `/qwenclaw:` commands directly in Qwen Code chat:
```
/qwenclaw:start - Start daemon
/qwenclaw:status - Check daemon status
/qwenclaw:send "task" - Send task to daemon
/qwenclaw:skills - List available skills
/qwenclaw:help - Show help
```
**Example:**
```
/qwenclaw:status
```
**Response:**
```
🐾 QwenClaw Status
════════════════════════════════════════
Daemon: Ready
Provider: Qwen Code CLI
Skills: 81 available
Web Dashboard: http://127.0.0.1:4632
```
**Note:** Commands execute in your terminal and show output in Qwen Code chat.
---
## Usage Examples

View File

@@ -16,7 +16,7 @@ const command = args[0];
const commands = {
async start() {
console.log('🐾 QwenClaw - Starting daemon...');
const proc = spawn('qwen', ['-p', 'QwenClaw daemon started. Ready for tasks.'], {
const proc = spawn('qwen', ['QwenClaw daemon started. Ready for tasks.'], {
stdio: 'inherit',
shell: true,
});
@@ -39,7 +39,7 @@ const commands = {
process.exit(1);
}
console.log('📤 Sending to Qwen Code CLI...');
const proc = spawn('qwen', ['-p', message], {
const proc = spawn('qwen', [message], {
stdio: 'inherit',
shell: true,
});

1146
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,8 @@
"description": "Qwen Code CLI's ALWAYS-ON AI Assistant - Built from OpenClaw",
"type": "module",
"bin": {
"qwenclaw": "./bin/qwenclaw.js"
"qwenclaw": "./bin/qwenclaw.js",
"qwenclaw-mcp": "./src/mcp-server.js"
},
"scripts": {
"start": "node bin/qwenclaw.js start",
@@ -12,7 +13,8 @@
"send": "node bin/qwenclaw.js send",
"skills": "node bin/qwenclaw.js skills",
"setup": "node bin/qwenclaw.js setup",
"help": "node bin/qwenclaw.js help"
"help": "node bin/qwenclaw.js help",
"mcp": "node src/mcp-server.js"
},
"keywords": [
"qwen",
@@ -21,7 +23,8 @@
"ai-assistant",
"openclaw",
"multi-agent",
"automation"
"automation",
"mcp"
],
"author": "QwenClaw Team",
"license": "MIT",
@@ -35,5 +38,8 @@
},
"engines": {
"node": ">=22.0.0"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.27.1"
}
}

200
src/mcp-server.js Normal file
View File

@@ -0,0 +1,200 @@
#!/usr/bin/env node
/**
* QwenClaw MCP Server
*
* Provides QwenClaw functionality as MCP tools for Qwen Code CLI
*
* Usage:
* In Qwen Code, type: /qwenclaw <command>
* Commands: start, status, send, skills, help
*/
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { spawn } from 'child_process';
import { join } from 'path';
const QWENCLAW_DIR = join(process.cwd());
// Tool definitions
const TOOLS = [
{
name: 'qwenclaw_start',
description: 'Start QwenClaw daemon',
inputSchema: {
type: 'object',
properties: {
web: {
type: 'boolean',
description: 'Enable web dashboard',
default: false,
},
},
},
},
{
name: 'qwenclaw_status',
description: 'Check QwenClaw daemon status',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'qwenclaw_send',
description: 'Send message to QwenClaw daemon',
inputSchema: {
type: 'object',
properties: {
message: {
type: 'string',
description: 'Message to send',
},
},
required: ['message'],
},
},
{
name: 'qwenclaw_skills',
description: 'List all available QwenClaw skills',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'qwenclaw_help',
description: 'Show QwenClaw help information',
inputSchema: {
type: 'object',
properties: {},
},
},
];
// Create MCP server
const server = new Server(
{
name: 'qwenclaw',
version: '2.0.0',
},
{
capabilities: {
tools: {},
},
}
);
// Handle tool listing
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: TOOLS,
};
});
// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args = {} } = request.params;
try {
switch (name) {
case 'qwenclaw_start': {
const web = args.web || false;
const result = await runCommand('start', web ? ['--web'] : []);
return {
content: [{ type: 'text', text: result }],
};
}
case 'qwenclaw_status': {
const result = await runCommand('status', []);
return {
content: [{ type: 'text', text: result }],
};
}
case 'qwenclaw_send': {
const message = args.message;
if (!message) {
return {
content: [{ type: 'text', text: 'Error: message is required' }],
isError: true,
};
}
const result = await runCommand('send', [message]);
return {
content: [{ type: 'text', text: result }],
};
}
case 'qwenclaw_skills': {
const result = await runCommand('skills', []);
return {
content: [{ type: 'text', text: result }],
};
}
case 'qwenclaw_help': {
const result = await runCommand('help', []);
return {
content: [{ type: 'text', text: result }],
};
}
default:
return {
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
isError: true,
};
}
} catch (error) {
return {
content: [{ type: 'text', text: `Error: ${error.message}` }],
isError: true,
};
}
});
// Run QwenClaw command
async function runCommand(command, args = []) {
return new Promise((resolve, reject) => {
const proc = spawn('node', [join(QWENCLAW_DIR, 'bin', 'qwenclaw.js'), command, ...args], {
stdio: ['pipe', 'pipe', 'pipe'],
});
let output = '';
let error = '';
proc.stdout.on('data', (data) => {
output += data.toString();
});
proc.stderr.on('data', (data) => {
error += data.toString();
});
proc.on('close', (code) => {
if (code === 0) {
resolve(output.trim());
} else {
reject(new Error(error || `Command failed with code ${code}`));
}
});
});
}
// Start server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('QwenClaw MCP server running on stdio');
}
main().catch((error) => {
console.error('Fatal error:', error);
process.exit(1);
});