Local LLM Gateway
Local LLMs as read-only coding assistants for Claude Code.
Local LLM Gateway exposes a small set of MCP tools that let Claude Code delegate bounded code-analysis tasks to a model running on your machine (or another endpoint you configure). It works with Ollama out of the box and with any server that speaks the OpenAI chat-completions API, such as LM Studio, llama.cpp, vLLM or LiteLLM.
Use Claude Code for orchestration and decision-making, and use the local model for focused, lower-cost work such as source summarization, code analysis, diff review, and test-case suggestions.
Status: Early-stage project. Review the limitations below and verify model-generated suggestions before relying on them.
Why this project?
Claude Code is useful as the primary coding agent, but sending every analysis task to a hosted model can consume tokens quickly. This project adds a separate local inference path without replacing Claude Code's normal authentication or workflow.
- Keep Claude Code connected directly to Anthropic using its supported login.
- Delegate selected tasks to a local model through MCP, whichever server runs it.
- Keep the integration read-only: the tools do not edit source files or execute generated tests.
- Bound workspace access and input size to reduce accidental over-reading.
How it works
You
|
v
Claude Code ----------------------> Anthropic
|
| MCP (stdio)
v
Local LLM Gateway
|
| validated workspace files / Git diff
v
Local model server
(Ollama or OpenAI-compatible)
|
| analysis result
v
Local LLM Gateway ----------------> Claude Code
Claude Code remains the primary agent. It decides when to call an MCP tool, receives the result, and can use that result in its wider reasoning.
The MCP server reads files inside the configured workspace, applies input limits, and sends the selected text to the configured model endpoint. If the model server runs locally, inference is performed on your machine. If you point the endpoint (OLLAMA_BASE_URL or LOCAL_LLM_OPENAI_BASE_URL) at a remote host, the source text is sent to that host.
Authentication boundary
Claude Code uses its normal direct Anthropic login. This project does not extract, store, or proxy Claude Code subscription OAuth credentials through LiteLLM.
The optional LiteLLM configuration is an independent gateway for Ollama and providers configured with separately provisioned API credentials. It is not required for the MCP integration.
Features
| MCP tool | Purpose | Behavior |
|---|
local_analyze(path, question) | Analyze source code against a specific question | Reads a file or directory within the workspace |
local_summarize(path) | Summarize source code | Summarizes purpose, symbols, dependencies, and uncertainties |
local_review_diff() | Review current unstaged Git changes | Reviews the output of git diff in the configured workspace |
local_generate_tests(path) | Suggest tests for source code | Returns test ideas and edge cases; does not create test files |
All tools are read-only. In particular, local_review_diff currently reviews unstaged tracked changes; staged changes and untracked files are not included.
Requirements
- Windows, Linux, or WSL
- Python 3.14.x (the project intentionally rejects other Python versions)
- uv (installs and manages Python 3.14 for you)
- Git
- Claude Code
- A local model server: Ollama (the default) or any OpenAI-compatible server (see Using another LLM server)
The default backend is Ollama with the model qwen2.5-coder:7b. Model quality and inference speed depend on your hardware. A GPU with 6 GB VRAM may not fit the entire model; Ollama can use CPU/RAM offload, which may reduce generation speed.
Quick start
The scripts below set up the default Ollama backend. For LM Studio, llama.cpp, vLLM or another OpenAI-compatible server, run setup and register-mcp as shown, skip install-models, and set the variables in Using another LLM server before launching Claude Code.
Run these commands from the repository root.
Windows (PowerShell)
# Create the virtual environment and install the project
.\scripts\setup.ps1
# Download the default Ollama model (Ollama backend only)
.\scripts\install-models.ps1
# Register the MCP server for the current project workspace
.\scripts\register-mcp.ps1 -Workspace (Get-Location).Path
Linux / WSL (Bash)
# Create the virtual environment and install the project
bash scripts/setup.sh
# Download the default Ollama model (Ollama backend only)
bash scripts/install-models.sh
# Register the MCP server for the current project workspace
bash scripts/register-mcp.sh "$PWD"