Syntax
Description
Theapp-server command starts Codex as a JSON-RPC server for IDE integrations. This is primarily used by the VS Code extension and other editor plugins.
Most users don’t need to run this command directly. It’s automatically started by IDE extensions like the VS Code Codex extension.
Usage
Start with stdio Transport (Default)
Start with WebSocket Transport
Options
Transport endpoint URL. Supported values:
stdio://- Standard input/output (default)ws://IP:PORT- WebSocket server
stdio://ws://127.0.0.1:4500ws://0.0.0.0:8080
Enable analytics by default. Analytics are disabled for app-server unless explicitly enabled.Users can still opt out in
config.toml:Examples
stdio Transport
WebSocket Transport
IDE Integration
VS Code extension typically starts the app-server automatically:Transport Types
stdio (Default)
When to use:- Single client connections
- VS Code and editor extensions
- Process-based communication
- One client per server instance
- Communicates via stdin/stdout
- Terminates when client disconnects
WebSocket
When to use:- Multiple concurrent clients
- Remote connections
- Web-based interfaces
- Multiple clients per server
- Network-based communication
- Persists after client disconnects
Protocol
The app-server uses JSON-RPC 2.0 over the specified transport. It implements the Codex App Server Protocol v2.Example Request
Example Response
Subcommands
Theapp-server command has experimental subcommands for protocol development:
generate-ts
Generate TypeScript bindings for the app server protocol:Output directory for generated TypeScript files.
Path to Prettier executable for formatting generated files.
Include experimental API methods and fields in generated types.
generate-json-schema
Generate JSON Schema for the app server protocol:Output directory for schema bundle.
Include experimental API surface in generated schema.
Configuration
The app-server respects all standard Codex configuration in~/.codex/config.toml:
Graceful Shutdown
stdio Mode
The server shuts down when stdin closes (client disconnects).WebSocket Mode
The server handles graceful shutdown on Ctrl+C:- Stops accepting new connections
- Waits for running assistant turns to complete
- Disconnects all clients
- Exits
Logging
App-server logs to stderr. Control log level withRUST_LOG:
Troubleshooting
Port Already in Use
If WebSocket port is in use:Connection Issues
For WebSocket connection problems:-
Verify server is running:
-
Test connection:
- Check firewall settings
stdio Issues
For stdio communication problems:- Ensure client is sending JSON-RPC messages
- Check stderr for error logs
- Verify stdin/stdout aren’t being buffered