Documentation
¶
Overview ¶
Package codex provides an adapter for OpenAI Codex CLI MCP configuration.
Codex uses TOML format instead of JSON, with additional features:
- bearer_token_env_var for OAuth
- enabled_tools / disabled_tools for tool filtering
- startup_timeout_sec / tool_timeout_sec for timeouts
- enabled flag to disable without deleting
File location: ~/.codex/config.toml
Index ¶
- Constants
- func ConfigPath() (string, error)
- func ReadConfig() (*core.Config, error)
- func WriteConfig(cfg *core.Config) error
- type Adapter
- func (a *Adapter) DefaultPaths() []string
- func (a *Adapter) FromCore(cfg *core.Config) *Config
- func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)
- func (a *Adapter) Name() string
- func (a *Adapter) Parse(data []byte) (*core.Config, error)
- func (a *Adapter) ReadFile(path string) (*core.Config, error)
- func (a *Adapter) ToCore(codexCfg *Config) *core.Config
- func (a *Adapter) WriteFile(cfg *core.Config, path string) error
- type Config
- type ServerConfig
Constants ¶
View Source
const ( // AdapterName is the identifier for this adapter. AdapterName = "codex" // ConfigDir is the config directory relative to home. ConfigDir = ".codex" // ConfigFileName is the config file name. ConfigFileName = "config.toml" )
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
ConfigPath returns the default Codex config path.
func WriteConfig ¶
WriteConfig writes to the Codex config file.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements core.Adapter for Codex.
func (*Adapter) DefaultPaths ¶
DefaultPaths returns the default config file paths for Codex.
type Config ¶
type Config struct {
MCPServers map[string]ServerConfig `toml:"mcp_servers"`
}
Config represents the Codex configuration file. This is a partial representation focusing on MCP servers.
type ServerConfig ¶
type ServerConfig struct {
// --- STDIO Server Fields ---
Command string `toml:"command,omitempty"`
Args []string `toml:"args,omitempty"`
Env map[string]string `toml:"env,omitempty"`
EnvVars []string `toml:"env_vars,omitempty"` // Additional env vars to whitelist
Cwd string `toml:"cwd,omitempty"`
// --- HTTP Server Fields ---
URL string `toml:"url,omitempty"`
BearerTokenEnvVar string `toml:"bearer_token_env_var,omitempty"`
HTTPHeaders map[string]string `toml:"http_headers,omitempty"`
EnvHTTPHeaders map[string]string `toml:"env_http_headers,omitempty"` // Header name -> env var name
// --- Tool Control ---
EnabledTools []string `toml:"enabled_tools,omitempty"`
DisabledTools []string `toml:"disabled_tools,omitempty"`
// --- Timeouts ---
StartupTimeoutSec int `toml:"startup_timeout_sec,omitempty"`
ToolTimeoutSec int `toml:"tool_timeout_sec,omitempty"`
// --- State ---
Enabled *bool `toml:"enabled,omitempty"`
}
ServerConfig represents a Codex MCP server configuration.
Click to show internal directories.
Click to hide internal directories.