Use opencode with a Local AMD LLM (ROCm): Config & MCP Tools
opencode can run entirely on your local AMD GPU. Here's a copy-paste opencode.json that wires it to your llama-swap model and the stack's MCP tools.
opencode is a terminal AI coding agent that speaks the OpenAI-compatible API — so it can drive your local model on an AMD GPU instead of a paid cloud API. Point it at llama-swap, add the stack's MCP tool servers, and your coding agent runs entirely on your own hardware.
Drop-in opencode config
Save this as ~/.config/opencode/opencode.json (global) or opencode.json in your project root:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ai-stack": {
"npm": "@ai-sdk/openai-compatible",
"name": "ai-stack (local AMD / ROCm)",
"options": {
"baseURL": "http://localhost:8080/v1",
"apiKey": "sk-local"
},
"models": {
"qwen3.8-27b-heretic": {
"name": "Qwen3.8-27B (local, ROCm)",
"limit": { "context": 131072, "output": 32768 }
}
}
}
},
"mcp": {
"web-search": { "type": "remote", "url": "http://localhost:8765/mcp" },
"browser": { "type": "remote", "url": "http://localhost:8931/mcp" }
}
}
baseURL points at llama-swap's local OpenAI endpoint; apiKey is just a non-empty placeholder. Swap the model id for whatever your stack serves (curl localhost:8080/v1/models).What each part does
- provider.ai-stack — registers your local llama.cpp/llama-swap server as an OpenAI-compatible provider via
@ai-sdk/openai-compatible. - options.baseURL —
http://localhost:8080/v1, the llama-swap endpoint (ROCm under the hood). - models — the local model(s) and their context/output limits.
- mcp — remote MCP tool servers from the stack (web search on 8765, headless browser on 8931). Add more, e.g. a sandboxed shell on
http://localhost:8099/mcp.
Run it
# make sure the stack is up
systemctl --user start ai-stack.service
# then just run opencode in your project
opencode
Pick the ai-stack provider/model in opencode and your coding agent is now local, private, and CUDA-free. MCP tools you listed are available to the agent automatically.
Technical FAQ
Can opencode use a local LLM instead of a cloud API?
Yes. opencode supports any OpenAI-compatible endpoint. Point its provider baseURL at a local llama.cpp/llama-swap server (e.g. http://localhost:8080/v1) and it runs fully offline.
How do I connect opencode to a local model on an AMD GPU?
Add a provider using @ai-sdk/openai-compatible with baseURL set to your llama-swap endpoint, and list your model ids. The model runs on AMD ROCm; opencode doesn't care about the GPU vendor.
Does opencode need an API key for a local model?
No real key is needed, but the field must be non-empty — use a placeholder like sk-local. The request never leaves your machine.
How do I give opencode tools like web search or a browser?
Register MCP servers in the mcp section of opencode.json with type remote and the server URL (e.g. web search on http://localhost:8765/mcp, a headless browser on http://localhost:8931/mcp).
Which model should I use with opencode locally?
Any instruct/coding model your stack serves. A 27B at Q6_K runs well on a 32GB AMD card; a smaller coder model is faster for autocomplete. List whatever curl localhost:8080/v1/models returns.