Skip to content

Conversation

alexmahrou
Copy link

@alexmahrou alexmahrou commented Aug 14, 2025

Summary

  • Generated dynamic Pydantic models for every tool, emitting strict Draft‑07 object schemas with additionalProperties: false and eliminating "type": "integer" across the board.
  • Added a lightweight tools/list shim to coerce any legacy descriptors into compliant schemas.

There are around 10's of millions of ChatGPT Plus users who now have the ability to sign in with their ChatGPT Credentials in the Codex CLI at no additional cost or API token hit. Providing compatibility with this platform will provide another onramp into QC Ecosystem. The changes tighten every tool’s input schema so it is a Draft‑07 JSON object with additionalProperties: false and no "integer" types. By returning schemas that conform to the same spec most MCP clients expect, OpenAI’s Codex, Anthropic’s Claude, and any other MCP-compliant client can parse arguments deterministically without needing client‑specific shims or guessing field types. This reduces “missing field 'type'” errors and ensures consistent validation for all clients, not just Codex.

I've tested this branch locally with Codex CLI and it works.

Related to #21

@alexmahrou alexmahrou changed the title Emit strict object-shaped input schemas for MCP tools; remove integer… Codex CLI Support: Emit strict object-shaped input schemas for MCP tools Aug 14, 2025
@alexmahrou alexmahrou force-pushed the codex/fix-mcp-tool-schemas-for-codex-compatibility branch from 5c0f4bb to cf2a504 Compare August 19, 2025 10:51
@jaredbroad
Copy link
Member

@alexmahrou We tested this with codex and it still had issues. Perhaps there's some nuance about your setup that made it work for you? Can you please share a screen recording? We'd love to make it work with Codex.

@alexmahrou alexmahrou force-pushed the codex/fix-mcp-tool-schemas-for-codex-compatibility branch from cf2a504 to a31c35b Compare August 24, 2025 12:38
@alexmahrou
Copy link
Author

alexmahrou commented Aug 24, 2025

Hi @jaredbroad ,

Thanks for taking another look at this. I rebased my branch from the latest upstream main this morning and confirmed everything still works end-to-end with Codex CLI. My branch is only one commit ahead, so it should be convenient to merge once we iron this out.

To mirror the video you shared, I recorded a YouTube walkthrough where Codex selects and runs a Dual Momentum Rotation algorithm:

▶️ YouTube: Codex + QC MCP Server Hello World

And here’s the backtest Codex produced during the run:

🔗 View QuantConnect Backtest


🔧 Repro Instructions (Hello World with Codex CLI)

1. Clone & checkout my branch

mkdir -p ~/work && cd ~/work
git clone git@github.com:alexmahrou/mcp-server.git
cd mcp-server
git checkout codex/fix-mcp-tool-schemas-for-codex-compatibility

2. Python environment

python3 -m venv .venv
. .venv/bin/activate
pip install -U pip
pip install -e ".[test]"

3. Codex installation

Codex CLI must be installed (npm i -g @codex/cli), then you can run it directly with:

DEBUG=* codex

4. Codex config

Codex looks for ~/.codex/config.toml. Here’s the working format:

[projects."/home/alexm"]
trust_level = "trusted"

[projects."/home/alexm/work/mcp-server"]
trust_level = "trusted"

[mcp_servers.quantconnect]
command = "bash"
args = [
  "-lc",
  "cd /home/alexm/work/mcp-server && exec /home/alexm/work/mcp-server/.venv/bin/python -m src.main"
]

[mcp_servers.quantconnect.env]
QUANTCONNECT_USER_ID = "<your_user_id>"
QUANTCONNECT_API_TOKEN = "<your_api_token>"

Replace the env values with your QC credentials.

5. Connect from Codex

Inside Codex chat:

/status
connect to the "quantconnect" MCP server

Expected working tool calls:

quantconnect.read_mcp_server_version {}
quantconnect.read_account {}
quantconnect.list_projects {}

This is the minimal repro I tested with. Codex CLI successfully:

  • Created a new QC project
  • Added a minimal algorithm file
  • Compiled
  • Launched a backtest (results linked above)

I tried to keep this setup guide in parity with your published video, so anyone should be able to follow it 1:1 and reproduce Codex driving the QC MCP server.

@DerekMelchin
Copy link
Collaborator

Hi @alexmahrou

The video above shows the agent commonly struggles to provide the correct arguments to each tool and some tools still show "tool failed".

We've created a GitHub Issue on the Codex repo to get the underlying problem addressed/pointed out.
openai/codex#2420

@alexmahrou
Copy link
Author

Oh sweet good to see this. Curious did you try launching codex with

DEBUG=* codex

?

Maybe that would give us more verbose logging?

@DerekMelchin
Copy link
Collaborator

I used the most verbose logging I could

$env:RUST_LOG = "codex_core=trace,codex_tui=trace"

but the logs still didn't elaborate on the problem.

@alexmahrou alexmahrou force-pushed the codex/fix-mcp-tool-schemas-for-codex-compatibility branch from a31c35b to 8c933cb Compare September 2, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants