Make user_agent optional (#3436)

# External (non-OpenAI) Pull Request Requirements

Currently, mcp server fail to start with:
```
🖐  MCP client for `<CLIENT>` failed to start: missing field `user_agent`
````

It isn't clear to me yet why this is happening. My understanding is that
this struct is simply added as a new field to the response but this
should fix it until I figure out the full story here.

<img width="714" height="262" alt="CleanShot 2025-09-10 at 13 58 59"
src="https://github.com/user-attachments/assets/946b1313-5c1c-43d3-8ae8-ecc3de3406fc"
/>
This commit is contained in:
Gabriel Peal
2025-09-10 14:15:02 -07:00
committed by GitHub
parent 87654ec0b7
commit 8d766088e6
2 changed files with 3 additions and 2 deletions

View File

@@ -238,7 +238,7 @@ impl MessageProcessor {
name: "codex-mcp-server".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
title: Some("Codex".to_string()),
user_agent: get_codex_user_agent(),
user_agent: Some(get_codex_user_agent()),
},
};

View File

@@ -496,7 +496,8 @@ pub struct McpServerInfo {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
pub version: String,
pub user_agent: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, TS)]