Skip to content

Commit 31155a4

Browse files
authored
feat(examples): add streamable HTTP section in configs (#296)
1 parent ee80903 commit 31155a4

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

examples/rig-integration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rmcp = { workspace = true, features = [
2020
"reqwest",
2121
"transport-child-process",
2222
"transport-sse-client",
23+
"transport-streamable-http-client"
2324
] }
2425
anyhow = "1.0"
2526
serde_json = "1"

examples/rig-integration/src/config/mcp.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub struct McpServerConfig {
1414
#[derive(Debug, Serialize, Deserialize, Clone)]
1515
#[serde(tag = "protocol", rename_all = "lowercase")]
1616
pub enum McpServerTransportConfig {
17+
Streamable {
18+
url: String,
19+
},
1720
Sse {
1821
url: String,
1922
},
@@ -60,6 +63,11 @@ impl McpConfig {
6063
impl McpServerTransportConfig {
6164
pub async fn start(&self) -> anyhow::Result<RunningService<RoleClient, ()>> {
6265
let client = match self {
66+
McpServerTransportConfig::Streamable { url } => {
67+
let transport =
68+
rmcp::transport::StreamableHttpClientTransport::from_uri(url.to_string());
69+
().serve(transport).await?
70+
}
6371
McpServerTransportConfig::Sse { url } => {
6472
let transport = rmcp::transport::SseClientTransport::start(url.to_string()).await?;
6573
().serve(transport).await?

examples/simple-chat-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rmcp = { workspace = true, features = [
1818
"client",
1919
"transport-child-process",
2020
"transport-sse-client",
21+
"transport-streamable-http-client",
2122
"reqwest"
2223
], no-default-features = true }
2324
clap = { version = "4.0", features = ["derive"] }

examples/simple-chat-client/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub struct McpServerConfig {
2929
#[derive(Debug, Serialize, Deserialize, Clone)]
3030
#[serde(tag = "protocol", rename_all = "lowercase")]
3131
pub enum McpServerTransportConfig {
32+
Streamable {
33+
url: String,
34+
},
3235
Sse {
3336
url: String,
3437
},
@@ -44,6 +47,11 @@ pub enum McpServerTransportConfig {
4447
impl McpServerTransportConfig {
4548
pub async fn start(&self) -> Result<RunningService<RoleClient, ()>> {
4649
let client = match self {
50+
McpServerTransportConfig::Streamable { url } => {
51+
let transport =
52+
rmcp::transport::StreamableHttpClientTransport::from_uri(url.to_string());
53+
().serve(transport).await?
54+
}
4755
McpServerTransportConfig::Sse { url } => {
4856
let transport =
4957
rmcp::transport::sse_client::SseClientTransport::start(url.to_owned()).await?;

0 commit comments

Comments
 (0)