Skip to content

m2ai-portfolio/agentic-coding-mcp-server

Repository files navigation

Agentic Coding MCP Server: Local Gemma 4 powered coding assistant integrated with Zed editor

A tiny offline coding assistant that suggests refactors or explains code using a local Gemma‑4 model

Quick StartFeaturesExamplesContributing

What is this?

Agentic Coding MCP Server is a command‑line tool that runs completely offline. It loads a locally stored Gemma‑4 GGUF model and, given a short code snippet, either returns a refactored version or a plain‑language explanation. It is built in Python 3.10+, uses torch and transformers for inference, and sentencepiece for tokenization. Ideal for solo developers who want fast, private AI help without any internet round‑trip.

Usage example – refactor:

$ gemma_code_helper.py --mode refactor --file example.py
def foo():
    # unused variable
    x = 1
    return x

Output:

def foo():
    return 1

Usage example – explain:

$ gemma_code_helper.py --mode explain --file example.py

Output:

The function foo returns the value of variable x after assigning it 1. It contains no side effects.

Features

Feature Description
Offline inference Runs entirely on local CPU/GPU, no network calls
Refactor mode Suggests code improvements (dead code removal, loop simplification, PEP‑8 compliance)
Explain mode Provides concise plain‑language description of snippet behavior
Multiple model formats Accepts any GGUF file; defaults to gemma-4-q4_k_m.gguf
Flexible prompting Control instruction prefix via --mode flag
Minimal dependencies Only torch, transformers, sentencepiece; no uv or RPC server
Zed editor agnostic Works with any editor; output is plain text
MIT license Permissive open‑source license

Quick Start

  1. Clone the repository: git clone https://github.com/yourusername/agentic-coding-mcp-server.git
  2. Create a virtual environment: python -m venv venv && source venv/bin/activate
  3. Install dependencies: pip install -r requirements.txt
  4. Place a GGUF model file (e.g., gemma-4-q4_k_m.gguf) in the models/ directory.
  5. Run the helper: python gemma_code_helper.py --mode refactor --file my_script.py
  6. View the refactored snippet printed to stdout

Examples

Title: Delete unused variable
Command: python gemma_code_helper.py --mode refactor --file dead.py
Input (dead.py):

def process():
    unused = 5
    result = 10
    return result

Output:

def process():
    return 10

Title: Describe what a function does
Command: python gemma_code_helper.py --mode explain --file greet.py
Input (greet.py):

def greet(name):
    """Return greeting."""
    return f"Hello, {name}"

Output:

The function greet takes a string name and returns a greeting message that starts with Hello, followed by the provided name.

File Structure

Agentic Coding MCP Server: Local Gemma 4 powered coding assistant integrated with Zed editor/ ├── gemma_code_helper/ │ ├── init.py │ ├── main.py │ ├── cli.py │ ├── engine.py │ ├── formatter.py │ └── prompt.py ├── tests/ │ ├── init.py │ ├── test_cli.py │ ├── test_engine.py │ ├── test_formatter.py │ └── test_prompt.py ├── models/ # Place your GGUF files here ├── assets/ # Infographic and other media ├── requirements.txt ├── requirements-dev.txt └── README.md

Tech Stack

Technology Purpose
Python 3.10+ Core language
torch ≥2.3 Model inference and tensor ops
transformers Tokenizer/model loading for GGUF
sentencepiece Subword tokenization
argparse CLI argument parsing
pathlib Filesystem handling
MIT License Licensing

Contributing

  • Fork the repo and create a branch.
  • Make changes with tests.
  • Run tests to confirm.
  • Open a pull request.

License

MIT

Author

Matthew Snow -- M2AI | @m2ai-portfolio

About

Agentic Coding MCP Server: Local Gemma 4 powered coding assistant integrated with Zed editor

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages