Skip to main content
Glama
keithah

Qwen3-Coder MCP Server

qwen3_code_generate

Generate code from natural language descriptions in specified programming languages using the Qwen3-Coder model.

Instructions

Generate code using Qwen3-Coder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of what code to generate
languageNoTarget programming language

Implementation Reference

  • Registration of the 'qwen3_code_generate' tool, including name, description, and input schema definition.
    {
      name: "qwen3_code_generate",
      description: "Generate code using Qwen3-Coder",
      inputSchema: {
        type: "object",
        properties: {
          prompt: {
            type: "string",
            description: "Description of what code to generate"
          },
          language: {
            type: "string",
            description: "Target programming language"
          }
        },
        required: ["prompt"]
      }
    },
  • Handler for 'qwen3_code_generate': constructs a specific prompt based on input arguments and calls the shared Qwen3-Coder function.
          case "qwen3_code_generate":
            prompt = `Generate ${args.language || 'code'} for the following requirement:
    
    ${args.prompt}
    
    ${args.language ? `Please write the code in ${args.language}.` : ''}
    
    Provide clean, well-documented code with explanations.`;
            result = await callQwen3Coder(prompt);
            break;
  • Shared helper function that spawns Ollama process to run Qwen3-Coder model with the given prompt and returns the output.
    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