mirror of
https://github.com/openai/codex.git
synced 2026-11-23 07:17:11 +00:00
Support package-style MCP server names (#41700)
## What changed - Allow MCP server names to contain `:`, `@`, `/`, and `.`, enabling names such as `npm:@modelcontextprotocol/server-sequential.thinking`. - Preserve these names across `mcp add`, `get`, `list`, and `remove`, runtime tool namespaces, and OAuth credential lookup. - Quote non-bare server names in generated `config.toml` recovery hints and keep similarly escaped OAuth credential names isolated. ## Testing - Add CLI and runtime round-trip coverage for npm-style names. - Add snapshot coverage for quoted recovery hints and a regression test for OAuth credential-name collisions. GitOrigin-RevId: 97e9353cdbc544db4eb2377ddbfa1d2d539b1e04
This commit is contained in:
1 parent
88f776588f
commit
94cbbddafc
12 files changed
+159
-13
No files matched your search
@@ -831,6 +831,9 @@ fn load_oauth_tokens_from_file_with_lock_held(
|
||||
false
|
||||
} else {
|
||||
entry.server_url == url
|
||||
// Escaped names may also match another server's stored, escaped name.
|
||||
// Only accept a legacy unescaped entry under this identity's own key.
|
||||
&& (!server_name.starts_with("local:") || stored_key == &key)
|
||||
&& (entry.server_name == local_server_name
|
||||
|| (stored_key == &key && entry.server_name == server_name))
|
||||
};
|
||||
|
||||
@@ -110,6 +110,38 @@ fn sample_tokens() -> StoredOAuthTokens {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_credentials_keep_repeated_local_prefixes_isolated() -> Result<()> {
|
||||
let _env = TempCodexHome::new();
|
||||
let config: codex_config::McpServerConfig = serde_json::from_value(serde_json::json!({
|
||||
"url": "https://example.test",
|
||||
}))?;
|
||||
let mut first = sample_tokens();
|
||||
first.server_name = config.oauth_credential_name("local:foo").into_owned();
|
||||
first.expires_at = None;
|
||||
first.token_response.0.set_expires_in(None);
|
||||
save_oauth_tokens_to_file(&first)?;
|
||||
|
||||
let second_name = config.oauth_credential_name("local:local:foo");
|
||||
assert_eq!(load_oauth_tokens_from_file(&second_name, &first.url)?, None);
|
||||
|
||||
let mut second = first.clone();
|
||||
second.server_name = second_name.into_owned();
|
||||
second
|
||||
.token_response
|
||||
.0
|
||||
.set_access_token(AccessToken::new("second-token".to_string()));
|
||||
save_oauth_tokens_to_file(&second)?;
|
||||
|
||||
for expected in [first, second] {
|
||||
assert_eq!(
|
||||
load_oauth_tokens_from_file(&expected.server_name, &expected.url)?,
|
||||
Some(expected)
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_rmcp_oauth_keyring_credentials_remain_readable() -> Result<()> {
|
||||
let _env = TempCodexHome::new();
|
||||
|
||||
Reference in new issue
Block a user