litellm/tests/e2e/codex/test_mcp_tool_e2e.py
ryan-crabbe-berri 6fa0477d84
test(e2e): add a Codex row that calls a local MCP tool on a first and a resumed turn (#49817)
* test(e2e): add a Codex row that calls a local MCP tool on a first and a resumed turn

* test(e2e): assert the codex mcp row got each value back from the mcp tool call itself

* test(e2e): check the codex mcp row exits cleanly on both turns

* test(e2e): drop the unused content type from the codex mcp result model
2026-11-06 03:59:03 +00:00

47 lines
1.8 KiB
Python

from __future__ import annotations
import sys
from pathlib import Path
from typing import Final
import pytest
from codex.harness import CodexHarness, McpServer
from codex.setups import SETUPS, ModelSetup
from e2e_config import unique_marker
pytestmark = pytest.mark.e2e
MCP_SERVER: Final = Path(__file__).with_name("mcp_server.py")
@pytest.mark.parametrize("deployment", SETUPS)
class TestCodexMcpTool:
def test_calls_a_local_mcp_tool_again_on_a_resumed_turn(self, codex: CodexHarness, setup: ModelSetup) -> None:
secret: Final = codex.home / "secret.txt"
vault: Final = McpServer(command=sys.executable, args=(str(MCP_SERVER),), env={"SECRET_FILE": str(secret)})
codex.add_mcp_server("vault", vault)
workspace: Final = codex.new_workspace(files={})
first_marker: Final = unique_marker()
_ = secret.write_text(first_marker)
first: Final = codex.exec(
"Call the read_secret tool of the vault MCP server, then reply with exactly what it returned.",
model=setup.model,
cwd=workspace,
)
assert first.exit_code == 0, first
assert first.thread_id is not None, first
assert any(first_marker in call.output for call in first.mcp_calls), first
assert first_marker in first.answer, first
second_marker: Final = unique_marker()
_ = secret.write_text(second_marker)
second: Final = codex.resume(
first.thread_id,
"The secret has changed. Call the read_secret tool again, then reply with exactly what it returned.",
model=setup.model,
cwd=workspace,
)
assert second.exit_code == 0, second
assert any(second_marker in call.output for call in second.mcp_calls), second
assert second_marker in second.answer, second