Installation
Running the Server
STDIO Transport Mode
HTTP Streaming Transport Mode
Available Tools
The server provides the following tools for OCI CLI interaction:| Tool Name | Description |
|---|---|
get_oci_command_help | Get help and instructions for running an OCI CLI command |
run_oci_command | Execute an OCI CLI command |
get_oci_commands (Resource) | Get helpful information on various OCI services and related commands |
Important: When using these tools, only provide the command after ‘oci’, do not include the string ‘oci’ in your command.For example:
- Correct:
compute instance list - Incorrect:
oci compute instance list
Usage Examples
Get Command Help
oci compute instance list command including required parameters and examples.
Run OCI Commands
oci compute instance list --compartment-id ocid1.compartment.oc1..example
oci compute instance get --instance-id ocid1.instance.oc1.phx.example
Get Service Information
Understanding the OCI CLI
What is OCI CLI?
The Oracle Cloud Infrastructure Command Line Interface (CLI) is a unified tool for managing OCI resources:- Comprehensive - Covers all OCI services
- Scriptable - Automate cloud operations
- Cross-Platform - Windows, macOS, Linux
- JSON Output - Easy to parse programmatically
Command Structure
Common Services
Computeoci compute instance- Manage instancesoci compute image- Manage imagesoci compute shape- List available shapes
oci network vcn- Manage VCNsoci network subnet- Manage subnetsoci network security-list- Manage security lists
oci iam compartment- Manage compartmentsoci iam user- Manage usersoci iam group- Manage groups
oci os bucket- Manage object storage bucketsoci os object- Manage objectsoci bv volume- Manage block volumes
oci db autonomous-database- Manage Autonomous Databasesoci db system- Manage DB systemsoci db database- Manage databases
Authentication
The server uses OCI CLI configuration from~/.oci/config:
- OCI CLI installed
- Valid API credentials configured
- Appropriate IAM permissions
Required Permissions
Permissions depend on the specific commands being executed. For example: Compute Operations:Common Use Cases
Ad-Hoc Queries
- Quick resource lookups
- Verify configurations
- Check resource states
- Gather information for troubleshooting
Automation Scripts
- Build deployment scripts
- Automate resource provisioning
- Implement CI/CD pipelines
- Schedule maintenance tasks
Troubleshooting
- Debug connectivity issues
- Verify resource configurations
- Check service status
- Investigate errors
Resource Management
- Bulk operations
- Cross-service operations
- Complex workflows
- Custom integrations
Reporting
- Generate resource inventories
- Export configurations
- Collect metrics
- Create audit reports
Best Practices
Command Construction
- Use clear, specific commands
- Include all required parameters
- Use
--helpto verify syntax - Test commands in non-production first
Error Handling
- Check command exit codes
- Parse error messages
- Implement retries for transient failures
- Log command execution
Security
- Never hardcode credentials
- Use IAM policies for access control
- Audit command execution
- Sanitize sensitive output
- Use —profile for different credentials
Output Processing
- Use
--queryto filter JSON output - Pipe to jq for advanced JSON processing
- Format output for readability
- Save outputs for audit trail
Performance
- Use pagination for large result sets
- Parallel execution for independent operations
- Cache frequently accessed data
- Minimize API calls
Advanced Usage
JSON Querying
Output Formatting
Using Profiles
Pagination
Troubleshooting
Command Not Found
Check:- OCI CLI is installed
- CLI is in system PATH
- Command syntax is correct
- Service name is valid
Authentication Errors
Error: NotAuthenticated- Verify OCI config file exists (~/.oci/config)
- Check API key is valid
- Ensure private key file exists and is readable
- Verify correct profile is being used
Permission Denied
Error: NotAuthorizedOrNotFound- Check IAM policies grant required permissions
- Verify you’re in correct compartment
- Ensure resource exists
- Confirm region is correct
Invalid Parameters
Error: Missing option / Invalid value- Use
--helpto check required parameters - Verify parameter format (especially OCIDs)
- Check for required vs optional parameters
- Ensure values meet constraints
Timeout Issues
- Check network connectivity
- Verify OCI service status
- Increase timeout if needed
- Retry the operation
Integration Patterns
Scripting
CI/CD Integration
Monitoring Scripts
CLI vs SDK
Use CLI when:- Quick ad-hoc operations
- Shell scripting
- Interactive exploration
- Simple automation
- Complex application logic
- Need programmatic control
- Error handling is critical
- Building production applications
Related Services
- OCI Cloud - SDK-based API access
- All other OCI servers - Service-specific tools
