Preserve complete MCP namespace descriptions (#36882)

## What changed

- Keep complete MCP namespace descriptions in tool-search source metadata.
- Raise the namespace tool-spec description limit from 1,000 bytes to 512 KiB,
  truncating at a UTF-8 character boundary only when the new limit is exceeded.

## Testing

- Cover descriptions beyond the former limit and multibyte truncation at 512 KiB.
- Update SSE and stdio MCP tests to verify that complete server instructions are
  preserved without hiding tools.

GitOrigin-RevId: 000bfcafb3df348065ae451685bfbf978a0e3248
This commit is contained in:
jif authored and copyberry committed 2026-08-04 11:14:06 +00:00
1 parent 77ce1d10aa
commit fd1e4d7a6d
3 files changed
+39 -22

No files matched your search

+7 -7
View File
@@ -545,7 +545,7 @@ fn assert_cwd_tool_output(structured: &Value, expected_cwd: &Path) {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn mcp_namespace_instructions_are_bounded_without_hiding_tools() -> anyhow::Result<()> {
async fn mcp_namespace_instructions_are_preserved_without_hiding_tools() -> anyhow::Result<()> {
skip_if_wine_exec!(
Ok(()),
"requires a Windows test_stdio_server in the Wine-exec environment"
@@ -553,8 +553,8 @@ async fn mcp_namespace_instructions_are_bounded_without_hiding_tools() -> anyhow
skip_if_no_network!(Ok(()));
let server = responses::start_mock_server().await;
let expected_description = "é".repeat(499);
let instructions = format!("{expected_description}🦀keep the valid MCP server");
let expected_description = format!("{}🦀keep the valid MCP server", "é".repeat(499));
let instructions = expected_description.clone();
let response = mount_sse_once(
&server,
responses::sse(vec![
@@ -614,7 +614,7 @@ async fn mcp_namespace_instructions_are_bounded_without_hiding_tools() -> anyhow
);
assert!(
responses::namespace_child_tool(&body, "mcp__bounded", "echo").is_some(),
"bounding the namespace must not hide a valid MCP tool"
"preserving the namespace must not hide a valid MCP tool"
);
Ok(())
}
@@ -672,8 +672,8 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
.await;
let expected_env_value = "propagated-env";
let expected_description = "é".repeat(499);
let instructions = format!("{expected_description}🦀keep the complete MCP metadata");
let expected_description = format!("{}🦀keep the complete MCP metadata", "é".repeat(499));
let instructions = expected_description.clone();
let rmcp_test_server_bin = remote_aware_stdio_server_bin()?;
let fixture = test_codex()
@@ -769,7 +769,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
"the complete tool search description must remain bounded"
);
assert!(search_description.contains(&format!("- rmcp: {expected_description}")));
assert!(!search_description.contains("🦀keep the complete MCP metadata"));
assert!(search_description.contains("🦀keep the complete MCP metadata"));
let search_output = call_mock
.single_request()