Skip to content

Commit 4f51b9e

Browse files
fix(mcp): support Goose discovery handshake (#8037)
## Summary Goose 1.52 starts MCP connections with `server/discover`. `buzz-dev-mcp` rejects that request with `ExpectedInitializeRequest`, preventing Goose from loading its Buzz tools. Upgrade the tool server to rmcp 3.4.1 and adopt the renamed SDK types. Subprocess tests exercise discovery and legacy initialization, tool listing, file reads/edits, invalid arguments, connection survival, and EOF shutdown. Include the server in both Rust unit-test runners and make the cancellation regression approve its shell call before testing cancellation. The native agent retains its independent rmcp 1.x client. Cargo also unifies the existing 3.x dependency used by the mesh smoke harness. ## Validation - Normal `git push` passed all hooks, including Rust tests, Tauri checks, and repository policy checks. - `just ci` passed on the final stack: repository checks, Rust and Tauri tests/lint, desktop tests/build, web build, and mobile checks/tests. - MCP: 78 existing tests and two subprocess lifecycle tests passed; the discovery regression fails with the old SDK. - All 54 native-agent regressions passed on the final stack, including cancellation of a real MCP shell process. - Previously exercised unmodified Goose 1.52 and 1.47 with Sandpit and the real tool server. Allowed workspace operations and permitted network traffic succeeded; disallowed file and network operations were denied. - Live staging desktop check with Goose 1.52: the reply appeared in Buzz, an allowed request returned HTTP 200, and a disallowed request returned CONNECT 403. ## Stack 1. **#8042 → `main`**: deterministic handoff regression. 2. **This PR → #8042**: Goose MCP discovery compatibility. Merge the lower PR first, then retarget this PR to `main`. This diff contains only the compatibility change and its tests; the relay build repair is already on `main` in #8036. --------- Signed-off-by: Alex Rosenzweig <[email protected]>
1 parent 2c270cf commit 4f51b9e

10 files changed

Lines changed: 200 additions & 45 deletions

File tree

‎Cargo.lock‎

Lines changed: 24 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Justfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ test-unit:
387387
# buzz-acp owns the relay-to-agent trust boundary. Run its tests here so
388388
# forged relay events cannot regain a path into agent routing unnoticed.
389389
cargo nextest run -p buzz-acp
390+
# Exercise the real MCP server for modern and legacy clients.
391+
cargo nextest run -p buzz-dev-mcp
390392
# buzz-db migrator/lint tests: pure SQL-parsing unit tests (no infra).
391393
# They guard the embedded-migrator invariant (the complete checked-in
392394
# additive migration set; legacy cutover/backfill remains an operator

‎crates/buzz-agent/tests/regressions.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,8 @@ async fn cancel_kills_inflight_tool_via_mcp_notification() {
14441444
)
14451445
.await;
14461446

1447-
// Wait for the tool call to be in-progress.
1448-
h.recv_until(|v| {
1447+
// Approve the tool so this test reaches execution before cancelling it.
1448+
h.recv_until_approving(|v| {
14491449
v.get("params")
14501450
.and_then(|p| p.get("update"))
14511451
.and_then(|u| u.get("status"))

‎crates/buzz-dev-mcp/Cargo.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ tokio = { workspace = true }
2020
tokio-util = { workspace = true }
2121
serde = { workspace = true }
2222
serde_json = { workspace = true }
23-
rmcp = { workspace = true }
23+
# Discovery-based clients (including Goose 1.52) require the modern lifecycle.
24+
# Keep the native agent's independent MCP client dependency unchanged.
25+
rmcp = { version = "3.4.1", features = ["server", "transport-io", "macros"] }
2426
schemars = { workspace = true }
2527
similar = "3"
2628
tempfile = "3"

‎crates/buzz-dev-mcp/src/lib.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![cfg_attr(windows, deny(unsafe_code))]
33
use rmcp::{
44
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
5-
model::{CallToolResult, ServerCapabilities, ServerInfo},
5+
model::{CallToolResult, ServerCapabilities, ServerConfig},
66
tool, tool_handler, tool_router,
77
transport::stdio,
88
ErrorData, ServerHandler, ServiceExt,
@@ -125,8 +125,8 @@ impl DevMcp {
125125

126126
#[tool_handler(router = self.tool_router)]
127127
impl ServerHandler for DevMcp {
128-
fn get_info(&self) -> ServerInfo {
129-
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
128+
fn get_info(&self) -> ServerConfig {
129+
ServerConfig::new(ServerCapabilities::builder().enable_tools().build())
130130
.with_server_info(rmcp::model::Implementation::new(
131131
"buzz-dev-mcp",
132132
env!("CARGO_PKG_VERSION"),

‎crates/buzz-dev-mcp/src/shell.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::shim::Shim;
2-
use rmcp::model::{CallToolResult, Content};
2+
use rmcp::model::{CallToolResult, ContentBlock};
33
use rmcp::ErrorData;
44
use schemars::JsonSchema;
55
use serde::Deserialize;
@@ -161,7 +161,7 @@ pub async fn run(
161161

162162
let bash = match &state.resolved_shell {
163163
Ok((path, _)) => path.clone(),
164-
Err(msg) => return Ok(CallToolResult::error(vec![Content::text(msg.clone())])),
164+
Err(msg) => return Ok(CallToolResult::error(vec![ContentBlock::text(msg.clone())])),
165165
};
166166
let shell_arg = shell_flag(&bash);
167167
let mut cmd = Command::new(&bash);
@@ -179,7 +179,7 @@ pub async fn run(
179179
let mut child = match cmd.spawn() {
180180
Ok(c) => c,
181181
Err(e) => {
182-
return Ok(CallToolResult::error(vec![Content::text(format!(
182+
return Ok(CallToolResult::error(vec![ContentBlock::text(format!(
183183
"failed to spawn shell: {e}"
184184
))]));
185185
}
@@ -230,7 +230,7 @@ pub async fn run(
230230
}
231231
stdout_handle.abort();
232232
stderr_handle.abort();
233-
return Ok(CallToolResult::error(vec![Content::text("cancelled")]));
233+
return Ok(CallToolResult::error(vec![ContentBlock::text("cancelled")]));
234234
}
235235
r = tokio::time::timeout(timeout_dur, child.wait()) => match r {
236236
Ok(Ok(s)) => (Some(s), false),
@@ -316,7 +316,7 @@ pub async fn run(
316316
});
317317
let text = serde_json::to_string_pretty(&body).unwrap_or_else(|_| "{}".into());
318318
kill_group.disarm();
319-
Ok(CallToolResult::success(vec![Content::text(text)]))
319+
Ok(CallToolResult::success(vec![ContentBlock::text(text)]))
320320
}
321321

322322
/// The flag used to pass a command string to the shell.

‎crates/buzz-dev-mcp/src/todo.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! On replacement, open items that disappear without being marked done
1212
//! trigger a soft warning appended to the tool response.
1313
14-
use rmcp::model::{CallToolResult, Content};
14+
use rmcp::model::{CallToolResult, ContentBlock};
1515
use rmcp::ErrorData;
1616
use schemars::JsonSchema;
1717
use serde::Deserialize;
@@ -239,12 +239,12 @@ fn render_items(items: &[Item]) -> String {
239239

240240
/// Wrap a string result as an MCP CallToolResult with text content.
241241
pub fn text_result(s: String) -> Result<CallToolResult, ErrorData> {
242-
Ok(CallToolResult::success(vec![Content::text(s)]))
242+
Ok(CallToolResult::success(vec![ContentBlock::text(s)]))
243243
}
244244

245245
/// Wrap an error string as an MCP CallToolResult with isError=true.
246246
pub fn error_result(s: String) -> Result<CallToolResult, ErrorData> {
247-
Ok(CallToolResult::error(vec![Content::text(s)]))
247+
Ok(CallToolResult::error(vec![ContentBlock::text(s)]))
248248
}
249249

250250
#[cfg(test)]

‎crates/buzz-dev-mcp/src/view_image.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! Design goals: tiny surface, no protocol-specific branching, and a
77
//! "reasonable resolution" that fits comfortably inside both Anthropic's
88
//! recommended ≤1568px / ≤5 MiB image budget and OpenAI's high-detail tile
9-
//! size sweet spot. The MCP host translates `Content::image(data, mime)`
9+
//! size sweet spot. The MCP host translates `ContentBlock::image(data, mime)`
1010
//! into the right provider-native shape on our behalf (see Goose's
1111
//! `providers::utils::convert_image` for a reference implementation).
1212
@@ -18,7 +18,7 @@ use image::{
1818
DynamicImage, ExtendedColorType, ImageEncoder, ImageReader, Limits,
1919
};
2020
use rmcp::{
21-
model::{CallToolResult, Content},
21+
model::{CallToolResult, ContentBlock},
2222
ErrorData,
2323
};
2424
use schemars::JsonSchema;
@@ -101,8 +101,8 @@ pub async fn run(state: &SharedState, p: ViewImageParams) -> Result<CallToolResu
101101
);
102102

103103
Ok(CallToolResult::success(vec![
104-
Content::text(header),
105-
Content::image(encoded, prepared.mime.to_string()),
104+
ContentBlock::text(header),
105+
ContentBlock::image(encoded, prepared.mime.to_string()),
106106
]))
107107
}
108108

0 commit comments

Comments
 (0)