|
| 1 | +# ============================================================================ |
| 2 | +# Codex MCP + auto-inject + proxy configuration for MATHIR |
| 3 | +# ---------------------------------------------------------------------------- |
| 4 | +# This is a TEMPLATE — every line that needs a per-user substitution uses the |
| 5 | +# placeholder `<YOU>` (Windows) or `<USER>` (macOS/Linux). |
| 6 | +# |
| 7 | +# How to use this on a fresh box: |
| 8 | +# 1. Find your Python interpreter: |
| 9 | +# Windows : `where.exe python` |
| 10 | +# macOS : `which python3` (or use a venv interpreter) |
| 11 | +# Then replace `<ABS_PYTHON>` below with that absolute path. |
| 12 | +# 2. Replace every `<YOU>` / `<USER>` with your username. |
| 13 | +# 3. Merge this into your existing `~/.codex/config.toml` (do not overwrite). |
| 14 | +# 4. Quit Codex fully (not just close the chat) and relaunch. |
| 15 | +# 5. Verify by asking Codex "liste tes outils MCP" — you should see |
| 16 | +# mcp__mathir__memory_recall, mcp__mathir__memory_save, etc. |
| 17 | +# |
| 18 | +# Troubleshooting: see ../../../docs/CODEX_INTEGRATION.md |
| 19 | +# and troubleshooting/codex-mcp-tools-invisible-three-layers.md |
| 20 | +# ============================================================================ |
| 21 | + |
| 22 | +# --------------------------------------------------------------------------- |
| 23 | +# Layer A — MCP server (the 27 tools) |
| 24 | +# --------------------------------------------------------------------------- |
| 25 | +[mcp_servers.mathir] |
| 26 | +# IMPORTANT: use ABSOLUTE python path. Codex (Electron) does not always |
| 27 | +# inherit your shell's PATH for MCP child processes, so `command = "python"` |
| 28 | +# silently resolves to nothing and 0 tools show up. |
| 29 | +command = "<ABS_PYTHON>" |
| 30 | +args = ["<HOME>\\.config\\MATHIR\\mathir_mcp\\mathir_lib\\mathir_mcp_server.py"] |
| 31 | +startup_timeout_sec = 30 |
| 32 | + |
| 33 | +[mcp_servers.mathir.env] |
| 34 | +MATHIR_EMBEDDING_DIM = "384" |
| 35 | +MATHIR_PORT = "7338" |
| 36 | +MATHIR_DAEMON_URL = "http://127.0.0.1:7338" |
| 37 | +# IMPORTANT: absolute paths in env vars, NOT `~/.config/...`. Codex does NOT |
| 38 | +# shell-expand `~` in MCP env vars before passing them to Python. If you use |
| 39 | +# `~`, `from mathir_paths import CONFIG_PATH` crashes silently and you get 0 tools. |
| 40 | +MATHIR_CONFIG = "<HOME>\\.config\\MATHIR\\config\\mathir.json" |
| 41 | +PYTHONPATH = "<HOME>\\.config\\MATHIR\\mathir_mcp\\mathir_lib" |
| 42 | + |
| 43 | +# --------------------------------------------------------------------------- |
| 44 | +# Layer B — auto-inject hook (prompt-time context) |
| 45 | +# --------------------------------------------------------------------------- |
| 46 | +# Drop hooks.json from this same directory into `~/.codex/hooks.json` (full |
| 47 | +# template also provided). No TOML changes needed for this. |
| 48 | + |
| 49 | +# --------------------------------------------------------------------------- |
| 50 | +# Layer C — transparent OpenAI proxy (optional) |
| 51 | +# --------------------------------------------------------------------------- |
| 52 | +# Adds `OPENAI_BASE_URL` to Codex's env forwarding. `/v1` is mandatory: |
| 53 | +# OpenAI SDK adds `/chat/completions` to your base_url, and its default |
| 54 | +# already includes `/v1` (per guardrail-base-url-v1-convention). |
| 55 | +[shell_environment_policy.set] |
| 56 | +OPENAI_BASE_URL = "http://127.0.0.1:7339/v1" |
| 57 | +MATHIR_PROXY_PORT = "7339" |
0 commit comments