Skip to main content
Glama
keithah

Qwen3-Coder MCP Server

qwen3_code_explain

Explain code functionality and logic in natural language to help developers understand complex programming concepts and improve code comprehension.

Instructions

Explain code using Qwen3-Coder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe code to explain
languageNoProgramming language of the code

Implementation Reference

  • The specific handler logic for the 'qwen3_code_explain' tool. It constructs a detailed prompt for code explanation and invokes the shared callQwen3Coder helper function to query the Qwen3-Coder model.
          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;
  • Registration of the 'qwen3_code_explain' tool in the ListTools response, including its 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"]
      }
    },
  • Input schema definition for the 'qwen3_code_explain' tool, specifying required 'code' parameter and optional 'language'.
    inputSchema: {
      type: "object",
      properties: {
        code: {
          type: "string",
          description: "The code to explain"
        },
        language: {
          type: "string",
          description: "Programming language of the code"
        }
      },
      required: ["code"]
    }
  • Shared helper function used by all Qwen3 tools to spawn an Ollama process running the 'qwen3-coder:30b' model with the constructed prompt, capturing output 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
      });
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keithah/qwen3-coder-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server