codex

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 4 Imported by: 0

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

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

func ConfigPath() (string, error)

ConfigPath returns the default Codex config path.

func ReadConfig

func ReadConfig() (*core.Config, error)

ReadConfig reads the Codex config file.

func WriteConfig

func WriteConfig(cfg *core.Config) error

WriteConfig writes to the Codex config file.

Types

type Adapter

type Adapter struct{}

Adapter implements core.Adapter for Codex.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new Codex adapter.

func (*Adapter) DefaultPaths

func (a *Adapter) DefaultPaths() []string

DefaultPaths returns the default config file paths for Codex.

func (*Adapter) FromCore

func (a *Adapter) FromCore(cfg *core.Config) *Config

FromCore converts canonical config to Codex format.

func (*Adapter) Marshal

func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)

Marshal converts canonical config to Codex TOML format.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter name.

func (*Adapter) Parse

func (a *Adapter) Parse(data []byte) (*core.Config, error)

Parse parses Codex TOML config data into the canonical format.

func (*Adapter) ReadFile

func (a *Adapter) ReadFile(path string) (*core.Config, error)

ReadFile reads a Codex config file.

func (*Adapter) ToCore

func (a *Adapter) ToCore(codexCfg *Config) *core.Config

ToCore converts Codex config to canonical format.

func (*Adapter) WriteFile

func (a *Adapter) WriteFile(cfg *core.Config, path string) error

WriteFile writes canonical config to a Codex TOML format file.

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.

func NewConfig

func NewConfig() *Config

NewConfig creates a new Codex config.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL