Error loading config.toml: invalid type: sequence, expected a string in `mcp_servers.perplexity.env.env_vars`

Resolved 💬 5 comments Opened Dec 10, 2025 by doggy8088 Closed Dec 10, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.66.0

What subscription do you have?

ChatGPT Plus

Which model were you using?

gpt-5.1-codex-max

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What issue are you seeing?

I followed this guide to setup my Perplexity MCP: https://github.com/openai/codex/blob/main/docs/config.md#stdio

My ~/.codex/config.toml file:

[mcp_servers.perplexity]
command = "npx"
args = ["-y", "@perplexity-ai/mcp-server"]

[mcp_servers.perplexity.env]
env_vars = [ "PERPLEXITY_API_KEY" ]

When run codex, it will produce:

Error loading config.toml: invalid type: sequence, expected a string
in `mcp_servers.perplexity.env.env_vars`

I believe this is a bug from Codex CLI.

What steps can reproduce the bug?

  1. codex mcp add perplexity -- npx -y '@perplexity-ai/mcp-server'
  2. Configure ~/.codex/config.toml add env_vars to it
  3. Run codex

What is the expected behavior?

This is either document wrong or Codex CLI implementation wrong.

Additional information

<img width="994" height="113" alt="Image" src="https://github.com/user-attachments/assets/35cd3fa8-d04b-4384-9f39-37acdc6b0b60" />

View original on GitHub ↗

5 Comments

etraut-openai contributor · 8 months ago

The env_vars key is valid only in the top-level table for the mcp server. Keys used in the .env subtable represent individual environment variables, and their values must be strings. You're attempting to define an env variable named env_vars here.

The guide you referenced isn't as clear as it could be. You may find this documentation to be clearer.

doggy8088 · 8 months ago

@etraut-openai Can you reopen this issue? It might be a documentation problem. The document provides an example env_vars = ["API_KEY2"], which is incorrect. The problem still exists. Please don't close it until it is resolved.

<img width="1338" height="721" alt="Image" src="https://github.com/user-attachments/assets/a82683ab-cd9c-4638-adc5-cc08423b5c2e" />

The document you mentioned is still vague to me. I'm unsure how to configure it. Can you provide more details?

<img width="1067" height="596" alt="Image" src="https://github.com/user-attachments/assets/ac0fc76c-1de6-4ee1-bb25-01584784e99c" />

doggy8088 · 8 months ago

@etraut-openai What exactly your mean about top-level table? I didn't get it.

etraut-openai contributor · 8 months ago

By "top-level table", I mean [mcp_servers.perplexity] in your example.

This is valid and means "share the values of environment variables FOO and BAR with this MCP server".

[mcp_servers.perplexity]
env_key = ["FOO", "BAR"]

This is valid and means "define values for environment variables FOO and BAR when calling this MCP server".

[mcp_servers.perplexity.env]
FOO = "a"
BAR = "b"

This is not valid:

[mcp_servers.perplexity.env]
FOO = ["a", "b"]
doggy8088 · 8 months ago

@etraut-openai Thank you! Hope the doc can be updated.