Skip to content

OpenCode Connection Guide

This guide describes how to connect OpenCode to SnatchArr's Model Context Protocol (MCP) server.


Protocol and Transport

SnatchArr exposes a native Model Context Protocol server over two transports:

  • Streamable HTTP: http://localhost:8080/api/v1/mcp (sessionless JSON-RPC 2.0).
  • Subprocess stdio: snatcharr mcp stdio (or docker exec -i -e SNATCHARR_URL -e SNATCHARR_API_KEY <container> /snatcharr-api mcp stdio for container deployments), a thin proxy that delegates to /api/v1/mcp via SNATCHARR_URL and SNATCHARR_API_KEY.

Authentication and Prerequisites

Connecting to SnatchArr requires:

  1. Enabling the MCP server on the settings page (/settings) via the Enable MCP server (/api/v1/mcp) toggle.
  2. Generating a scoped bearer API key on the account page (/account) under the API keys section.

See Module Toggle Switch and Authentication and Permission Scopes for full scope descriptions, challenge behavior, and write-tool activation instructions.

Export the connection environment variables in your shell:

export SNATCHARR_URL="http://localhost:8080"
export SNATCHARR_API_KEY="your-snatcharr-api-key"

Client Configuration

OpenCode supports configuring MCP servers via opencode.json (or opencode.jsonc) or via the opencode mcp CLI.

Option A: Subprocess stdio Transport

To compile and install the host snatcharr CLI binary, see Install the proxy.

Configuration File (opencode.json)

Add the local proxy server under the mcp key in ~/.config/opencode/opencode.json (global) or opencode.json (workspace):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "snatcharr": {
      "type": "local",
      "command": "snatcharr",
      "args": ["mcp", "stdio"],
      "enabled": true,
      "env": {
        "SNATCHARR_URL": "http://localhost:8080",
        "SNATCHARR_API_KEY": "{env:SNATCHARR_API_KEY}"
      }
    }
  }
}

For containerized deployments:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "snatcharr": {
      "type": "local",
      "command": "docker",
      "args": ["exec", "-i", "-e", "SNATCHARR_URL", "-e", "SNATCHARR_API_KEY", "snatcharr-api", "/snatcharr-api", "mcp", "stdio"],
      "enabled": true,
      "env": {
        "SNATCHARR_URL": "http://localhost:8080",
        "SNATCHARR_API_KEY": "{env:SNATCHARR_API_KEY}"
      }
    }
  }
}

CLI Helper

Register the stdio server using the CLI:

opencode mcp add snatcharr --command snatcharr --args mcp,stdio --env SNATCHARR_URL="http://localhost:8080" --env SNATCHARR_API_KEY="${SNATCHARR_API_KEY}"

Option B: Streamable HTTP Transport

Configuration File (opencode.json)

Add the remote server:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "snatcharr": {
      "type": "remote",
      "url": "http://localhost:8080/api/v1/mcp",
      "enabled": true,
      "headers": {
        "Authorization": "Bearer {env:SNATCHARR_API_KEY}"
      }
    }
  }
}

[!IMPORTANT] OpenCode's {env:VARIABLE_NAME} syntax interpolates the secret from your environment dynamically at runtime. Never place raw bearer credentials into the JSON configuration file.

CLI Helper

Register the remote MCP server using the CLI:

opencode mcp add snatcharr --url http://localhost:8080/api/v1/mcp --header 'Authorization=Bearer {env:SNATCHARR_API_KEY}'

[!IMPORTANT] Single quotes around 'Authorization=Bearer {env:SNATCHARR_API_KEY}' are mandatory. Single quotes protect the {env:...} block from premature shell expansion or brace interpretation, ensuring the literal template string is written to opencode.json for OpenCode to resolve at runtime.


Agent Skills Installation

SnatchArr provides an official Agent Skills bundle complying with the agentskills.io standard at skills/snatcharr/ in the repository root (ADR-0021 section 8).

Copy the skill definition into your OpenCode skills directory:

  • Global user path: ~/.config/opencode/skills/snatcharr/SKILL.md or ~/.agents/skills/snatcharr/SKILL.md (verified in https://opencode.ai/docs/skills)
  • Workspace project path: .opencode/skills/snatcharr/SKILL.md or .agents/skills/snatcharr/SKILL.md (verified in https://opencode.ai/docs/skills)
# Global installation
mkdir -p ~/.config/opencode/skills/snatcharr
cp -r skills/snatcharr/* ~/.config/opencode/skills/snatcharr/

# Or workspace installation
mkdir -p .opencode/skills/snatcharr
cp -r skills/snatcharr/* .opencode/skills/snatcharr/

Verification

To verify the connection and list available tools:

  1. Run the CLI tool verification command:
opencode mcp list
  1. Confirm that snatcharr reports an active status and that standard read tools are listed:
  2. snatcharr_get_system_status
  3. snatcharr_list_instances
  4. snatcharr_list_runs
  5. snatcharr_get_hourly_caps

Official Documentation References