How to Add Context7 to OpenCode
A step-by-step guide to fixing AI knowledge cutoffs by connecting Context7 MCP to OpenCode manually or via CLI.
Enhancing OpenCode with Real-Time Documentation 🚀
If you are using OpenCode, you've likely realized that even the most advanced AI models have a "knowledge cutoff." They often suggest deprecated libraries or outdated syntax. To fix this, we use the Model Context Protocol (MCP) with Context7—a bridge that brings the latest documentation directly into your AI's context.
On macOS, setting this up can be tricky because configuration files are hidden. Here is how I solved it using two different methods.
OpenCode provides a built-in helper to guide you. This is the best approach if you want the tool to handle the folder creation for you.
Open your Terminal
Launch your favorite terminal application on your Mac.Run the setup command
Execute the following built-in helper command:opencode mcp addFill in the prompts
When prompted, fill in the details exactly like this:- Name:
context7 - Command:
npx - Arguments:
-y @upstash/context7-mcp@latest --api-key YOUR_API_KEY
Why Choose "Local" over "Remote"? In both methods, we set the type to
local. This runs the MCP server directly on your Mac using stdio (Standard
Input/Output). It's faster, more secure, and allows the AI to "talk" to the
server without needing to host a separate web service.
Verification
Once you've saved your settings, verify the connection with:
opencode mcp list