fix: error for status in post method of streamable http client (#238)

This commit is contained in:
4t145 2025-05-29 14:51:24 +08:00 committed by GitHub
parent 969fad26cc
commit a66f66ae34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -95,7 +95,7 @@ impl StreamableHttpClient for reqwest::Client {
if let Some(session_id) = session_id {
request = request.header(HEADER_SESSION_ID, session_id.as_ref());
}
let response = request.json(&message).send().await?;
let response = request.json(&message).send().await?.error_for_status()?;
if response.status() == reqwest::StatusCode::ACCEPTED {
return Ok(StreamableHttpPostResponse::Accepted);
}

View file

@ -16,7 +16,7 @@ async fn main() -> Result<()> {
)
.with(tracing_subscriber::fmt::layer())
.init();
let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000");
let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000/mcp");
let client_info = ClientInfo {
protocol_version: Default::default(),
capabilities: ClientCapabilities::default(),