Skip to content

Commit d695046

Browse files
authored
fix: enable task support on counter long_task example (modelcontextprotocol#838)
* fix: enable task support on counter long_task example * ci: include example targets when testing example crates
1 parent 5ccdfc0 commit d695046

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ jobs:
259259
if [ -f "$dir/Cargo.toml" ]; then
260260
if [[ "$dir" != *"wasi"* ]]; then
261261
echo "Testing $dir"
262-
cargo test --manifest-path "$dir/Cargo.toml" --all-features
262+
cargo test --manifest-path "$dir/Cargo.toml" --all-features --all-targets
263263
fi
264264
fi
265265
done

examples/servers/src/common/counter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ impl Counter {
103103
)]))
104104
}
105105

106-
#[tool(description = "Long running task example")]
106+
#[tool(
107+
description = "Long running task example",
108+
execution(task_support = "optional")
109+
)]
107110
async fn long_task(&self) -> Result<CallToolResult, McpError> {
108111
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
109112
Ok(CallToolResult::success(vec![Content::text(
@@ -360,7 +363,7 @@ mod tests {
360363
"source".into(),
361364
serde_json::Value::String("integration-test".into()),
362365
);
363-
let params = CallToolRequestParams::new("long_task").with_task(Some(task_meta));
366+
let params = CallToolRequestParams::new("long_task").with_task(task_meta);
364367
let response = client_service
365368
.send_request(ClientRequest::CallToolRequest(Request::new(params.clone())))
366369
.await?;

0 commit comments

Comments
 (0)