Preserve longer MCP source descriptions in tool search (#37066)

## Why

The 4 KiB aggregate limit can truncate source metadata before it reaches the
model through the tool search description.

## What changed

Raise the aggregate source-description limit to 512 KiB while retaining the
existing character-boundary-safe truncation and bounded output.

## Testing

Expand unit and RMCP round-trip coverage to verify that substantially longer
Unicode descriptions remain complete within the new limit.

GitOrigin-RevId: 002760cdd2e8741e531b45f75f8624ef84334d24
This commit is contained in:
jif authored and copyberry committed 2026-08-05 09:39:05 +00:00
1 parent 757c151a0e
commit fcc4ca552f
2 files changed
+6 -4

No files matched your search

+2 -2
View File
@@ -620,7 +620,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
.await;
let expected_env_value = "propagated-env";
let expected_description = format!("{}🦀keep the complete MCP metadata", "é".repeat(499));
let expected_description = format!("{}🦀keep the complete MCP metadata", "é".repeat(11_000));
let instructions = expected_description.clone();
let rmcp_test_server_bin = remote_aware_stdio_server_bin()?;
@@ -713,7 +713,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
.and_then(|tool| tool.get("description").and_then(Value::as_str))
.expect("the model should receive a tool search description");
assert!(
search_description.len() < 5 * 1024,
search_description.len() < 513 * 1024,
"the complete tool search description must remain bounded"
);
assert!(search_description.contains(&format!("- rmcp: {expected_description}")));