Connect Codex
Use the Twin CLI from Codex, with MCP as an optional integration.
Codex can call the Twin CLI directly. This is the recommended setup for the app, CLI, and IDE extension because browser OAuth and credentials stay outside the repository.
What you need
- Node.js 20 or newer for the public
twinpackage; - a browser where you can sign in to MLX; and
- at least one accessible channel or other routed Twin context.
Copy this into Codex
Connect this Codex host to my organisation's Twin for approved questions.
Read the live Codex and CLI guides before setup:
- https://docs.mlx.systems/docs/connect/codex
- https://docs.mlx.systems/docs/connect/cli
Use those guides if installation, sign-in, or a command is unclear. After
installation, treat `twin help --json` as the exact contract for that installed
CLI version.
First run `command -v twin`. If it is missing, follow the official Twin CLI
guide and install the public GitHub Release globally. Do not request a GitHub
account or token, use `npx`, add the CLI to this repository, install a similarly
named package, or use `sudo`.
Verify the global command with `command -v twin` and `twin help --json`. It must
work outside this repository. If npm installed it but the command is not on
`PATH`, fix the current user's persistent shell `PATH` without overwriting
unrelated configuration, then tell me to restart Codex so it inherits the new
`PATH`. Do not continue until the global command works.
Run `twin login` and let me complete browser sign-in. Do not request SSH,
Tailscale, a tenant or organisation ID, an API key, or a token. Never ask me to
paste a password, client secret, or cookie.
Use the `twin help --json` result as the current command contract. List accessible
organisations with `twin organisations --json`, run `twin status --json`, and
tell me which organisation is current. If several are available, ask me which
one to use; never guess. Switch with `twin organisations --use` without logging
in again, confirm with `twin status --json`, then list channels with `twin
channels --json`. List recent sessions with `twin sessions --json`; use their
title, ID, canonical owner ID, and most-recent-first order to select a relevant
conversation, then read it with `twin sessions --session <id> --json`. Use
`twin artifacts --session <id>` and `twin artifacts --artifact <id>` when its
artifacts are relevant. Do not infer a session transcript from a channel feed
thread, and do not request internal prompts, tools, events, or reasoning.
Verify with one real routed `twin query --stream --client-app codex`, explaining its queued and
running status before presenting the terminal result and reporting its
query/task/session IDs. Use a
deterministic intent only with inspected fields; never submit raw SQL or guess
internal product or relation names. Read channel feeds and flat threads in
small pages when useful. List channel members before using canonical mention
IDs. Add a channel post, comment, reaction, record, view update, or artifact
creation/update only after I approve the exact mutation and content, and use
`--allow-write`. Use `eyes` for seen and `check` for handled; reading alone
does not mark activity seen. Pass `--client-app codex` on queries, posts, and
artifacts so the web app can show where the action started. Do not
configure MCP unless I explicitly ask.
If I provide or confirm feedback about the Twin, submit it with `twin
feedback` and attach the routed query ID when relevant. Never infer or submit
feedback on my behalf without confirming it with me.See Use the Twin CLI for the manual commands.
Optional MCP configuration
Codex clients on the same host share MCP configuration. Use this only when you specifically want Twin operations exposed as native MCP tools; the CLI does not need it.
Add this table to ~/.codex/config.toml:
[mcp_servers.twin]
url = "https://<gateway>/mcp"
bearer_token_env_var = "MLX_TWIN_OAUTH_ACCESS_TOKEN"
enabled_tools = [
"twin_channels_list",
"twin_channels_inspect",
"twin_channel_members_list",
"twin_channel_views_list",
"twin_channel_view_create",
"twin_channel_view_get",
"twin_channel_dashboard_data",
"twin_channel_view_update",
"twin_channel_record_create",
"twin_channel_feed_list",
"twin_channel_post_create",
"twin_channel_post_update",
"twin_channel_post_delete",
"twin_channel_post_replies_list",
"twin_channel_post_reply_create",
"twin_channel_feed_thread_get",
"twin_channel_feed_comment_create",
"twin_channel_feed_comment_update",
"twin_channel_feed_comment_delete",
"twin_channel_feed_reaction_set",
"twin_artifact_create",
"twin_artifact_update",
"twin_query",
"twin_query_result",
"twin_feedback",
"twin_connections_list",
"twin_connections_verify",
"twin_onboarding_plan",
"twin_onboarding_start",
"twin_onboarding_status",
"twin_onboarding_continue",
"twin_sessions_list",
"twin_session_get",
"twin_session_artifacts_list",
"twin_artifact_get",
"twin_artifact_content",
"twin_channel_record_get",
"twin_channel_record_update",
"twin_feed_list",
"twin_feed_expand",
"twin_feed_mark_read",
"twin_automations_list",
"twin_automation_create",
"twin_automation_update",
"twin_automation_delete",
"twin_automation_run",
"twin_automation_runs_list",
"twin_feed_item_state",
"twin_channel_create",
"twin_channel_archive",
"twin_channel_object_type_create",
"twin_channel_field_create",
"twin_channel_field_update",
"twin_onboarding_list",
"search",
"fetch",
]twin_channel_dashboard_data is the compatibility tool name for canonical
saved-View data. It reads Table, Board, Calendar, Timeline, Dashboard, and Pivot
Views; clients should use its title and schema rather than infer coverage from
the legacy name. Use twin_channel_view_update for Save and
twin_channel_view_create for Save as.
Restart the Codex client after changing the environment or configuration. Use
codex mcp list in the CLI or /mcp in the terminal view to inspect the
connection.
Keep the token out of TOML
bearer_token_env_var contains the name of an environment variable, not the
credential itself. Do not replace it with a literal token.
See the current Codex MCP guide for shared configuration and client controls.