fix: a few things with the mcp snapshot test (#4818)

This commit is contained in:
Jack Amadeo
2025-09-25 14:36:21 -04:00
committed by GitHub
parent 2f11d8d4ac
commit 917e1794ab
8 changed files with 158 additions and 254 deletions
+11 -16
View File
@@ -50,7 +50,7 @@ enum TestMode {
vec![]
)]
#[test_case(
vec!["cargo", "run", "-p", "goose-server", "--bin", "goosed", "--", "mcp", "developer"],
vec!["cargo", "run", "--quiet", "-p", "goose-server", "--bin", "goosed", "--", "mcp", "developer"],
vec![
ToolCall::new("text_editor", json!({
"command": "view",
@@ -74,12 +74,6 @@ enum TestMode {
"new_str": "# codename goose"
})),
ToolCall::new("list_windows", json!({})),
ToolCall::new("screen_capture", json!({
"display": 0
})),
ToolCall::new("image_processor", json!({
"path": "~/goose/crates/goose/tests/tmp/goose-test.png"
})),
],
vec![]
)]
@@ -162,10 +156,9 @@ async fn test_replayed_session(
let extension_manager = ExtensionManager::new();
let result = extension_manager.add_extension(extension_config).await;
assert!(result.is_ok(), "Failed to add extension: {:?}", result);
let result = (async || -> Result<(), Box<dyn std::error::Error>> {
extension_manager.add_extension(extension_config).await?;
let mut results = Vec::new();
for tool_call in tool_calls {
let tool_call = ToolCall::new(format!("test__{}", tool_call.name), tool_call.arguments);
@@ -196,12 +189,14 @@ async fn test_replayed_session(
.await;
if let Err(err) = result {
let errors =
fs::read_to_string(format!("{}.errors.txt", replay_file_path.to_string_lossy()))
.expect("could not read errors");
eprintln!("errors from {}", replay_file_path.to_string_lossy());
eprintln!("{}", errors);
eprintln!();
if matches!(mode, TestMode::Playback) {
let errors =
fs::read_to_string(format!("{}.errors.txt", replay_file_path.to_string_lossy()))
.expect("could not read errors");
eprintln!("errors from {}", replay_file_path.to_string_lossy());
eprintln!("{}", errors);
eprintln!();
}
panic!("Test failed: {:?}", err);
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,111 @@
[
[
{
"type": "resource",
"resource": {
"uri": "file:///Users/jackamadeo/goose/crates/goose/tests/tmp/goose.txt",
"mimeType": "text",
"text": "# codename goose\n"
},
"annotations": {
"audience": [
"assistant"
]
}
},
{
"type": "text",
"text": "### /Users/jackamadeo/goose/crates/goose/tests/tmp/goose.txt\n```\n1: # codename goose\n```\n",
"annotations": {
"audience": [
"user"
],
"priority": 0.0
}
}
],
[
{
"type": "text",
"text": "The file /Users/jackamadeo/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# codename goose (modified by test)\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n",
"annotations": {
"audience": [
"assistant"
]
}
},
{
"type": "text",
"text": "```\n# codename goose (modified by test)\n```\n",
"annotations": {
"audience": [
"user"
],
"priority": 0.2
}
}
],
[
{
"type": "text",
"text": "# codename goose (modified by test)\n",
"annotations": {
"audience": [
"assistant"
]
}
},
{
"type": "text",
"text": "# codename goose (modified by test)\n",
"annotations": {
"audience": [
"user"
],
"priority": 0.0
}
}
],
[
{
"type": "text",
"text": "The file /Users/jackamadeo/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# codename goose\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n",
"annotations": {
"audience": [
"assistant"
]
}
},
{
"type": "text",
"text": "```\n# codename goose\n```\n",
"annotations": {
"audience": [
"user"
],
"priority": 0.2
}
}
],
[
{
"type": "text",
"text": "Available windows:\nMenubar",
"annotations": {
"audience": [
"assistant"
]
}
},
{
"type": "text",
"text": "Available windows:\nMenubar",
"annotations": {
"audience": [
"user"
],
"priority": 0.0
}
}
]
]
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,8 +1,10 @@
STDIN: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"goose","version":"0.1.0"}}}
STDERR: Starting default (STDIO) server...
STDOUT: {"result":{"protocolVersion":"2025-03-26","capabilities":{"prompts":{},"resources":{"subscribe":true},"tools":{},"logging":{},"completions":{},"elicitation":{}},"serverInfo":{"name":"example-servers/everything","title":"Everything Example Server","version":"1.0.0"},"instructions":"Testing and demonstration server for MCP protocol features.\n\n## Resources\n\nResources 1-100 follow pattern: even IDs contain text, odd IDs contain binary data. Resources are paginated at 10 items per page with cursor-based navigation.\n\n## Key dependencies\n\nProgress notifications require `_meta.progressToken` in tool calls. Resource subscriptions generate updates every 10 seconds.\n\n## Performance characteristics\n\nServer generates automatic log messages every 20 seconds (filtered by current log level), stderr notifications every 30 seconds, and resource update notifications every 10 seconds for active subscriptions. Log level changes affect message filtering in real-time.\n\n## Multi-modal testing\n\n`complex_prompt` includes both text arguments and image content for testing client multi-modal handling. `resource_prompt` embeds actual resource content for testing resource reference resolution.\n\nArgument completion is available for prompt parameters and resource IDs. Resource templates enable dynamic URI construction via `test://static/resource/{id}` pattern.\n\n## Easter egg\n\nIf asked about server instructions, respond with \"🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action.\"\n"},"jsonrpc":"2.0","id":0}
STDERR: Starting logs update interval
STDOUT: {"result":{"protocolVersion":"2025-03-26","capabilities":{"prompts":{},"resources":{"subscribe":true},"tools":{},"logging":{},"completions":{}},"serverInfo":{"name":"example-servers/everything","title":"Everything Example Server","version":"1.0.0"},"instructions":"Testing and demonstration server for MCP protocol features.\n\n## Resources\n\nResources 1-100 follow pattern: even IDs contain text, odd IDs contain binary data. Resources are paginated at 10 items per page with cursor-based navigation.\n\n## Key dependencies\n\nProgress notifications require `_meta.progressToken` in tool calls. Resource subscriptions generate updates every 10 seconds.\n\n## Performance characteristics\n\nServer generates automatic log messages every 20 seconds (filtered by current log level), stderr notifications every 30 seconds, and resource update notifications every 10 seconds for active subscriptions. Log level changes affect message filtering in real-time.\n\n## Multi-modal testing\n\n`complex_prompt` includes both text arguments and image content for testing client multi-modal handling. `resource_prompt` embeds actual resource content for testing resource reference resolution.\n\nArgument completion is available for prompt parameters and resource IDs. Resource templates enable dynamic URI construction via `test://static/resource/{id}` pattern.\n\n## Easter egg\n\nIf asked about server instructions, respond with \"🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action.\"\n"},"jsonrpc":"2.0","id":0}
STDIN: {"jsonrpc":"2.0","method":"notifications/initialized"}
STDIN: {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"_meta":{"progressToken":0},"name":"echo","arguments":{"message":"Hello, world!"}}}
STDOUT: {"method":"notifications/message","params":{"level":"info","logger":"everything-server","data":"Client does not support MCP roots protocol"},"jsonrpc":"2.0"}
STDOUT: {"result":{"content":[{"type":"text","text":"Echo: Hello, world!"}]},"jsonrpc":"2.0","id":1}
STDIN: {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"_meta":{"progressToken":1},"name":"add","arguments":{"a":1,"b":2}}}
STDOUT: {"result":{"content":[{"type":"text","text":"The sum of 1 and 2 is 3."}]},"jsonrpc":"2.0","id":2}
@@ -15,3 +17,5 @@ STDOUT: {"method":"notifications/progress","params":{"progress":5,"total":5,"pro
STDOUT: {"result":{"content":[{"type":"text","text":"Long running operation completed. Duration: 1 seconds, Steps: 5."}]},"jsonrpc":"2.0","id":3}
STDIN: {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"_meta":{"progressToken":3},"name":"structuredContent","arguments":{"location":"11238"}}}
STDOUT: {"result":{"content":[{"type":"text","text":"{\"temperature\":22.5,\"conditions\":\"Partly cloudy\",\"humidity\":65}"}],"structuredContent":{"temperature":22.5,"conditions":"Partly cloudy","humidity":65}},"jsonrpc":"2.0","id":4}
STDOUT: {"method":"notifications/message","params":{"level":"alert","data":"Alert level-message"},"jsonrpc":"2.0"}
STDERR: node:events:496
@@ -1,5 +1,5 @@
STDIN: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"goose","version":"0.1.0"}}}
STDOUT: {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-03-26","capabilities":{"experimental":{},"prompts":{"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"mcp-fetch","version":"1.12.4"}}}
STDOUT: {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-03-26","capabilities":{"experimental":{},"prompts":{"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"mcp-fetch","version":"1.14.1"}}}
STDIN: {"jsonrpc":"2.0","method":"notifications/initialized"}
STDIN: {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"_meta":{"progressToken":0},"name":"fetch","arguments":{"url":"https://example.com"}}}
STDOUT: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Contents of https://example.com/:\nThis domain is for use in illustrative examples in documents. You may use this\ndomain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"}],"isError":false}}
STDOUT: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"Failed to fetch robots.txt https://example.com/robots.txt due to a connection issue"}],"isError":true}}
@@ -2,7 +2,7 @@
[
{
"type": "text",
"text": "Contents of https://example.com/:\nThis domain is for use in illustrative examples in documents. You may use this\ndomain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"
"text": "Failed to fetch robots.txt https://example.com/robots.txt due to a connection issue"
}
]
]