Client recipes

OpenAI Codex with Stable Baseline.

Set up Stable Baseline's MCP server in OpenAI Codex so its agent can generate and maintain living documentation for your codebase — all driven from the CLI.

Before you begin

You'll need a Stable Baseline API key. Visit the MCP setup guide to create one from your workspace settings. Keys are prefixed sta_… and shown only once.

Step 1 · Export your API key

Codex reads bearer tokens from your environment at runtime — the token itself never sits in a config file. Add the export to your shell profile (~/.bashrc, ~/.zshrc, etc.):

Shell profilebash
export STABLE_BASELINE_API_KEY="sta_your_api_key_here"

Step 2 · Option A: via the Codex CLI (recommended)

Terminalbash
codex mcp add sb \
  --url "https://api.stablebaseline.io/functions/v1/cloud-serve/mcp" \
  --bearer-token-env-var STABLE_BASELINE_API_KEY

Verify the server was added:

Terminalbash
codex mcp list

Step 2 · Option B: edit the config file directly

Open (or create) the config at ~/.codex/config.toml and add:

config.tomltoml
[mcp_servers.sb]
url = "https://api.stablebaseline.io/functions/v1/cloud-serve/mcp"
bearer_token_env_var = "STABLE_BASELINE_API_KEY"
http_headers = {}
startup_timeout_sec = 30
tool_timeout_sec = 60
enabled = true

bearer_token_env_var takes a name, not a value

The bearer_token_env_var field takes the name of the environment variable (not the token itself). Codex reads the value from your environment at runtime.

After adding the server, restart Codex or start a new session. The server will connect automatically.

Step 3 · Generate your documentation

Once the MCP server is connected, start Codex and type:

Codexprompt
Run the sb-setup prompt from the sb server

Codex walks you through an interactive setup process to generate documentation for your project.

What sb-setup does — the 9-step process

  • Verifies MCP connection — Confirms the Stable Baseline server is reachable and authenticated
  • Resolves workspace & project — Finds or creates your Stable Baseline workspace and project
  • Scans your codebase — Analyses project structure, tech stack, dependencies, and architecture
  • Checks for existing docs — Detects if documentation already exists in Stable Baseline and offers to augment, replace, or cancel
  • Creates folder structure — Organises documentation into logical folders matching your codebase
  • Generates documents — Writes comprehensive docs for each area of your codebase
  • Adds diagrams — Creates architecture and flow diagrams using Mermaid, PlantUML, or other supported formats
  • Configures AGENTS.md — Adds auto-sync rules to your project's AGENTS.md file (augments existing content — never removes what's already there)
  • Summary & next steps — Provides a summary of everything created with links to view in Stable Baseline

What gets documented

  • Architecture — High-level system design, component relationships, data flow
  • API & Integrations — Endpoints, external services, authentication flows
  • Data Model — Database schemas, relationships, migrations
  • Frontend — Component hierarchy, state management, routing
  • Backend — Server logic, middleware, business rules
  • DevOps — Build pipeline, deployment, environment configuration
  • Auth & Identity — Authentication, authorisation, user management

The exact structure is determined dynamically based on your codebase — no two projects get the same output.

How auto-sync works

After setup, your AGENTS.md file contains rules that tell Codex when to update documentation:

File patternDocumentation impactAction
src/components/**UI components and patternsUpdate "Frontend Patterns"
src/lib/api/**API client and integrationsUpdate "API & Integrations"
supabase/migrations/**Database schema changesUpdate "Data Model"
src/hooks/**Custom hooks and state logicUpdate "Frontend Patterns"

Whenever Codex modifies files matching these patterns, it automatically updates the corresponding Stable Baseline documentation via the sb-sync prompt.

File structure

text
Your Stable Baseline Project
├── Architecture/
│   ├── High Level Overview
│   └── System Architecture Diagram
├── Frontend/
│   ├── Component Hierarchy
│   ├── State Management
│   └── Routing & Navigation
├── Backend/
│   ├── API Endpoints
│   ├── Business Logic
│   └── Middleware & Auth
├── Data Model/
│   ├── Database Schema
│   └── Entity Relationships
└── DevOps/
    ├── Build & Deploy
    └── Environment Config

This is an example. Your actual structure will be tailored to your specific project.

Try it

Once setup is complete, try these prompts in Codex:

Document the authentication flow in our API.

Add a sequence diagram showing the checkout process.

Update the database schema docs after the latest migration.

Create a new doc explaining our caching strategy.

Regenerate documentation

To regenerate your entire documentation from scratch:

Codexprompt
Run the sb-setup prompt from the sb server

Setup will detect existing documentation and ask whether you want to augment (add to existing), replace (start fresh), or cancel.

Managing MCP servers

Codex provides CLI commands to manage your MCP server connections:

Terminalbash
# List all configured servers
codex mcp list

# View details of a specific server
codex mcp get sb

# Remove a server
codex mcp remove sb

Other prompts available

PromptDescription
sb-setupFull project onboarding — scans codebase, creates docs, configures auto-sync
sb-syncSync AGENTS.md rules — augments existing content, never removes
sb-create-docCreate a new document in Stable Baseline
sb-create-diagramCreate a diagram (Mermaid, PlantUML, BPMN, GraphViz, etc.)
sb-edit-docEdit an existing document with targeted patches
sb-manage-imagesUpload, update, or delete images in documents
sb-manage-dataManage data files for Vega/Vega-Lite statistical visualisations