Ollama CodeAn agentic coding panel for your local Ollama models — a Claude Code / Codex–style chat experience that runs entirely on your machine. Under the hood it runs the open-source OpenCode agent (MIT) — OpenCode 2, embedded in the extension itself — pointed at your Ollama server. You get a real agent — file edits, shell tools, permissions, multi-step reasoning — with no cloud model and no API key. Demo
WhyThe official Claude Code and Codex VS Code extensions are not open source, so they can't be adapted to local models. The agents behind several of them are open, though — and OpenCode in particular can be embedded as a library. This extension runs it inside VS Code behind a native chat panel and fills its model picker with the models you actually have installed. Features
Requirements
Quick start
Beta channelNew features ship to the Marketplace pre-release channel first (odd minor
versions, e.g. Settings
MCP serversThe agent can call tools from MCP (Model Context Protocol) servers — browser automation, databases, issue trackers, docs, and more. OpenCode runs the servers; this extension just gathers them from wherever you've configured them and hands them over. Where servers come fromServers are merged from these sources, in increasing precedence (a later source wins on a name collision):
If you already use MCP with Claude Code or VS Code Copilot, those servers work here with nothing to re-enter. Use Setting up a
|
| Field | Applies to | Notes |
|---|---|---|
command |
local (stdio) | Executable name or path (e.g. npx, uvx, an absolute path). |
args |
local (stdio) | Array of arguments passed to command. |
env |
local (stdio) | Environment variables for the server process. |
type |
both | "http" / "sse" mark a remote server; "stdio" / "local" a local one. Inferred from the fields when omitted (a url ⇒ remote, a command ⇒ local). |
url |
remote (http/sse) | The server endpoint. |
headers |
remote (http/sse) | HTTP headers, e.g. an Authorization token. |
enabled |
both | Set false to keep a server defined but not started. |
${VAR}references inenvvalues,headers, andurlare resolved from the environment before the server launches — keep secrets in your environment, not in the file.- Transports: local (stdio) and remote (http/sse). Both the Claude Code field shape (
command+args) and the VS Code shape are accepted and normalized for you.
Checking status — the /mcp command
Type /mcp in the chat to list your configured servers and their live status:
- 🟢 connected — running and its tools are available
- 🟡 disabled — defined but
"enabled": false - 🔴 failed — couldn't start/connect; the reason is shown (a bad server never blocks the chat)
Each row shows the transport (local/remote) and the command or URL it was configured with.
Notes
- Applying changes. Edits to
ollamaCode.mcpServers(or VS Code'smcpsetting) restart the agent automatically. Edits to the.mcp.json/.vscode/mcp.jsonfiles apply on the next Ollama Code: Restart OpenCode Server (or a window reload). - Mind the context window. Each MCP server adds its tool schemas to every request. Local models have far less context than cloud ones (OpenCode's own system prompt + built-in tools already use ~11k tokens), so enable only the servers you need and raise
ollamaCode.minContextLengthif tools start crowding out the conversation. npx/uvxonPATH. Local servers launched withnpx/uvxneed Node and those tools onPATH. The extension augmentsPATHwith common install locations (Homebrew,~/.local/bin, nvm/fnm, bun, cargo), but if a server shows as failed, check Ollama Code: Show Logs.
How it works
VS Code webview (chat UI)
│ postMessage
▼
Extension host (bridge)
│ in-process calls + event stream
▼
OpenCode 2 engine (@opencode/sdk, embedded)
│ bundled Ollama provider (opencode-provider/ollama.mjs)
▼
Ollama native API (/api/chat with num_ctx + think, local model)
The extension enumerates your installed models with Ollama's REST API
(/api/tags, /api/show, /api/ps) and hands the engine its config in
memory — nothing is written to your workspace or global config. Each model
is declared with its capabilities, its context limit and the matching
num_ctx, through a patched ollama-ai-provider
that speaks Ollama's native /api endpoint. OpenCode's own built-in Ollama
support uses the OpenAI-compatible /v1 endpoint, which cannot carry a
context window (Ollama reloads the model at its default on every /v1
request), so it is never enabled. When you pick a different context window or
pull a new model, the engine is rebuilt before the next message so the window
you chose is the one Ollama runs. Model load/eject uses /api/generate with
keep_alive and options.num_ctx.
Develop from source
npm install
npm run bundle:opencode-sdk # build the embedded engine into opencode-sdk/ for your platform
npm run bundle:provider # bundle the Ollama provider into opencode-provider/ollama.mjs
npm run compile # type-check + bundle (extension + webview)
# then press F5 in VS Code to launch the Extension Development Host
npm run package:vsix:bundled # build a platform .vsix with the engine and provider embedded
The engine is built from @opencode/sdk, pinned to an exact version in
devDependencies: one ES module plus the native modules it needs for the
target platform. Neither it nor the provider bundle is committed. Run both
bundle: scripts once before launching the dev host.
Tests:
npm test # unit tests
npm run test:integration # the live webview in a headless VS Code, against a fake Ollama
npm run test:live # the engine and the provider against a real Ollama
npm run test:e2e # every feature through the real panel, against a real Ollama
test:live -- provider is the proof that the bundled provider works under
OpenCode 2: prompts stream, tools run, the configured num_ctx is what
Ollama loads the model at (/api/ps), thinking switches on and off, and
images reach a vision model.
License
MIT
