mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Set a default user agent for MCP HTTP requests (#34883)
## What changed - Send `codex-mcp-client/<version>` as the default user agent for streamable HTTP and OAuth requests. - Preserve user agents supplied through configured HTTP headers. ## Testing - Verify the default user agent on OAuth discovery, token refresh, and MCP initialization requests. - Verify that a configured user agent overrides the default. GitOrigin-RevId: 659ef8f126df97b3c1b4d01e9e542a673b5ef42b
This commit is contained in:
1 parent
4e0cee8030
commit
6e0455fdc4
3 files changed
+86
No files matched your search
@@ -5,10 +5,13 @@ use reqwest::ClientBuilder;
|
||||
use reqwest::header::HeaderMap;
|
||||
use reqwest::header::HeaderName;
|
||||
use reqwest::header::HeaderValue;
|
||||
use reqwest::header::USER_AGENT;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
|
||||
const MCP_USER_AGENT: &str = concat!("codex-mcp-client/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
pub(crate) fn create_env_for_mcp_server(
|
||||
extra_env: Option<HashMap<OsString, OsString>>,
|
||||
env_vars: &[McpServerEnvVar],
|
||||
@@ -62,6 +65,7 @@ pub(crate) fn build_default_headers(
|
||||
env_http_headers: Option<HashMap<String, String>>,
|
||||
) -> Result<HeaderMap> {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert(USER_AGENT, HeaderValue::from_static(MCP_USER_AGENT));
|
||||
|
||||
if let Some(static_headers) = http_headers {
|
||||
for (name, value) in static_headers {
|
||||
|
||||
Reference in new issue
Block a user