Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
---
title: OpenCode
description: Use OpenKnowledge with OpenCode.
icon: custom/OpenCode
---
[OpenCode](https://opencode.ai) is an open-source AI coding agent.
## Install
<McpInstall editor="OpenCode" />
OpenCode reads MCP servers from `opencode.json` in the project root, or `~/.config/opencode/opencode.json` for a global install. `ok init` writes the `open-knowledge` server under the top-level `mcp` key in both, using the same resilient launcher every other editor gets. It also installs the OpenKnowledge skill to `.opencode/skills/open-knowledge/`, which OpenCode scans automatically.
OpenKnowledge Beta registers as `open-knowledge-beta` instead; see [Beta uses its own entry](/docs/reference/what-open-knowledge-writes#beta-uses-its-own-entry).
## Use a local model
OpenCode is model-agnostic and talks to any OpenAI-compatible endpoint, so you can pair OpenKnowledge with a model running entirely on your machine — no cloud round-trip. Point OpenCode at [Ollama](https://ollama.com), [LM Studio](https://lmstudio.ai), or a self-hosted server in the same `opencode.json` that holds the OpenKnowledge MCP entry:
```jsonc
{
"$schema": "https://opencode.ai/config.json",
// Added by `ok init` — connects OpenCode to your knowledge base.
"mcp": {
"open-knowledge": { "type": "local", "enabled": true, "command": ["..."] }
},
// Your local model, via any OpenAI-compatible endpoint (Ollama shown).
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "http://localhost:11434/v1" },
"models": { "qwen3-coder:30b": {} }
}
}
}
```
Pick the model in OpenCode with `/models`. **The model must support tool/function calling** — that's how it drives OpenKnowledge's `exec` / `write` / `edit` tools; a chat-only model will connect but never call them. See OpenCode's [models](https://opencode.ai/docs/models/), [providers](https://opencode.ai/docs/providers/), and [MCP servers](https://opencode.ai/docs/mcp-servers/) docs for the authoritative provider schema.
## Verify
Open the project in OpenCode and ask:
<VerifyExec subject="OpenCode" />
If OpenCode doesn't use the OpenKnowledge `exec` tool, restart it so it picks up the new MCP entry, and make sure the model you selected supports tool calling. If it's still missing and `ok init` reported your config was `left unchanged`, OpenKnowledge declined to edit your `opencode.json` for the reason shown in parentheses — an unreadable file, a duplicate `mcp` block, or a config too large to edit safely. Fix that and re-run `ok init`.