Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Codex CLI
This guide helps you set up the mcp-grafana server for the OpenAI Codex CLI.
Prerequisites
- Codex CLI installed (
npm install -g @openai/codex) - Grafana 9.0+ with a service account token
mcp-grafanabinary in your PATH
Important: TOML format
Codex uses TOML configuration, not JSON. Configuration file: ~/.codex/config.toml
Configuration
CLI setup (recommended)
codex mcp add grafana -- mcp-grafanaAdd environment variables:
codex mcp add grafana \
--env GRAFANA_URL=http://localhost:3000 \
--env GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
-- mcp-grafanaManual configuration
Create or edit ~/.codex/config.toml:
[mcp_servers.grafana]
command = "mcp-grafana"
args = []
env = { GRAFANA_URL = "http://localhost:3000", GRAFANA_SERVICE_ACCOUNT_TOKEN = "<your-token>" }Note: Use mcp_servers (underscore, not hyphen).
Debug mode
[mcp_servers.grafana]
command = "mcp-grafana"
args = ["-debug"]
env = { GRAFANA_URL = "http://localhost:3000", GRAFANA_SERVICE_ACCOUNT_TOKEN = "<your-token>" }Docker setup
[mcp_servers.grafana]
command = "docker"
args = ["run", "--rm", "-i", "-e", "GRAFANA_URL", "-e", "GRAFANA_SERVICE_ACCOUNT_TOKEN", "grafana/mcp-grafana", "-t", "stdio"]
env = { GRAFANA_URL = "http://host.docker.internal:3000", GRAFANA_SERVICE_ACCOUNT_TOKEN = "<your-token>" }Verify configuration
# List configured servers
codex mcp list
# Show specific server config
codex mcp get grafana
# Start Codex and test
codexThen ask: “List my Grafana dashboards”
Timeout settings
If Grafana operations take time, increase timeout:
[mcp_servers.grafana]
command = "mcp-grafana"
args = []
env = { GRAFANA_URL = "http://localhost:3000", GRAFANA_SERVICE_ACCOUNT_TOKEN = "<your-token>" }
startup_timeout_ms = 20000
tool_timeout_ms = 120000Troubleshooting
Server not found in Codex:
- Verify TOML syntax (no trailing commas, use
=not:) - Check key is
mcp_serversnotmcp-servers - Restart Codex after configuration changes
Config shared across CLI and IDE: Codex CLI and VS Code extension share ~/.codex/config.toml. A syntax error breaks both.
Common TOML mistakes:
# Wrong - JSON-style
env = {"GRAFANA_URL": "http://localhost:3000"}
# Correct - TOML-style
env = { GRAFANA_URL = "http://localhost:3000" }Read-only mode
[mcp_servers.grafana]
command = "mcp-grafana"
args = ["--disable-write"]
env = { GRAFANA_URL = "http://localhost:3000", GRAFANA_SERVICE_ACCOUNT_TOKEN = "<your-token>" }Next steps
- Set up for other install options.
- Configure authentication for Grafana credentials.


