mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
[codex] switch default Apps MCP to plugin-service routes
This commit is contained in:
@@ -477,14 +477,12 @@ fn normalize_codex_apps_base_url(base_url: &str) -> String {
|
||||
|
||||
fn codex_apps_mcp_url_for_base_url(base_url: &str) -> String {
|
||||
let base_url = normalize_codex_apps_base_url(base_url);
|
||||
let (base_url, default_path) = if base_url.contains("/backend-api") {
|
||||
(base_url, "wham/apps")
|
||||
} else if base_url.contains("/api/codex") {
|
||||
(base_url, "apps")
|
||||
let base_url = if base_url.contains("/backend-api") || base_url.contains("/api/codex") {
|
||||
base_url
|
||||
} else {
|
||||
(format!("{base_url}/api/codex"), "apps")
|
||||
format!("{base_url}/api/codex")
|
||||
};
|
||||
format!("{base_url}/{default_path}")
|
||||
format!("{base_url}/ps/mcp")
|
||||
}
|
||||
|
||||
pub fn codex_apps_mcp_server_config(
|
||||
@@ -503,17 +501,7 @@ pub fn hosted_plugin_runtime_mcp_server_config(
|
||||
chatgpt_base_url: &str,
|
||||
apps_mcp_product_sku: Option<&str>,
|
||||
) -> McpServerConfig {
|
||||
let base_url = normalize_codex_apps_base_url(chatgpt_base_url);
|
||||
let base_url = if base_url.contains("/backend-api") || base_url.contains("/api/codex") {
|
||||
base_url
|
||||
} else {
|
||||
format!("{base_url}/api/codex")
|
||||
};
|
||||
mcp_server_config_for_url(
|
||||
format!("{base_url}/ps/mcp"),
|
||||
apps_mcp_product_sku,
|
||||
McpServerAuth::ChatGpt,
|
||||
)
|
||||
codex_apps_mcp_server_config(chatgpt_base_url, apps_mcp_product_sku)
|
||||
}
|
||||
|
||||
fn mcp_server_config_for_url(
|
||||
|
||||
@@ -231,27 +231,27 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_mcp_url_for_base_url_keeps_existing_paths() {
|
||||
fn codex_apps_mcp_url_for_base_url_uses_plugin_service_paths() {
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("https://chatgpt.com/backend-api"),
|
||||
"https://chatgpt.com/backend-api/wham/apps"
|
||||
"https://chatgpt.com/backend-api/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("https://chat.openai.com"),
|
||||
"https://chat.openai.com/backend-api/wham/apps"
|
||||
"https://chat.openai.com/backend-api/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("http://localhost:8080/api/codex"),
|
||||
"http://localhost:8080/api/codex/apps"
|
||||
"http://localhost:8080/api/codex/ps/mcp"
|
||||
);
|
||||
assert_eq!(
|
||||
codex_apps_mcp_url_for_base_url("http://localhost:8080"),
|
||||
"http://localhost:8080/api/codex/apps"
|
||||
"http://localhost:8080/api/codex/ps/mcp"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn codex_apps_server_config_uses_legacy_codex_apps_path() {
|
||||
fn codex_apps_server_config_uses_plugin_service_path() {
|
||||
let config =
|
||||
codex_apps_mcp_server_config("https://chatgpt.com", /*apps_mcp_product_sku*/ None);
|
||||
let url = match &config.transport {
|
||||
@@ -259,7 +259,7 @@ fn codex_apps_server_config_uses_legacy_codex_apps_path() {
|
||||
_ => panic!("expected streamable http transport for codex apps"),
|
||||
};
|
||||
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/wham/apps");
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -388,7 +388,7 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
|
||||
}
|
||||
match &codex_apps.transport {
|
||||
McpServerTransportConfig::StreamableHttp { url, .. } => {
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/wham/apps");
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
|
||||
}
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ pub async fn recorded_apps_tool_calls(server: &MockServer) -> Vec<Value> {
|
||||
.into_iter()
|
||||
.filter_map(|request| {
|
||||
let body: Value = serde_json::from_slice(&request.body).ok()?;
|
||||
(request.url.path() == "/api/codex/apps"
|
||||
(request.url.path() == "/api/codex/ps/mcp"
|
||||
&& body.get("method").and_then(Value::as_str) == Some("tools/call"))
|
||||
.then_some(body)
|
||||
})
|
||||
@@ -384,7 +384,7 @@ async fn mount_streamable_http_json_rpc_with_startup_control(
|
||||
remaining_initialize_failures: Option<Arc<AtomicUsize>>,
|
||||
) {
|
||||
Mock::given(method("POST"))
|
||||
.and(path_regex("^/api/codex/apps/?$"))
|
||||
.and(path_regex("^/api/codex/ps/mcp/?$"))
|
||||
.respond_with(CodexAppsJsonRpcResponder {
|
||||
connector_name,
|
||||
connector_description,
|
||||
|
||||
@@ -2360,7 +2360,7 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
let server = responses::start_mock_server().await;
|
||||
let untrusted_server = MockServer::start().await;
|
||||
let untrusted_apps = AppsTestServer::mount(&untrusted_server).await?;
|
||||
let untrusted_mcp_url = format!("{}/api/codex/apps", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_mcp_url = format!("{}/api/codex/ps/mcp", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_chatgpt_base_url = untrusted_apps.chatgpt_base_url;
|
||||
|
||||
let fixture = test_codex()
|
||||
@@ -2391,7 +2391,7 @@ async fn streamable_http_chatgpt_auth_is_not_sent_to_configured_origin() -> anyh
|
||||
.await
|
||||
.expect("mock server should capture MCP startup requests")
|
||||
.into_iter()
|
||||
.filter(|request| request.url.path() == "/api/codex/apps")
|
||||
.filter(|request| request.url.path() == "/api/codex/ps/mcp")
|
||||
.filter_map(|request| {
|
||||
let body: Value = serde_json::from_slice(&request.body).ok()?;
|
||||
let method = body.get("method")?.as_str()?.to_string();
|
||||
@@ -2423,7 +2423,7 @@ async fn configured_chatgpt_base_url_does_not_grant_mcp_chatgpt_auth() -> anyhow
|
||||
let server = responses::start_mock_server().await;
|
||||
let untrusted_server = MockServer::start().await;
|
||||
let untrusted_apps = AppsTestServer::mount(&untrusted_server).await?;
|
||||
let untrusted_mcp_url = format!("{}/api/codex/apps", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_mcp_url = format!("{}/api/codex/ps/mcp", untrusted_apps.chatgpt_base_url);
|
||||
let untrusted_chatgpt_base_url = untrusted_apps.chatgpt_base_url;
|
||||
|
||||
let fixture = test_codex()
|
||||
@@ -2452,7 +2452,7 @@ auth = "chatgpt"
|
||||
.await
|
||||
.expect("mock server should capture MCP startup requests")
|
||||
.into_iter()
|
||||
.filter(|request| request.url.path() == "/api/codex/apps")
|
||||
.filter(|request| request.url.path() == "/api/codex/ps/mcp")
|
||||
.filter_map(|request| {
|
||||
let body: Value = serde_json::from_slice(&request.body).ok()?;
|
||||
let method = body.get("method")?.as_str()?.to_string();
|
||||
|
||||
@@ -72,7 +72,7 @@ async fn runtime_overlay_preserves_disabled_server() -> TestResult {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn legacy_fallback_overwrites_reserved_config_without_an_extension() -> TestResult {
|
||||
async fn default_fallback_overwrites_reserved_config_without_an_extension() -> TestResult {
|
||||
let codex_home = tempfile::tempdir()?;
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
@@ -95,11 +95,11 @@ async fn legacy_fallback_overwrites_reserved_config_without_an_extension() -> Te
|
||||
let server = servers
|
||||
.get(CODEX_APPS_MCP_SERVER_NAME)
|
||||
.and_then(|server| server.configured_config())
|
||||
.ok_or("legacy Apps MCP should be present")?;
|
||||
.ok_or("default Apps MCP should be present")?;
|
||||
let McpServerTransportConfig::StreamableHttp { url, .. } = &server.transport else {
|
||||
panic!("legacy Apps MCP should use streamable HTTP");
|
||||
panic!("default Apps MCP should use streamable HTTP");
|
||||
};
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/wham/apps");
|
||||
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user