Opencode Setup
Install Context7 MCP Server in Opencode to access up-to-date documentation and code examples directly in your AI coding assistant.Prerequisites
- Opencode installed and configured
- (Recommended) Free API key from context7.com/dashboard
While Context7 works without an API key, we recommend getting a free API key for higher rate limits.
Installation Methods
Opencode supports both remote and local MCP server connections via its configuration file.- Remote Server (Recommended)
- Local Server
Remote connection uses the hosted Context7 MCP server. No local installation required.
Configuration
Add the following to your Opencode configuration file:Replace
YOUR_API_KEY with your actual API key from context7.com/dashboardBenefits
- No local installation or dependencies
- Always running the latest version
- Reduced system resource usage
- Perfect for teams (consistent configuration)
Configuration File Location
The Opencode configuration file location varies by platform:- Linux:
~/.config/opencode/config.json - macOS:
~/Library/Application Support/opencode/config.json - Windows:
%APPDATA%\opencode\config.json
Automated Setup
Use the Context7 CLI for automated setup:- Authenticates via OAuth
- Generates an API key
- Configures the MCP server in your Opencode config
- Sets up recommended rules
Verify Installation
Add a Rule (Recommended)
To avoid typinguse context7 in every prompt, configure Opencode to automatically invoke Context7 for code-related questions.
Add the following to your Opencode rules configuration:
Advanced Configuration
Conditional Enablement
Enable Context7 only for specific projects:Custom Timeout
For slow network connections, increase the timeout:Multiple Profiles
Configure different Context7 instances for different use cases:Troubleshooting
MCP server not appearing
MCP server not appearing
- Verify JSON syntax in your configuration file
- Check that
"enabled": trueis set - Restart Opencode completely
- Check Opencode logs for error messages
Authentication errors
Authentication errors
- Verify your API key is correct (should start with
ctx7sk) - Ensure the API key is properly formatted in the configuration
- Try regenerating your API key at context7.com/dashboard
- Check that the header name is
CONTEXT7_API_KEY
Local server fails to start
Local server fails to start
- Ensure Node.js is installed:
node --version - Clear npx cache:
npx clear-npx-cache - Test manual execution:
npx -y @upstash/context7-mcp - Check that the command array is properly formatted
Remote connection fails
Remote connection fails
- Verify internet connectivity
- Test the endpoint:
curl https://mcp.context7.com/ping - Check firewall settings
- Ensure proxy settings are configured if required
Rate limit errors
Rate limit errors
- Get a free API key at context7.com/dashboard
- Check your usage on the dashboard
- Consider upgrading to a paid plan at context7.com/plans
Learn More
For more details on Opencode MCP integration:Next Steps
Configuration
Learn about advanced configuration options
Tools Reference
Explore available MCP tools