Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions src/agent-client-protocol/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! ```

use crate::schema::{InitializeRequest, InitializeResponse};
use serde_json::json;
use serde_json::{json, Value};

/// Trait for capabilities stored in the `_meta.symposium` object.
///
Expand Down Expand Up @@ -67,7 +67,8 @@ impl MetaCapabilityExt for InitializeRequest {
.as_ref()
.and_then(|meta| meta.get("symposium"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikomatsakis on this, should we even have this symposium specific stuff in this SDK? Are you handling it on the symposium side already and maybe this is just leftover?

.and_then(|symposium| symposium.get(capability.key()))
.is_some()
.map(|v| !matches!(v, Value::Bool(false) | Value::Null))
.unwrap_or(false)
}

fn add_meta_capability(mut self, capability: impl MetaCapability) -> Self {
Expand Down Expand Up @@ -104,7 +105,8 @@ impl MetaCapabilityExt for InitializeResponse {
.as_ref()
.and_then(|meta| meta.get("symposium"))
.and_then(|symposium| symposium.get(capability.key()))
.is_some()
.map(|v| !matches!(v, Value::Bool(false) | Value::Null))
.unwrap_or(false)
}

fn add_meta_capability(mut self, capability: impl MetaCapability) -> Self {
Expand Down Expand Up @@ -185,4 +187,40 @@ mod tests {
json!(true)
);
}

#[test]
fn test_has_meta_capability_false_value() {
let mut meta = serde_json::Map::new();
meta.insert(
"symposium".to_string(),
json!({
"version": "1.0",
"mcp_acp_transport": false
}),
);
let client_capabilities = ClientCapabilities::new().meta(meta);

let request = InitializeRequest::new(ProtocolVersion::LATEST)
.client_capabilities(client_capabilities);

assert!(!request.has_meta_capability(McpAcpTransport));
}

#[test]
fn test_has_meta_capability_null_value() {
let mut meta = serde_json::Map::new();
meta.insert(
"symposium".to_string(),
json!({
"version": "1.0",
"mcp_acp_transport": null
}),
);
let client_capabilities = ClientCapabilities::new().meta(meta);

let request = InitializeRequest::new(ProtocolVersion::LATEST)
.client_capabilities(client_capabilities);

assert!(!request.has_meta_capability(McpAcpTransport));
}
}
14 changes: 5 additions & 9 deletions src/agent-client-protocol/src/mcp_server/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,13 @@ impl<Counterpart: Role> ConnectTo<role::mcp::Client> for McpServerConnection<Cou
let (mcp_client_read, mcp_client_write) = tokio::io::split(mcp_client_stream);

let run_client = async {
// Connect byte_streams to the provided client
let byte_streams =
ByteStreams::new(mcp_client_write.compat_write(), mcp_client_read.compat());
drop(
<ByteStreams<_, _> as ConnectTo<role::mcp::Client>>::connect_to(
byte_streams,
client,
)
.await,
);
Ok(())
<ByteStreams<_, _> as ConnectTo<role::mcp::Client>>::connect_to(
byte_streams,
client,
)
.await
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I am fine with. I think we need to clarify the symposium stuff. If it was separate PRs probably would have merged this change

};

let run_server = async {
Expand Down