Skip to main content

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

OpenGround provides an automatic installer for OpenCode:
This command:
  1. Locates your OpenCode config at ~/.config/opencode/opencode.json
  2. Creates a timestamped backup of existing config
  3. Safely merges the OpenGround MCP server configuration
  4. Validates JSON before writing
Success! You should see: “Successfully installed openground to OpenCode!”

Configuration Structure

The installer adds this configuration to opencode.json:

Configuration File Location

OpenCode stores its configuration at:

Manual Installation

If you prefer to manually edit the configuration:
1

Generate Configuration

This displays the JSON without modifying files
2

Locate OpenCode Config

Navigate to ~/.config/opencode/opencode.json
3

Edit Configuration

Add the OpenGround server to the mcp section:
If you have existing MCP servers, add OpenGround alongside them:
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 to openground-mcp if found in PATH:

Transport Protocol

OpenGround uses stdio (standard input/output):
  • OpenCode spawns openground-mcp as a subprocess
  • Communication via stdin/stdout
  • No network ports required

Backup Files

The installer creates timestamped backups before making changes:
Restore from backup if needed:

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 libraries

Using 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:
Verify:

Windows

Add Python Scripts to PATH:
If not found:
  1. Open System Properties → Environment Variables
  2. Add to PATH:
  3. Restart terminal/OpenCode
Run installer:

Advanced Configuration

Disable OpenGround Temporarily

Set enabled 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:
The installer:
  1. Creates a new timestamped backup
  2. Preserves other MCP servers
  3. 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