Blog
Next

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 add

Fill 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

Verification

Once you've saved your settings, verify the connection with:

opencode mcp list