OpenCodeAgent class

OpenCode agent implementation

OpenCode uses a different config format than Claude Code.

  • Config path: .opencode/mcp_config.json
  • Config format: Uses servers instead of mcpServers
Inheritance

Constructors

OpenCodeAgent()

Properties

configPath String
Config file path relative to project root
no setteroverride
defaultMcpConfig Map<String, dynamic>
Get default MCP configuration structure
no setteroverride
displayName String
Display name for UI
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
mcpConfigKey String
Get key for MCP configuration (usually 'mcpServers')
no setteroverride
name String
Agent name (e.g., 'claude-code', 'opencode')
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedFileTypes List<String>
List supported file types
no setteroverride
userConfigPath String?
Config file path relative to user home (optional)
no setteroverride

Methods

detectByCommand(String command) Future<bool>
Detect if agent is installed on system using command
inherited
detectByFiles(String basePath, Map<String, dynamic> config) Future<bool>
Detect if agent is in project by checking files/directories
inherited
generateMcpConfig(ServerPodProject project) Map<String, dynamic>
Generate MCP config for this agent
override
getConfigPath(String projectRoot) String
Get absolute path to config file
inherited
getUserConfigPath() String?
Get absolute path to user config file (if applicable)
inherited
isInProject(String basePath) Future<bool>
Check if agent is used in the current project
override
isInstalled() Future<bool>
Check if agent is installed on the system
override
mergeConfig(Map<String, dynamic> existing, Map<String, dynamic> generated) Map<String, dynamic>
Merge new config with existing config
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
projectDetectionConfig() Map<String, dynamic>
Get detection config for project-specific detection
override
systemDetectionConfig() Map<String, dynamic>
Get detection config for system-wide installation
override
toString() String
A string representation of this object.
inherited
writeMcpConfig(ServerPodProject project, Map<String, dynamic> config) Future<void>
Write MCP config to project
override
writeMcpConfigToFile(String configFilePath, Map<String, dynamic> config) Future<void>
Write MCP configuration to file
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited