Code Generator MCP Server
Click on "Install 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., "@Code Generator MCP ServerGenerate a Python function to calculate factorial"
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.
Code Generator MCP Template Server
An MCP (Model Context Protocol) server built using Python's FastMCP framework. It exposes 4 precise, structured code-generation tools backed by prompt templates to generate production-grade, parsed code using local or cloud-based OpenAI-compatible APIs (such as llama-server, qwen-coder, gemma-12b, or OpenAI's API).
๐ Features
Exposes 4 key MCP tools that use structured templates to instruct the model to think step-by-step and produce clean, executable code:
generate_standard_function(Template 1): Generates a standalone function based on constraints, edge cases, test cases, and external integration notes.generate_codebase_context(Template 2): Generates a function that respects and integrates with existing codebase structures and dependencies.generate_bugfix_refactor(Template 3): Focuses on refactoring or repairing current buggy implementations based on problem descriptions and test expectations.generate_multi_function_module(Template 4): Generates a multi-function module, validating that there are no circular dependencies or undefined functions.
โ๏ธ Parser & Guardrails
Markdown Stripper: Automatic code parsing (
extract_code_from_response) strips any markdown code blocks (```python) generated by instruct models, guaranteeing only raw executable code is returned.Reasoning Fallback: Correctly handles DeepSeek-style reasoning models or
llama-serverconfigurations where all output is redirected into thereasoning_contentfield instead ofcontent.Max Tokens Guardrail: Enforces a
2048token limit per request to prevent local model reasoning loops and timeouts.
Related MCP server: apcore-mcp
๐ ๏ธ Configuration
Configure the server using command-line arguments or environment variables:
Setting | CLI Argument | Environment Variable | Default Value | Description |
API URL |
|
|
| OpenAI-compatible endpoint |
Model |
|
|
| The model name to target |
API Key |
|
| (Empty) | API token (optional for local endpoints) |
For security reasons, do not pass--api-key via command-line arguments as it will be visible in plain text in the host process table. Use the environment variables instead.
๐ป Getting Started
Prerequisites
Python 3.10+
Dependencies installed in virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtRunning Locally
To run the MCP server directly over standard input/output (stdio):
python src/code_generator_mcp/server.py --api-url http://localhost:8008/v1 --model gemma-12bTesting during development
You can use mcp dev (from MCP CLI) to test the server interactively in a development UI:
mcp dev src/code_generator_mcp/server.py -- --api-url http://localhost:8008/v1 --model gemma-12b๐ Integration Setup
To use this server with your favorite MCP client (like Claude Desktop or Cursor):
Claude Desktop Configuration
Open your Claude Desktop config file (usually located at ~/.config/Claude/claude_desktop_config.json on Linux/macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows) and add the following entry:
{
"mcpServers": {
"code-generator-mcp": {
"command": "/path/to/project/.venv/bin/python",
"args": [
"/path/to/project/src/code_generator_mcp/server.py"
],
"env": {
"CODE_GEN_API_URL": "http://localhost:8008/v1",
"CODE_GEN_MODEL": "gemma-12b"
}
}
}
}๐งช Testing
The codebase includes a fully-featured unit and integration test suite using pytest. Run tests with:
.venv/bin/pytestThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/remiehneppo/code-generator-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server