codex icon indicating copy to clipboard operation
codex copied to clipboard

Add MCP support.

Open LuciferMornens opened this issue 1 year ago • 43 comments

Would it be possible to have MCP servers support in codex?

i'd defo love to see that. me and many others.

LuciferMornens avatar Apr 16 '25 17:04 LuciferMornens

Tbh, It's kinda weird that it was launched without MCP support, it's kind of a standard.

OhadRubin avatar Apr 16 '25 17:04 OhadRubin

we need MCP support. Without MCP, this is not much useful

vigneshchinnadurai avatar Apr 16 '25 17:04 vigneshchinnadurai

Codex is great, but a huge step backwards vs Cursor agent mode or Claude Code, which both have MCP support.

I will hold off testing Codex until MCP support is added.

jacob-israel-turner avatar Apr 16 '25 19:04 jacob-israel-turner

I can't really test this without MCP support, it would be a step back

plwalters avatar Apr 17 '25 00:04 plwalters

Hey folks, following up on the discussion about potentially integrating MCP here.

Just wanted to put a library I've been working on onto the radar, in case it might help accelerate things if we go down the MCP route. It's called omcph (https://github.com/lefrog-dont-code/omcph) and it's basically a ready-made TypeScript client host for managing connections to MCP servers.

The idea is to handle some of the boilerplate involved in being an MCP Host, like:

  • Connecting to multiple servers (stdio, streamable-http, websockets, etc.)
  • Aggregating capabilities (tools, resources, prompts) from all of them.
  • Handling the sampling/createMessage delegation flow securely (so Codex keeps control of the main LLM calls).
  • Built on top of the official @modelcontextprotocol/sdk.

Obviously, adding any dependency is a consideration, but thought it might be useful as a potential building block if the project decides to implement MCP host capabilities.

Let me know if this looks potentially helpful or if a different approach (like building directly on the base SDK) seems more appropriate for Codex!

lefrog-dont-code avatar Apr 17 '25 02:04 lefrog-dont-code

I have a PR coming for MCP support -- have added commands based on claude code to add, remove and support local and global MCP servers; have got client invoking working and just testing -- should be PR today for this.

jasonkneen avatar Apr 17 '25 06:04 jasonkneen

I stopped using it as soon as I realised I cannot call perplexity-search mcp it with. it's really fine if there is no support for MCP yet, but no web search? that's a bummer

Stewart86 avatar Apr 17 '25 11:04 Stewart86

Running final tests etc.

jasonkneen avatar Apr 17 '25 17:04 jasonkneen

Bit rough, not happy with it but was a pig to get in there, so needs some more love I think but it works -- it's very fragile with MCP servers that don't behave well but I'm starting to test it now with a load.

Incoming shortly

jasonkneen avatar Apr 17 '25 21:04 jasonkneen

PR in

jasonkneen avatar Apr 17 '25 21:04 jasonkneen

I've created what I believe is a more minimal implementation of MCP support. You can find it here:

https://github.com/wtesler/codex-mcp/commit/1136135e692e560262f48f42f7e910179ee91f24

In my approach, you add the MCP config to ~/.codex/config.json like:

{
  "model": "o4-mini",
  "mcpServers": {
    "playwright": { "url": "http://localhost:8931/sse" },
  }
}

Then you can run the MCP server locally like:

npx @playwright/mcp@latest --port 8931

If you want to try it out, download my fork, cd into codex-cli, npm install, npm run build, and then you can run codex like bin/codex.

Then you can make an MCP call like "Call the playwright tool browser_tab_new with url https://example.com"

Try it out and let me know what you think.

wtesler avatar Apr 18 '25 22:04 wtesler

Yes, I would love to check what I can squeeze from 4.1 with a 1 million context window and https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking.

Claude Code, with his appetite, will make me bankrupt :D

gaiar avatar Apr 24 '25 07:04 gaiar

nice! when it would be out?

MatanYemini avatar May 03 '25 16:05 MatanYemini

@gaiar FYI: https://x.com/alexalbert__/status/1918017889548026263

Max plan subscribers now get Claude Code included as part of their plan.

michabbb avatar May 03 '25 20:05 michabbb

FYI this is the latest take on adding MCP support to ts version of codex

Damecek avatar May 12 '25 08:05 Damecek

It's been over a month and this still hasn't landed, unless I'm missing something. MCP is kind of table stakes these days...

sobri909 avatar May 19 '25 08:05 sobri909

Great to see efforts to deliver MCP :D

Just one small question, do we know if the stdio based commands will be sandboxed without network access as codex is? I'd love to add some MCPs for documentation search specifically and that would be a deal breaker

ramarivera avatar May 19 '25 10:05 ramarivera

I absolutely do not want the same limitations as the cloud codex -- it's unsuable as-is with it's no internet access so if it's added, it need to be configurable please

jasonkneen avatar May 19 '25 10:05 jasonkneen

Why was the PR abandoned?

schdief avatar May 19 '25 15:05 schdief

surprised of absence of MCP for so long

macseem avatar May 20 '25 09:05 macseem