OpenCode Integration
Integrate OpenGround with OpenCode to search documentation during your AI-assisted development sessions.Prerequisites
1
Install OpenGround
2
Add Documentation
Index at least one library:
3
Install OpenCode
Download from opencode.sh
Installation
Automatic Installation (Recommended)
OpenGround provides an automatic installer for OpenCode:- Locates your OpenCode config at
~/.config/opencode/opencode.json - Creates a timestamped backup of existing config
- Safely merges the OpenGround MCP server configuration
- Validates JSON before writing
Success! You should see: “Successfully installed openground to OpenCode!”
Configuration Structure
The installer adds this configuration toopencode.json:
Configuration File Location
OpenCode stores its configuration at:- macOS
- Linux
- Windows
Manual Installation
If you prefer to manually edit the configuration:1
Generate Configuration
2
Locate OpenCode Config
Navigate to
~/.config/opencode/opencode.json3
Edit Configuration
Add the OpenGround server to the If you have existing MCP servers, add OpenGround alongside them:
mcp section:4
Validate JSON
Ensure proper syntax (no trailing commas, quotes, etc.)
Configuration Details
OpenCode MCP Schema
OpenCode’s MCP configuration differs slightly from other clients:Command Resolution
The installer uses the full path toopenground-mcp if found in PATH:
Transport Protocol
OpenGround uses stdio (standard input/output):- OpenCode spawns
openground-mcpas a subprocess - Communication via stdin/stdout
- No network ports required
Backup Files
The installer creates timestamped backups before making changes:Verification
1
Restart OpenCode
Completely quit and restart OpenCode
2
Check MCP Status
In OpenCode settings or console, verify OpenGround MCP is connected
3
Test Tools
Ask OpenCode: “What documentation is available in openground?”OpenCode should call
list_libraries_tool and display your indexed librariesUsing OpenGround in OpenCode
Automatic Tool Invocation
OpenCode will automatically use OpenGround when appropriate:Explicit Documentation Searches
Request specific documentation searches:Combining Code and Docs
OpenCode can analyze your code alongside documentation:Platform-Specific Configuration
macOS
No additional configuration needed. Works out of the box.Linux
Ensure pip’s bin directory is in PATH:Windows
- Native Windows
- WSL
Add Python Scripts to PATH:If not found:
- Open System Properties → Environment Variables
- Add to PATH:
- Restart terminal/OpenCode
Advanced Configuration
Disable OpenGround Temporarily
Setenabled to false without removing the configuration:
Use Specific Virtual Environment
Point to a specific Python environment:Environment Variables
Pass custom environment variables:Multiple OpenGround Instances
Run separate instances with different databases:Troubleshooting
Configuration Not Applied
1
Verify File Location
Confirm
opencode.json exists at ~/.config/opencode/2
Check JSON Syntax
Validate with:
3
Restart OpenCode Completely
Quit entirely (not just close window), then restart
Invalid JSON Error
If OpenCode reports JSON errors:Permission Denied
Fix file permissions:Command Not Found
1
Verify Installation
2
Use Full Path
Edit
opencode.json with full path:3
Check PATH
Ensure Python bin/Scripts directory is in PATH
MCP Server Not Starting
Debug the server:No Search Results
Verify documentation:Updating Configuration
Re-run the installer to update:- Creates a new timestamped backup
- Preserves other MCP servers
- Updates only OpenGround configuration
Next Steps
Add Libraries
Index more documentation sources
Configure Search
Customize embedding models and retrieval
MCP Overview
Learn about MCP architecture
Custom Agents
Use with other MCP clients