Skip to content

Commit 51af21a

Browse files
committed
Add Streamable HTTP Client and multiple refactoring and improvements
1 parent 3508e1e commit 51af21a

File tree

105 files changed

+5330
-692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+5330
-692
lines changed

.release-manifest.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"crates/rust-mcp-sdk": "0.6.3",
33
"crates/rust-mcp-macros": "0.5.1",
4-
"crates/rust-mcp-transport": "0.5.1",
5-
"examples/hello-world-mcp-server": "0.1.31",
6-
"examples/hello-world-mcp-server-core": "0.1.22",
7-
"examples/simple-mcp-client": "0.1.31",
8-
"examples/simple-mcp-client-core": "0.1.31",
9-
"examples/hello-world-server-core-streamable-http": "0.1.22",
10-
"examples/hello-world-server-streamable-http": "0.1.31",
11-
"examples/simple-mcp-client-core-sse": "0.1.22",
12-
"examples/simple-mcp-client-sse": "0.1.22"
4+
"crates/rust-mcp-transport": "0.5.0",
5+
"examples/hello-world-mcp-server-stdio": "0.1.28",
6+
"examples/hello-world-mcp-server-stdio-core": "0.1.19",
7+
"examples/simple-mcp-client-stdio": "0.1.28",
8+
"examples/simple-mcp-client-stdio-core": "0.1.28",
9+
"examples/hello-world-server-streamable-http-core": "0.1.19",
10+
"examples/hello-world-server-streamable-http": "0.1.28",
11+
"examples/simple-mcp-client-sse-core": "0.1.19",
12+
"examples/simple-mcp-client-sse": "0.1.19",
13+
"examples/simple-mcp-client-streamable-http": "0.1.0",
14+
"examples/simple-mcp-client-streamable-http-core": "0.1.0"
1315
}

Cargo.lock

Lines changed: 67 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ members = [
44
"crates/rust-mcp-macros",
55
"crates/rust-mcp-sdk",
66
"crates/rust-mcp-transport",
7-
"examples/simple-mcp-client",
8-
"examples/simple-mcp-client-core",
9-
"examples/hello-world-mcp-server",
10-
"examples/hello-world-mcp-server-core",
7+
"examples/simple-mcp-client-stdio",
8+
"examples/simple-mcp-client-stdio-core",
9+
"examples/hello-world-mcp-server-stdio",
10+
"examples/hello-world-mcp-server-stdio-core",
1111
"examples/hello-world-server-streamable-http",
12-
"examples/hello-world-server-core-streamable-http",
12+
"examples/hello-world-server-streamable-http-core",
1313
"examples/simple-mcp-client-sse",
14-
"examples/simple-mcp-client-core-sse",
14+
"examples/simple-mcp-client-sse-core",
15+
"examples/simple-mcp-client-streamable-http",
16+
"examples/simple-mcp-client-streamable-http-core",
17+
1518
]
1619

1720
[workspace.dependencies]
@@ -39,7 +42,7 @@ tracing-subscriber = { version = "0.3", features = [
3942
"std",
4043
"fmt",
4144
] }
42-
45+
base64 = "0.22"
4346
axum = "0.8"
4447
rustls = "0.23"
4548
tokio-rustls = "0.26"

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rust-mcp-stack/rust-mcp-sdk/ci.yml?style=for-the-badge" height="22">
1010
](https://github.com/rust-mcp-stack/rust-mcp-sdk/actions/workflows/ci.yml)
1111
[<img alt="Hello World MCP Server" src="https://img.shields.io/badge/Example-Hello%20World%20MCP-0286ba?style=for-the-badge&logo=rust" height="22">
12-
](examples/hello-world-mcp-server)
12+
](examples/hello-world-mcp-server-stdio)
1313

1414
A high-performance, asynchronous toolkit for building MCP servers and clients.
1515
Focus on your app's logic while **rust-mcp-sdk** takes care of the rest!
@@ -42,6 +42,17 @@ This project supports following transports:
4242
- ⬜ Resumability
4343
- ⬜ Authentication / Oauth
4444

45+
46+
47+
**MCP Streamable HTTP Support**
48+
- [x] Streamable HTTP Support for MCP Servers
49+
- [x] DNS Rebinding Protection
50+
- [x] Batch Messages
51+
- [x] Streaming & non-streaming JSON response
52+
- [ ] Streamable HTTP Support for MCP Clients
53+
- [ ] Resumability
54+
- [ ] Authentication / Oauth
55+
4556
**⚠️** Project is currently under development and should be used at your own risk.
4657

4758
## Table of Contents
@@ -110,7 +121,7 @@ async fn main() -> SdkResult<()> {
110121
}
111122
```
112123

113-
See hello-world-mcp-server example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
124+
See hello-world-mcp-server-stdio example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
114125

115126
![mcp-server in rust](assets/examples/hello-world-mcp-server.gif)
116127

@@ -180,7 +191,7 @@ pub struct MyServerHandler;
180191
#[async_trait]
181192
impl ServerHandler for MyServerHandler {
182193
// Handle ListToolsRequest, return list of available tools as ListToolsResult
183-
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: &dyn McpServer) -> Result<ListToolsResult, RpcError> {
194+
async fn handle_list_tools_request(&self, request: ListToolsRequest, runtime: Arc<dyn McpServer>) -> Result<ListToolsResult, RpcError> {
184195

185196
Ok(ListToolsResult {
186197
tools: vec![SayHelloTool::tool()],
@@ -191,7 +202,7 @@ impl ServerHandler for MyServerHandler {
191202
}
192203

193204
/// Handles requests to call a specific tool.
194-
async fn handle_call_tool_request( &self, request: CallToolRequest, runtime: &dyn McpServer, ) -> Result<CallToolResult, CallToolError> {
205+
async fn handle_call_tool_request( &self, request: CallToolRequest, runtime: Arc<dyn McpServer>, ) -> Result<CallToolResult, CallToolError> {
195206

196207
if request.tool_name() == SayHelloTool::tool_name() {
197208
Ok( CallToolResult::text_content( vec![TextContent::from("Hello World!".to_string())] ))
@@ -205,7 +216,7 @@ impl ServerHandler for MyServerHandler {
205216

206217
---
207218

208-
👉 For a more detailed example of a [Hello World MCP](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server) Server that supports multiple tools and provides more type-safe handling of `CallToolRequest`, check out: **[examples/hello-world-mcp-server](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server)**
219+
👉 For a more detailed example of a [Hello World MCP](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server-stdio) Server that supports multiple tools and provides more type-safe handling of `CallToolRequest`, check out: **[examples/hello-world-mcp-server](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server)**
209220

210221
See hello-world-server-streamable-http example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
211222

@@ -477,10 +488,10 @@ Learn when to use the `mcp_*_handler` traits versus the lower-level `mcp_*_hand
477488
[rust-mcp-sdk](https://github.com/rust-mcp-stack/rust-mcp-sdk) provides two type of handler traits that you can chose from:
478489

479490
- **ServerHandler**: This is the recommended trait for your MCP project, offering a default implementation for all types of MCP messages. It includes predefined implementations within the trait, such as handling initialization or responding to ping requests, so you only need to override and customize the handler functions relevant to your specific needs.
480-
Refer to [examples/hello-world-mcp-server/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server/src/handler.rs) for an example.
491+
Refer to [examples/hello-world-mcp-server-stdio/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server-stdio/src/handler.rs) for an example.
481492

482493
- **ServerHandlerCore**: If you need more control over MCP messages, consider using `ServerHandlerCore`. It offers three primary methods to manage the three MCP message types: `request`, `notification`, and `error`. While still providing type-safe objects in these methods, it allows you to determine how to handle each message based on its type and parameters.
483-
Refer to [examples/hello-world-mcp-server-core/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server-core/src/handler.rs) for an example.
494+
Refer to [examples/hello-world-mcp-server-stdio-core/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server-stdio-core/src/handler.rs) for an example.
484495

485496
---
486497

@@ -509,7 +520,7 @@ Both functions create an MCP client instance.
509520

510521

511522

512-
Check out the corresponding examples at: [examples/simple-mcp-client](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client) and [examples/simple-mcp-client-core](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-core).
523+
Check out the corresponding examples at: [examples/simple-mcp-client-stdio](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-stdio) and [examples/simple-mcp-client-stdio-core](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-stdio-core).
513524

514525

515526
## Projects using Rust MCP SDK

0 commit comments

Comments
 (0)