codex.server()

Configure Console as a stdio MCP server for the Codex SDK (openai-codex).

Usage

Source

codex.server(*, command=None, args=None, server_parameters=None)

Put this entry inside the thread’s mcp_servers configuration. The SDK starts Console and routes tool calls to it; this function only builds configuration. Reuse the thread for follow-up requests so its Console session retains state.

Parameters

command: Command | None = None

Console executable. Defaults to the installed mcp-console.

args: Sequence[Command] | None = None

Server arguments. Defaults to ["serve"].

server_parameters: Mapping[str, Any] | None = None
Additional stdio configuration, such as cwd or env.

Returns

dict[str, Any]
One server entry for config["mcp_servers"].

Examples

Install with pip install 'mcp-console[codex]' and authenticate Codex before running this script. It starts a thread with Console available as a tool and prints the final response:

import os
import mcp_console
from openai_codex import Codex

config = {
    "mcp_servers": {
        "mcp-console": mcp_console.codex.server(
            server_parameters={"cwd": os.getcwd()},
        ),
    },
}
with Codex() as client:
    thread = client.thread_start(config=config)
    result = thread.run(
        "Use Python in Console to calculate the mean and sample "
        "standard deviation of [12, 15, 18, 20, 25]."
    )
    print(result.final_response)