[MCP] Introduce an experimental official rust sdk based mcp client (#4252)
The [official Rust
SDK](57fc428c57)
has come a long way since we first started our mcp client implementation
5 months ago and, today, it is much more complete than our own
stdio-only implementation.
This PR introduces a new config flag `experimental_use_rmcp_client`
which will use a new mcp client powered by the sdk instead of our own.
To keep this PR simple, I've only implemented the same stdio MCP
functionality that we had but will expand on it with future PRs.
---------
Co-authored-by: pakrym-oai <pakrym@openai.com>
This commit is contained in:
@@ -70,11 +70,8 @@ async fn main() -> Result<()> {
|
||||
},
|
||||
protocol_version: MCP_SCHEMA_VERSION.to_owned(),
|
||||
};
|
||||
let initialize_notification_params = None;
|
||||
let timeout = Some(Duration::from_secs(10));
|
||||
let response = client
|
||||
.initialize(params, initialize_notification_params, timeout)
|
||||
.await?;
|
||||
let response = client.initialize(params, timeout).await?;
|
||||
eprintln!("initialize response: {response:?}");
|
||||
|
||||
// Issue `tools/list` request (no params).
|
||||
|
||||
@@ -315,13 +315,12 @@ impl McpClient {
|
||||
pub async fn initialize(
|
||||
&self,
|
||||
initialize_params: InitializeRequestParams,
|
||||
initialize_notification_params: Option<serde_json::Value>,
|
||||
timeout: Option<Duration>,
|
||||
) -> Result<mcp_types::InitializeResult> {
|
||||
let response = self
|
||||
.send_request::<InitializeRequest>(initialize_params, timeout)
|
||||
.await?;
|
||||
self.send_notification::<InitializedNotification>(initialize_notification_params)
|
||||
self.send_notification::<InitializedNotification>(None)
|
||||
.await?;
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user