MCP guides · 9 min read

Codex CLI Text to Speech: Connect Clonylab and Narrate Scripts

Connect Clonylab to Codex CLI with a short config.toml block and a token kept in an environment variable. Setup, timeouts, prompts and fixes.

Yashveer Bharani, founder of ClonylabYashveer BharaniFounder of ClonylabPublished Updated
Clonylab guide: Codex CLI Text to Speech, with a config.toml block on the left and a voice waveform on the right

The short answer

To add text to speech to Codex CLI, create a token on Clonylab’s Connector screen, export it as CLONYLAB_TOKEN and add an mcp_servers.clonylab block with the url https://clonylab.com/mcp and bearer_token_env_var to ~/.codex/config.toml. Codex then gets 14 voice tools. Keep your Clonylab tab open. It needs Pro or Team.

Key takeaways

  1. Add an [mcp_servers.clonylab] block to ~/.codex/config.toml with url https://clonylab.com/mcp and bearer_token_env_var.
  2. Keep the token in an environment variable, so config.toml never holds it.
  3. Codex gives a tool call 60 seconds by default. Raise tool_timeout_sec for long scripts.
  4. The voice-over is made in your open Clonylab tab, so keep it open with the browser switch on.
  5. The AI connection is part of Pro and Team. It is English only, and Codex cannot create a cloned voice.

01What you get with Codex CLI text to speech

Codex is OpenAI’s coding agent. It runs in your terminal, reads your project and does tasks on request. Like other agents, it works with text and files. Connect a text to speech MCP server and it can also turn a script into speech and save the MP3 beside your code.

Clonylab gives Codex 14 tools: list voices, make a voice-over, watch the job, search your History and fetch the MP3. The tools are the same in every app, and our guide to the text to speech MCP server explains them. This guide is the Codex version, with the config.toml block and one setting that matters for longer scripts.

Codex has an unusual strength for this job. It is happy to run a long chain of steps on its own, such as “read these ten files, write ten scripts, make ten voice-overs and list the results.” That is exactly what the Clonylab tools are good at.

Figure 1. The path of one voice-over from Codex CLI. The line on top is the command going out; the line below is the finished MP3 coming back as a download link.

02Before you start

What you need for Codex and Clonylab
NeedDetails
Codex CLIInstalled and signed in. The desktop app, the CLI and the IDE extension share one config file
A Clonylab planThe AI connection is part of Pro and Team
A tokenMade on the Connector screen. It starts with swr_ and is shown once
An open Clonylab tabVoices are made in your browser tab, so keep it open

Codex stores MCP servers in ~/.codex/config.toml. A project can add its own .codex/config.toml, but Codex reads that file only in projects you trust. Keep your Clonylab block in the file in your home folder.

03Add Clonylab to Codex in 4 steps

Figure 2. The four steps for Codex CLI.

Create a token

Open Connector in your Clonylab account, name a token “Codex on my laptop” and copy it. You can have up to 10 tokens, one per tool.

The Connector card Option B with a token name field, a new token shown once, and a token in the list
The token is shown once. The value here is a placeholder.

Put the token in an environment variable

Codex can read a bearer token from a variable, so the token never has to be written in the file. Add this line to your shell profile, or run it in your terminal, with your own token.

In your shell
export CLONYLAB_TOKEN="YOUR_TOKEN"

Add the block to config.toml

Open ~/.codex/config.toml and add this block.

Codex CLI (~/.codex/config.toml)
[mcp_servers.clonylab]
url = "https://clonylab.com/mcp"
bearer_token_env_var = "CLONYLAB_TOKEN"
The Connector setup card for Codex CLI with the export line and the config.toml block filled in
The Codex card on the Connector screen. It shows the variable line and the block together.

Allow your browser tab

Switch on Allow AI tools to use this browser in Clonylab and keep the tab open. Then start Codex from the same terminal, so it can see the variable.

The Connector card with the switch turned on and the message Connected
When the card says Connected, Codex can use your tab.

04The block, line by line

Figure 3. The block, line by line. The two timeout lines are optional and show Codex’s defaults.

Codex’s documentation lists a few more options that are useful here. http_headers sends fixed headers, env_http_headers reads header values from variables, and enabled = false switches a server off without deleting it. You do not need any of them for Clonylab.

A project can also hold a .codex/config.toml with its own servers, for example one that only that project needs. Codex reads that file only in trusted projects, which protects you from a stranger’s repository adding servers without you knowing. For Clonylab, keep the block in your home file. Then every project can use it, and the token stays out of any repository.

You can check what Codex loaded with codex mcp list. It lists the servers you set up. If you ever prefer signing in instead of a token, codex mcp login starts an OAuth login for servers that support it.

05One setting for long scripts: the tool timeout

Codex gives each tool call 60 seconds by default. Clonylab’s generate_speech waits up to 45 seconds for a result unless the agent asks for a different wait, and it can wait up to 100 seconds. If Codex cuts the call off at 60 seconds, a long script may look like a failure even though the job is still running in your tab.

You have two easy fixes. Ask Codex to check the job again with get_job, or raise the limit in the block:

config.toml with a longer tool timeout
[mcp_servers.clonylab]
url = "https://clonylab.com/mcp"
bearer_token_env_var = "CLONYLAB_TOKEN"
tool_timeout_sec = 120

Large batches are the most likely place to hit the 60-second limit, so set the longer timeout before you start one.

Figure 4. The life of one speech job. These are the real status words that get_job returns. The bar loops here only to show the idea.
Timing settings that touch a voice-over
SettingWhereDefaultWhat it does
startup_timeout_secCodex10 secondsHow long Codex waits for the server to answer when it starts
tool_timeout_secCodex60 secondsHow long one tool call may run
wait_secondsClonylab tool45 secondsHow long generate_speech waits for the result; up to 100
Download linkClonylab30 minutesHow long a get_audio link works

06Your first voice-over from Codex

Start Codex in a project folder. Ask for something small first.

Check that Clonylab is connected and list the UK male voices.Uses connection_status and list_voices.
Read docs/overview.md and write a 40-second narration. Make it in a calm US female voice and save the MP3 as audio/overview.mp3.Uses generate_speech, get_job and get_audio, then a download command.
For every file in scripts/, make a voice-over in the same voice and list the MP3 names when you finish.A batch run. The tab makes them one after another.
Show my last five voice-overs and delete none of them.Uses list_history. Say it plainly when you do not want a delete.
Figure 5. The loop Codex runs for each voice-over. It repeats for every script in a batch.

07Keep your token safe

The variable route already helps. The token is not in config.toml, so you can back up or share that file without sharing the token. Keep these habits too.

Figure 6. Safe and unsafe homes for a Codex token.

08If something goes wrong

Common problems with Codex and Clonylab
What you seeLikely causeWhat to do
The server does not appear in codex mcp listThe block is in the wrong file or has a typoCheck the table name and that the file is in ~/.codex
UnauthorizedThe variable is empty or the token was deletedRun echo $CLONYLAB_TOKEN in the same terminal, then make a new token if needed
The call times out but the clip is madeThe tool timeout is shorter than the waitRaise tool_timeout_sec or ask Codex to run get_job
Codex says no browser tab is connectedClonylab is closed or the switch is offOpen Clonylab and switch on “Allow AI tools to use this browser”
It worked in one terminal onlyThe variable was set in that terminal onlyPut the export line in your shell profile
How we checked this guide

We took the config file path, the fields and the timeout defaults from OpenAI’s Codex documentation on 1 November 2026, and the Clonylab block from our own Connector screen. Codex changes quickly. If a field name differs in your version, run codex mcp --help.

09Limits, and when to use the Studio

Figure 7. Which plan includes the AI connection. The Trial lets you try the Studio and cloning; the MCP server starts with Pro.
Codex with Clonylab: limits
TopicWhat to know
PlanPro or Team
LanguageEnglish only, with US and UK voices
One requestUp to 10,000 characters per generate_speech call
BrowserThe Clonylab tab must stay open
Cloned voicesCodex can use your clones, not create them. See voice clone MCP
Download linksAn MP3 link works for 30 minutes

The Studio stays the best place for one clip that you want to hear and tune. Codex is the better place when voice-overs come out of a larger task. If you also use other agents, our guides for Gemini CLI and Claude Code show the same server in their formats. The pauses page lists the script tags.

10Questions and answers

How do I add an MCP server to Codex CLI?

Add a table named mcp_servers.<name> to ~/.codex/config.toml with the server url. For Clonylab the url is https://clonylab.com/mcp, and bearer_token_env_var names the variable that holds your token.

Where is the Codex config file?

It is ~/.codex/config.toml. A project can also have .codex/config.toml, but Codex reads it only in trusted projects. The desktop app, the CLI and the IDE extension share the file.

Why is my voice-over call timing out?

Codex gives each tool call 60 seconds by default. Raise tool_timeout_sec in the block, or ask Codex to check the job again with get_job.

Do I have to keep Clonylab open?

Yes. The voice-over is made in your open Clonylab browser tab on your own device. Keep the tab open and the browser switch on.

Can Codex clone my voice?

No. You create a clone yourself on the Clone screen. After that Codex can list your cloned voices and use them to read English scripts.

Is it free?

The free trial lets you try the Studio and cloning. The AI connection that Codex uses is part of the Pro and Team plans.

Ready to let your AI make the voice-overs?

Start free with the Studio and cloning, then add Pro when you want the AI connection. English only, no card to start.

Keep reading

Sources and further reading

Last updated . The screenshots come from the Clonylab Connector screen, with the address and the token replaced by the real address and a placeholder. App and tool settings change often: if a step does not match your version, trust the Connector screen in your account.