Short answer: install the official package with opencode plugin @upstash/context7-opencode, restart OpenCode, then run opencode mcp auth context7. Confirm that the server appears with opencode mcp list before asking OpenCode to use Context7 for a specific library.
Context7 retrieves current, version-aware documentation for coding agents. The official OpenCode plugin removes most of the manual MCP configuration and also installs a small skill that tells OpenCode when and how to call the service. That convenience has a privacy trade-off: queries are sent to a hosted Context7 endpoint, so this is not an offline documentation system.
What the official plugin adds
| Item | Verified detail |
|---|---|
| Package | @upstash/context7-opencode |
| Version control | Record the resolved plugin and OpenCode versions before rollout; check the official package source when updating. |
| What it adds | The hosted Context7 MCP connection and a context7-mcp skill |
| Authentication | OAuth by default, with CONTEXT7_API_KEY or a plugin option as fallbacks |
| Licence | MIT |
| Deployment | Start in a disposable project, then review authentication, returned sources and update behaviour. |
The plugin belongs to the official Context7 repository. Check that exact publisher and repository rather than relying on a similar package name. Official provenance does not remove the need to review what a plugin does. Record the package version in team change notes and check the release page before a wide rollout.
Context7 also documents npx ctx7 setup --opencode, which offers CLI or MCP setup. This guide deliberately uses the OpenCode plugin route below. Choose that route once; an additional setup command is not required.
Before you install it
- Install a current OpenCode build and confirm the
opencodecommand works in the same shell you normally use. - Decide whether the plugin belongs in OpenCode’s global configuration or only in one project’s
opencode.json. - Use OAuth unless your organisation specifically manages Context7 API keys.
- Choose a non-sensitive test repository. Context7 queries can contain library names, versions and wording from your prompt.
- Back up an existing OpenCode configuration before editing it manually.
If you are still choosing an agentic coding workflow, compare the site’s Aider guide and GPT Pilot guide. Context7 supplies documentation context; it does not replace a coding agent or determine whether its output is correct.
1. Install the Context7 OpenCode plugin
opencode plugin @upstash/context7-opencode
Close and restart OpenCode after the command completes. OpenCode’s plugin documentation says npm plugins are installed with Bun at startup and cached under ~/.cache/opencode/node_modules/. A restart is therefore part of the installation, not an optional troubleshooting ritual.
If your installed OpenCode version does not recognise the convenience command, use the documented configuration form instead. Add the package name to the plugin array in either the global or project configuration:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@upstash/context7-opencode"]
}The global configuration is normally ~/.config/opencode/opencode.json. A project-level opencode.json affects that project and may be committed to source control. Keep secrets out of both files. If a plugin array already exists, add one entry rather than replacing the rest.
2. Authenticate with OAuth
opencode mcp auth context7
OpenCode should launch a browser-based OAuth flow. Complete it only on the expected Context7 page. OpenCode stores MCP OAuth credentials in ~/.local/share/opencode/mcp-auth.json, so protect that file with your normal user-account permissions and never commit it.
For a managed API key instead, set CONTEXT7_API_KEY in the environment that launches OpenCode. Context7 sends the value in an Authorization header. Do not paste it into a prompt, screenshot it, or store a real key in a repository’s configuration file.
# PowerShell, for the current process only $env:CONTEXT7_API_KEY = "replace-with-your-key" opencode
A process-scoped variable disappears when that shell closes, which is useful for a first test. If your company injects secrets through a password manager or CI system, use that existing mechanism rather than inventing a plaintext startup script.
3. Verify the MCP connection
opencode mcp list
Look for a Context7 entry in a connected or authenticated state. The plugin deliberately leaves an existing MCP server named context7 alone. If you configured that name previously, inspect it before assuming the plugin replaced or repaired it.
Open a disposable project and try one narrow, verifiable request:
Use Context7 to show the documented Next.js 15 middleware setup. Name the documentation version and link the source you used.
For a known library identifier, Context7’s guide gives this style of request:
Use Context7 with /vercel/next.js for App Router setup.
A successful tool call is not proof that generated code is safe or compatible with your project. Compare the cited page with your locked dependency version and run the project’s tests. For broader model selection, see the site’s coding LLM comparison.
What data leaves your computer?
| Data or action | Where it goes | Practical control |
|---|---|---|
| Authentication | Context7’s hosted OAuth service, or its API with your bearer key | Use OAuth where possible; revoke it when no longer needed |
| Documentation query | The hosted Context7 MCP server | Do not include source code, customer data, tokens or undisclosed product names in the query |
| Returned documentation | Back into OpenCode’s context | Use the tool selectively because MCP output consumes context and can influence generated code |
| Project files | Not described as a required bulk upload by the plugin | Still review the actual tool arguments shown by OpenCode before approving calls |
This is a remote service, not an air-gapped documentation mirror. If policy prohibits external query text, do not install it. Use local vendor documentation or a separately approved internal MCP service instead.
Choose project or global scope deliberately
A global plugin is convenient for one developer who wants Context7 available everywhere. It also makes the external tool available in repositories that never asked for it. A project-level entry is easier for a team to review and reproduce, but the configuration becomes part of that repository and should contain only the package name, never a credential.
| Scope | Good fit | Main caution |
|---|---|---|
| Global | Personal machine with one approved policy for all development work | The tool may be offered in sensitive or unrelated projects unless the user notices |
| Project | A team wants a reviewed, reproducible tool list for one repository | The committed configuration reveals the dependency and can surprise contributors who have not approved the hosted service |
For a team pilot, add the package in one non-sensitive repository, document why Context7 is allowed, and ask reviewers to inspect the tool arguments during the first week. Record the plugin version, OpenCode version, authentication method and an owner for removal. Do not enable automatic tool approval simply to make the demonstration smoother.
When a new plugin version appears, read its official release notes before restarting every developer into the update. Re-run the narrow documentation test, confirm OAuth still targets the expected host and compare the MCP tool names and arguments. An update that changes query content, credential handling or endpoint location deserves a fresh privacy review even if its semantic version looks small.
Troubleshooting
| Symptom | Check |
|---|---|
context7 is missing from the MCP list | Restart OpenCode, confirm the package is in the intended configuration, and check that JSON syntax remains valid. |
| OAuth repeatedly fails | Run opencode mcp debug context7, verify system time and browser access, then retry. Do not post the debug output publicly without removing tokens. |
| API key is ignored | Confirm CONTEXT7_API_KEY exists in the environment of the OpenCode process, not only another terminal. |
| The wrong Context7 server is used | An existing server named context7 is preserved. Remove or rename the stale manual definition only after backing up the config. |
| Answers use an unexpected library version | State the version and, where known, the Context7 library identifier. Verify the cited upstream documentation yourself. |
| OpenCode becomes slow or context-heavy | Invoke Context7 only for questions that need current API documentation; disable it for unrelated tasks. |
How to remove Context7 cleanly
First remove the locally stored OAuth credentials while the server is still configured:
opencode mcp logout context7
Then remove @upstash/context7-opencode from the relevant plugin array and restart OpenCode. If you also created a manual Context7 MCP entry or used the separate setup tool, inspect and remove only those Context7-specific entries you intend to disable. If you used an API key, unset it and revoke or rotate the key in Context7 if it is no longer needed. Local OAuth logout removes stored credentials; review any remaining account-side authorization separately. OpenCode’s cache can retain downloaded package files, but deleting the entire cache is not required to disable the plugin and can affect other plugins. Verify removal with opencode mcp list.
Frequently asked questions
Is the Context7 OpenCode plugin free?
The plugin source is MIT-licensed. Service plans, quotas and account terms can change independently, so check Context7’s current account page before designing a team rollout around a particular allowance.
Does Context7 run locally?
Not in this official OpenCode plugin workflow. It connects OpenCode to the hosted Context7 MCP server. Treat query text as data sent to an external service.
Do I need both the plugin and a manual MCP entry?
No. The plugin installs the MCP definition. If a server named context7 already exists, the plugin leaves it unchanged, so keep one intentional configuration and document which one your team supports.
Can I trust code because it came from current documentation?
No. Current documentation reduces stale-API errors, but the agent can still combine examples incorrectly or overlook project constraints. Review diffs, pin dependencies and run tests and security checks.
Official sources
- Official Context7 repository and package source
- Context7’s official OpenCode setup guide
- OpenCode plugin documentation
- OpenCode MCP server and authentication documentation
- Context7 MIT licence
Bottom line: the official package makes Context7 easier to add to OpenCode, and its queries use a hosted service. Start with OAuth in a disposable project, verify every returned source, and remove the plugin and credential if it does not earn a place in your workflow.
Sources reviewed 10 September 2026 against the official documentation linked above. Record versions and validate the workflow in your own environment.