Skip to main content

Overview

The /connect command (when available through plugins or MCP servers) allows you to establish connections to external services during an OpenCode session. This enables real-time access to:
  • Cloud resources (AWS, GCP, Azure)
  • Databases (PostgreSQL, MySQL, MongoDB)
  • APIs and webhooks
  • Development servers
  • Remote machines
The /connect command is provided by plugins or MCP servers. Available connection types depend on your installed integrations.

Usage

Examples

Database Connections

Connect to a database:
Once connected, the agent can:
  • Query data
  • Inspect schema
  • Run migrations
  • Analyze performance

Cloud Services

Connect to cloud providers:
Requires appropriate credentials (environment variables, config files, or IAM roles).

Development Servers

Connect to local or remote development servers:

Configuration

Connections can be pre-configured in opencode.json:
Then connect by name:

Environment Variables

Use environment variables for sensitive credentials:
Reference in configuration:

Security

Never commit credentials to version control. Use environment variables or secure credential stores.

Best Practices

  1. Use environment variables for all credentials
  2. Add .env to .gitignore
  3. Rotate credentials regularly
  4. Use least-privilege access
  5. Enable MFA where available

Credential Storage

OpenCode respects standard credential chains:
  • AWS: ~/.aws/credentials, IAM roles, environment variables
  • GCP: Application Default Credentials, service accounts
  • Azure: Azure CLI credentials, managed identities
  • Databases: Connection strings, environment variables

MCP Server Connections

Many MCP servers provide connection capabilities:

Filesystem

GitHub

Slack

Google Drive

See each MCP server’s documentation for specific connection syntax.

Plugin Connections

Plugins can provide custom connection types:
Then use:

Use Cases

Database Analysis

Cloud Resource Management

API Testing

Connection Lifecycle

  1. Connect: Establish connection with credentials
  2. Use: Agent accesses the service as needed
  3. Persist: Connection remains for the session
  4. Disconnect: Automatic cleanup on session end

Troubleshooting

Connection Failed

Problem: Cannot connect to service Solutions:
  • Verify credentials are correct
  • Check network connectivity
  • Ensure service is running
  • Review firewall rules
  • Check permission/IAM policies

Authentication Error

Problem: Credentials rejected Solutions:
  • Verify credentials haven’t expired
  • Check credential format
  • Ensure correct environment variables are set
  • Test credentials outside OpenCode

Command Not Available

Problem: /connect command not found Solutions:
  • Install an MCP server that provides connections
  • Add a plugin with connection support
  • Check that the server/plugin is properly configured

MCP Servers

Install servers with connection capabilities

Plugins

Create custom connection types

Configuration

Pre-configure connections

Commands

Learn about other commands