- Add plugin to OpenCode config (
~/.config/opencode/opencode.jsonc):
- Create Toolbox config (
~/.config/opencode/toolbox.jsonc):
{
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
"mcp": {
"time": {
"type": "local",
"command": ["npx", "-y", "@anthropic/mcp-time"]
}
}
}Note: The config file is auto-created with default settings if it doesn't exist when the plugin loads.
- Default:
~/.config/opencode/toolbox.jsonc - Custom: Set
OPENCODE_TOOLBOX_CONFIGenvironment variable
{
// JSON Schema for editor support (optional, recommended)
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
// MCP servers to manage (required)
"mcp": {
// Local MCP server (stdio)
"gmail": {
"type": "local",
"command": ["npx", "-y", "@anthropic/mcp-gmail"],
"environment": {
"GMAIL_CREDENTIALS": "{env:GMAIL_CREDENTIALS}"
}
},
// Remote MCP server (SSE)
"weather": {
"type": "remote",
"url": "https://mcp.example.com/weather",
"headers": {
"Authorization": "Bearer {env:WEATHER_API_KEY}"
}
}
},
// Optional settings
"settings": {
"defaultLimit": 5, // Default number of search results (1-20)
"initMode": "eager", // "eager" (default) or "lazy"
"connection": {
"connectTimeout": 5000, // Connection timeout in ms
"requestTimeout": 30000, // Request timeout in ms
"retryAttempts": 2, // Retry attempts on failure
"retryDelay": 1000 // Delay between retries in ms
}
}
}Runs MCP server as a child process via stdio:
{
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
"mcp": {
"my-server": {
"type": "local",
"command": ["npx", "-y", "@anthropic/mcp-server"],
"environment": {
"API_KEY": "{env:MY_API_KEY}"
}
}
}
}Connects to MCP server via HTTP/SSE:
{
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
"mcp": {
"my-remote": {
"type": "remote",
"url": "https://mcp.example.com/sse",
"headers": {
"Authorization": "Bearer {env:API_KEY}"
}
}
}
}Use {env:VAR_NAME} pattern to reference environment variables:
{
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
"mcp": {
"github": {
"type": "local",
"command": ["npx", "@anthropic/mcp-github"],
"environment": {
"GITHUB_TOKEN": "{env:GITHUB_TOKEN}"
}
}
}
}If the environment variable doesn't exist, it will be replaced with an empty string.
Add $schema to your config for editor autocompletion and validation:
{
"$schema": "https://unpkg.com/opencode-toolbox@latest/toolbox.schema.json",
"mcp": { ... }
}The @latest tag auto-updates when new versions are published to npm. To pin a specific version:
https://unpkg.com/opencode-toolbox@0.8.0/toolbox.schema.json
JSONC Support: The schema includes
allowTrailingCommasandallowCommentsextensions for VS Code and Neovim (jsonls). Editors will not warn about trailing commas or comments in.jsoncfiles referencing this schema.
| Setting | Type | Default | Description |
|---|---|---|---|
defaultLimit |
number | 5 | Default number of search results (1-20) |
initMode |
"eager" | "lazy" | "eager" | When to connect to MCP servers (see below) |
connection.connectTimeout |
number | 5000 | Connection timeout in milliseconds |
connection.requestTimeout |
number | 30000 | Request timeout in milliseconds |
connection.retryAttempts |
number | 2 | Number of retry attempts on failure (0-10) |
connection.retryDelay |
number | 1000 | Delay between retries in milliseconds |
eager(default): Start connecting to MCP servers immediately when the plugin loads. Connections happen in the background and don't block plugin startup. First search/execute may wait briefly if servers haven't finished connecting.lazy: Only connect to servers when the first tool is used. Reduces startup overhead but adds latency to the first operation.
// Wrong - will cause errors
{
"servers": {
"time": { ... }
}
}// Correct - use "mcp"
{
"mcp": {
"time": { ... }
}
}// Wrong - trailing comma in arrays breaks some parsers
{
"mcp": {
"time": {
"type": "local",
"command": ["npx", "-y", "@anthropic/mcp-time",] // <-- trailing comma
}
}
}Note: JSONC allows trailing commas, but ensure your file has the .jsonc extension.
- Check file exists:
ls ~/.config/opencode/toolbox.jsonc - Verify JSON syntax:
cat ~/.config/opencode/toolbox.jsonc | bun -e "console.log(JSON.parse(await Bun.stdin.text()))" - Check OpenCode logs for plugin errors
- Verify server command works standalone:
npx -y @anthropic/mcp-time - Check environment variables are set
- For remote servers, verify URL is accessible
- Verify at least one server is configured
- Check server is connecting (no errors in logs)
- Try broader search terms
{ "plugin": ["opencode-toolbox"] }