@@ -24,7 +24,7 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "mai
2424
2525Start a client in one line:
2626
27- ``` rust
27+ ``` rust, ignore
2828use rmcp::{ServiceExt, transport::TokioChildProcess};
2929use tokio::process::Command;
3030
@@ -37,7 +37,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3737}
3838```
3939
40- #### 1. Build a transport
40+ <details >
41+ <summary >1. Build a transport</summary >
4142
4243``` rust, ignore
4344use tokio::io::{stdin, stdout};
@@ -58,48 +59,59 @@ For server, the sink item is [`ServerJsonRpcMessage`](crate::model::ServerJsonRp
58594 . A tuple of [ ` tokio::io::AsyncRead ` ] ` R ` and [ ` tokio::io::AsyncWrite ` ] ` W ` : ` (R, W) ` .
5960
6061For example, you can see how we build a transport through TCP stream or http upgrade so easily. [ examples] ( examples/README.md )
62+ </details >
6163
62- #### 2. Build a service
64+ <details >
65+ <summary >2. Build a service</summary >
6366
6467You can easily build a service by using [ ` ServerHandler ` ] ( crates/rmcp/src/handler/server.rs ) or [ ` ClientHandler ` ] ( crates/rmcp/src/handler/client.rs ) .
6568
6669``` rust, ignore
6770let service = common::counter::Counter::new();
6871```
72+ </details >
6973
70- #### 3. Serve them together
74+ <details >
75+ <summary >3. Serve them together</summary >
7176
7277``` rust, ignore
7378// this call will finish the initialization process
7479let server = service.serve(transport).await?;
7580```
81+ </details >
7682
77- #### 4. Interact with the server
83+ <details >
84+ <summary >4. Interact with the server</summary >
7885
7986Once the server is initialized, you can send requests or notifications:
8087
8188``` rust, ignore
82- // request
89+ // request
8390let roots = server.list_roots().await?;
8491
8592// or send notification
8693server.notify_cancelled(...).await?;
8794```
95+ </details >
8896
89- #### 5. Waiting for service shutdown
97+ <details >
98+ <summary >5. Waiting for service shutdown</summary >
9099
91100``` rust, ignore
92101let quit_reason = server.waiting().await?;
93102// or cancel it
94103let quit_reason = server.cancel().await?;
95104```
105+ </details >
96106
97107### Use macros to declaring tool
98108
99109Use ` toolbox ` and ` tool ` macros to create tool quickly.
100110
101- Check this [ file] ( examples/servers/src/common/calculator.rs ) .
111+ <details >
112+ <summary >Example: Calculator Tool</summary >
102113
114+ Check this [ file] ( examples/servers/src/common/calculator.rs ) .
103115``` rust, ignore
104116use rmcp::{ServerHandler, model::ServerInfo, schemars, tool};
105117
@@ -150,19 +162,19 @@ impl ServerHandler for Calculator {
150162 }
151163 }
152164}
153-
154165```
155166
167+
156168The only thing you should do is to make the function's return type implement ` IntoCallToolResult ` .
157169
158170And you can just implement ` IntoContents ` , and the return value will be marked as success automatically.
159171
160172If you return a type of ` Result<T, E> ` where ` T ` and ` E ` both implemented ` IntoContents ` , it's also OK.
173+ </details >
161174
162175### Manage Multi Services
163176
164177For many cases you need to manage several service in a collection, you can call ` into_dyn ` to convert services into the same type.
165-
166178``` rust, ignore
167179let service = service.into_dyn();
168180```
@@ -177,7 +189,7 @@ See [examples](examples/README.md)
177189- ` server ` : use server side sdk
178190- ` macros ` : macros default
179191
180- #### Transports
192+ ### Transports
181193
182194- ` transport-io ` : Server stdio transport
183195- ` transport-sse-server ` : Server SSE transport
@@ -189,6 +201,8 @@ See [examples](examples/README.md)
189201- [ MCP Specification] ( https://spec.modelcontextprotocol.io/specification/2024-11-05/ )
190202- [ Schema] ( https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts )
191203
192- ## Development with Dev Container
204+ ## Related Projects
205+ - [ containerd-mcp-server] ( https://github.com/modelcontextprotocol/containerd-mcp-server ) - A containerd-based MCP server implementation
193206
207+ ## Development with Dev Container
194208See [ docs/DEVCONTAINER.md] ( docs/DEVCONTAINER.md ) for instructions on using Dev Container for development.
0 commit comments