qwen3_code_explain
Explain code functionality and logic using the Qwen3-Coder model to help developers understand programming concepts and implementation details.
Instructions
Explain code using Qwen3-Coder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The code to explain | |
| language | No | Programming language of the code |
Implementation Reference
- qwen3-mcp-server.js:184-193 (handler)Handler implementation for the qwen3_code_explain tool. Constructs a prompt to explain the code snippet (including language if provided) and invokes the Qwen3-Coder model via callQwen3Coder.case "qwen3_code_explain": prompt = `Please explain the following ${args.language || 'code'} in detail, including what it does, how it works, and any important concepts: \`\`\`${args.language || ''} ${args.code} \`\`\` Provide a clear and comprehensive explanation.`; result = await callQwen3Coder(prompt); break;
- qwen3-mcp-server.js:83-96 (schema)Input schema for the qwen3_code_explain tool, specifying a required 'code' string parameter and an optional 'language' string.inputSchema: { type: "object", properties: { code: { type: "string", description: "The code to explain" }, language: { type: "string", description: "Programming language of the code" } }, required: ["code"] }
- qwen3-mcp-server.js:80-97 (registration)Registration of the qwen3_code_explain tool in the ListTools response, including name, description, and input schema.{ name: "qwen3_code_explain", description: "Explain code using Qwen3-Coder", inputSchema: { type: "object", properties: { code: { type: "string", description: "The code to explain" }, language: { type: "string", description: "Programming language of the code" } }, required: ["code"] } },
- qwen3-mcp-server.js:25-56 (helper)Helper function used by all tools, including qwen3_code_explain, to execute prompts against the qwen3-coder:30b model using ollama via child_process.spawn, with timeout handling.async function callQwen3Coder(prompt, options = {}) { return new Promise((resolve, reject) => { const ollamaProcess = spawn('ollama', ['run', 'qwen3-coder:30b', prompt], { stdio: ['pipe', 'pipe', 'pipe'] }); let output = ''; let error = ''; ollamaProcess.stdout.on('data', (data) => { output += data.toString(); }); ollamaProcess.stderr.on('data', (data) => { error += data.toString(); }); ollamaProcess.on('close', (code) => { if (code === 0) { resolve(output.trim()); } else { reject(new Error(`Ollama process exited with code ${code}: ${error}`)); } }); // Set timeout for long-running requests setTimeout(() => { ollamaProcess.kill(); reject(new Error('Request timeout')); }, options.timeout || 120000); // 2 minutes default timeout }); }