OpenKnowledge

OpenCode

Use OpenKnowledge with OpenCode — including fully local models via Ollama, LM Studio, or any OpenAI-compatible endpoint.

OpenKnowledge plugs into OpenCode through MCP. OpenCode is a terminal-based coding agent that works with any model — cloud or fully local — so you can run an entirely local edit-your-knowledge-base loop.

Install

There are two ways to connect OpenCode, depending on how you run OpenKnowledge:

  • macOS desktop app. The first time you open a project, a consent dialog detects OpenCode and configures it for you. To re-trigger the dialog, delete ~/.ok/mcp-status.json and relaunch.
  • Web app / terminal (Linux, Intel Mac — see the web app guide). Run ok init in your project: it registers the OpenKnowledge MCP server with OpenCode and the other editors it detects. Every ok start refreshes the entry.

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. OpenCode also picks up the OpenKnowledge skill from the shared .agents/skills/ directory automatically.

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, LM Studio, or a self-hosted server in the same opencode.json that holds the OpenKnowledge MCP entry:

{
  "$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, providers, and MCP servers docs for the authoritative provider schema.

Verify

Open the project in OpenCode and ask:

OpenCode should call the OpenKnowledge exec tool and respond with some of your documents.

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.