You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[MCP protocol versions with corresponding features](#mcp-protocol-versions-with-corresponding-features)
@@ -111,10 +114,14 @@ See hello-world-mcp-server example running in [MCP Inspector](https://modelconte
111
114
112
115

113
116
114
-
### MCP Server (sse)
117
+
### MCP Server (Streamable HTTP)
115
118
116
119
Creating an MCP server in `rust-mcp-sdk` with the `sse` transport allows multiple clients to connect simultaneously with no additional setup.
117
-
Simply create a Hyper Server using `hyper_server::create_server()` and pass in the same handler and transform options.
120
+
Simply create a Hyper Server using `hyper_server::create_server()` and pass in the same handler and HyperServerOptions.
121
+
122
+
123
+
💡 By default, both **Streamable HTTP** and **SSE** transports are enabled for backward compatibility. To disable the SSE transport , set the `sse_support` to false in the `HyperServerOptions`.
124
+
118
125
119
126
```rust
120
127
@@ -145,6 +152,7 @@ let server = hyper_server::create_server(
145
152
handler,
146
153
HyperServerOptions {
147
154
host:"127.0.0.1".to_string(),
155
+
sse_support:false,
148
156
..Default::default()
149
157
},
150
158
);
@@ -199,9 +207,9 @@ impl ServerHandler for MyServerHandler {
199
207
200
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)**
201
209
202
-
See hello-world-server-sse example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
210
+
See hello-world-server-streamable-http example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
203
211
204
-

212
+

205
213
206
214
---
207
215
@@ -303,6 +311,103 @@ Creating an MCP client using the `rust-mcp-sdk` with the SSE transport is almost
303
311
304
312
If you are looking for a step-by-step tutorial on how to get started with `rust-mcp-sdk` , please see : [Getting Started MCP Server](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/doc/getting-started-mcp-server.md)
305
313
314
+
## HyperServerOptions
315
+
316
+
HyperServer is a lightweight Axum-based server that streamlines MCP servers by supporting **Streamable HTTP** and **SSE** transports. It supports simultaneous client connections, internal session management, and includes built-in security features like DNS rebinding protection and more.
317
+
318
+
HyperServer is highly customizable through HyperServerOptions provided during initialization.
319
+
320
+
A typical example of creating a HyperServer that exposes the MCP server via Streamable HTTP and SSE transports at:
321
+
322
+
```rs
323
+
324
+
letserver=hyper_server::create_server(
325
+
server_details,
326
+
handler,
327
+
HyperServerOptions {
328
+
host:"127.0.0.1".to_string(),
329
+
enable_ssl:true,
330
+
..Default::default()
331
+
},
332
+
);
333
+
334
+
server.start().await?;
335
+
336
+
```
337
+
338
+
Here is a list of available options with descriptions for configuring the HyperServer:
339
+
```rs
340
+
pubstructHyperServerOptions {
341
+
/// Hostname or IP address the server will bind to (default: "127.0.0.1")
342
+
pubhost:String,
343
+
344
+
/// Hostname or IP address the server will bind to (default: "8080")
345
+
pubport:u16,
346
+
347
+
/// Optional custom path for the Streamable HTTP endpoint (default: `/mcp`)
/// Path to the SSL/TLS certificate file (e.g., "cert.pem").
369
+
/// Required if `enable_ssl` is `true`.
370
+
pubssl_cert_path:Option<String>,
371
+
372
+
/// Path to the SSL/TLS private key file (e.g., "key.pem").
373
+
/// Required if `enable_ssl` is `true`.
374
+
pubssl_key_path:Option<String>,
375
+
376
+
/// If set to true, the SSE transport will also be supported for backward compatibility (default: true)
377
+
pubsse_support:bool,
378
+
379
+
/// Optional custom path for the Server-Sent Events (SSE) endpoint (default: `/sse`)
380
+
/// Applicable only if sse_support is true
381
+
pubcustom_sse_endpoint:Option<String>,
382
+
383
+
/// Optional custom path for the MCP messages endpoint for sse (default: `/messages`)
384
+
/// Applicable only if sse_support is true
385
+
pubcustom_messages_endpoint:Option<String>,
386
+
387
+
/// List of allowed host header values for DNS rebinding protection.
388
+
/// If not specified, host validation is disabled.
389
+
puballowed_hosts:Option<Vec<String>>,
390
+
391
+
/// List of allowed origin header values for DNS rebinding protection.
392
+
/// If not specified, origin validation is disabled.
393
+
puballowed_origins:Option<Vec<String>>,
394
+
395
+
/// Enable DNS rebinding protection (requires allowedHosts and/or allowedOrigins to be configured).
396
+
/// Default is false for backwards compatibility.
397
+
pubdns_rebinding_protection:bool,
398
+
}
399
+
400
+
```
401
+
402
+
### Security Considerations
403
+
404
+
When using Streamable HTTP transport, following security best practices are recommended:
405
+
406
+
- Enable DNS rebinding protection and provide proper `allowed_hosts` and `allowed_origins` to prevent DNS rebinding attacks.
407
+
- When running locally, bind only to localhost (127.0.0.1 / localhost) rather than all network interfaces (0.0.0.0)
408
+
- Use TLS/HTTPS for production deployments
409
+
410
+
306
411
## Cargo Features
307
412
308
413
The `rust-mcp-sdk` crate provides several features that can be enabled or disabled. By default, all features are enabled to ensure maximum functionality, but you can customize which ones to include based on your project's requirements.
-[MCP protocol versions with corresponding features](#mcp-protocol-versions-with-corresponding-features)
@@ -111,10 +114,14 @@ See hello-world-mcp-server example running in [MCP Inspector](https://modelconte
111
114
112
115

113
116
114
-
### MCP Server (sse)
117
+
### MCP Server (Streamable HTTP)
115
118
116
119
Creating an MCP server in `rust-mcp-sdk` with the `sse` transport allows multiple clients to connect simultaneously with no additional setup.
117
-
Simply create a Hyper Server using `hyper_server::create_server()` and pass in the same handler and transform options.
120
+
Simply create a Hyper Server using `hyper_server::create_server()` and pass in the same handler and HyperServerOptions.
121
+
122
+
123
+
💡 By default, both **Streamable HTTP** and **SSE** transports are enabled for backward compatibility. To disable the SSE transport , set the `sse_support` to false in the `HyperServerOptions`.
124
+
118
125
119
126
```rust
120
127
@@ -145,6 +152,7 @@ let server = hyper_server::create_server(
145
152
handler,
146
153
HyperServerOptions {
147
154
host:"127.0.0.1".to_string(),
155
+
sse_support:false,
148
156
..Default::default()
149
157
},
150
158
);
@@ -199,9 +207,9 @@ impl ServerHandler for MyServerHandler {
199
207
200
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)**
201
209
202
-
See hello-world-server-sse example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
210
+
See hello-world-server-streamable-http example running in [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) :
203
211
204
-

212
+

205
213
206
214
---
207
215
@@ -303,6 +311,103 @@ Creating an MCP client using the `rust-mcp-sdk` with the SSE transport is almost
303
311
304
312
If you are looking for a step-by-step tutorial on how to get started with `rust-mcp-sdk` , please see : [Getting Started MCP Server](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/doc/getting-started-mcp-server.md)
305
313
314
+
## HyperServerOptions
315
+
316
+
HyperServer is a lightweight Axum-based server that streamlines MCP servers by supporting **Streamable HTTP** and **SSE** transports. It supports simultaneous client connections, internal session management, and includes built-in security features like DNS rebinding protection and more.
317
+
318
+
HyperServer is highly customizable through HyperServerOptions provided during initialization.
319
+
320
+
A typical example of creating a HyperServer that exposes the MCP server via Streamable HTTP and SSE transports at:
321
+
322
+
```rs
323
+
324
+
letserver=hyper_server::create_server(
325
+
server_details,
326
+
handler,
327
+
HyperServerOptions {
328
+
host:"127.0.0.1".to_string(),
329
+
enable_ssl:true,
330
+
..Default::default()
331
+
},
332
+
);
333
+
334
+
server.start().await?;
335
+
336
+
```
337
+
338
+
Here is a list of available options with descriptions for configuring the HyperServer:
339
+
```rs
340
+
pubstructHyperServerOptions {
341
+
/// Hostname or IP address the server will bind to (default: "127.0.0.1")
342
+
pubhost:String,
343
+
344
+
/// Hostname or IP address the server will bind to (default: "8080")
345
+
pubport:u16,
346
+
347
+
/// Optional custom path for the Streamable HTTP endpoint (default: `/mcp`)
/// Path to the SSL/TLS certificate file (e.g., "cert.pem").
369
+
/// Required if `enable_ssl` is `true`.
370
+
pubssl_cert_path:Option<String>,
371
+
372
+
/// Path to the SSL/TLS private key file (e.g., "key.pem").
373
+
/// Required if `enable_ssl` is `true`.
374
+
pubssl_key_path:Option<String>,
375
+
376
+
/// If set to true, the SSE transport will also be supported for backward compatibility (default: true)
377
+
pubsse_support:bool,
378
+
379
+
/// Optional custom path for the Server-Sent Events (SSE) endpoint (default: `/sse`)
380
+
/// Applicable only if sse_support is true
381
+
pubcustom_sse_endpoint:Option<String>,
382
+
383
+
/// Optional custom path for the MCP messages endpoint for sse (default: `/messages`)
384
+
/// Applicable only if sse_support is true
385
+
pubcustom_messages_endpoint:Option<String>,
386
+
387
+
/// List of allowed host header values for DNS rebinding protection.
388
+
/// If not specified, host validation is disabled.
389
+
puballowed_hosts:Option<Vec<String>>,
390
+
391
+
/// List of allowed origin header values for DNS rebinding protection.
392
+
/// If not specified, origin validation is disabled.
393
+
puballowed_origins:Option<Vec<String>>,
394
+
395
+
/// Enable DNS rebinding protection (requires allowedHosts and/or allowedOrigins to be configured).
396
+
/// Default is false for backwards compatibility.
397
+
pubdns_rebinding_protection:bool,
398
+
}
399
+
400
+
```
401
+
402
+
### Security Considerations
403
+
404
+
When using Streamable HTTP transport, following security best practices are recommended:
405
+
406
+
- Enable DNS rebinding protection and provide proper `allowed_hosts` and `allowed_origins` to prevent DNS rebinding attacks.
407
+
- When running locally, bind only to localhost (127.0.0.1 / localhost) rather than all network interfaces (0.0.0.0)
408
+
- Use TLS/HTTPS for production deployments
409
+
410
+
306
411
## Cargo Features
307
412
308
413
The `rust-mcp-sdk` crate provides several features that can be enabled or disabled. By default, all features are enabled to ensure maximum functionality, but you can customize which ones to include based on your project's requirements.
0 commit comments