For more details on MCP server configuration in OpenCode, see the OpenCode MCP documentation.
Installation
- Remote Server (Recommended)
- Local Server
No dependencies required. Connects to Context7’s hosted server.
1
Open your OpenCode config
Create or edit
opencode.json in your project root, or ~/.config/opencode/opencode.json for global config. See the OpenCode config docs for more details.2
Add Context7 MCP server
Add the Context7 MCP server to the
mcp section:- With API Key (Recommended)
- With OAuth
- Without API Key
Add this to your config file:
Using Context7
Add “use context7” to your prompts to fetch current documentation:AGENTS.md file for automatic Context7 usage:
AGENTS.md
Tips
Getting Better Results
Getting Better Results
- Be specific about what you’re trying to do, not just which library
- Mention versions when they matter
- If the first result isn’t right, ask for a different part of the docs
Project-Level Configuration
Project-Level Configuration
You can place your
opencode.json in your project directory to have project-specific configurations. This is useful when:- Different projects need different API keys
- You want to share the config with your team via version control
- A project requires specific Context7 settings