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:- Query data
- Inspect schema
- Run migrations
- Analyze performance
Cloud Services
Connect to cloud providers:Development Servers
Connect to local or remote development servers:Configuration
Connections can be pre-configured inopencode.json:
Environment Variables
Use environment variables for sensitive credentials:Security
Best Practices
- Use environment variables for all credentials
- Add
.envto.gitignore - Rotate credentials regularly
- Use least-privilege access
- 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
Plugin Connections
Plugins can provide custom connection types:Use Cases
Database Analysis
Cloud Resource Management
API Testing
Connection Lifecycle
- Connect: Establish connection with credentials
- Use: Agent accesses the service as needed
- Persist: Connection remains for the session
- 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
Related Topics
MCP Servers
Install servers with connection capabilities
Plugins
Create custom connection types
Configuration
Pre-configure connections
Commands
Learn about other commands