Skip to content

Commit 59c9758

Browse files
authored
docs: format and fix typo (#72)
1 parent 145b5de commit 59c9758

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
</div>
44

55
# RMCP
6+
67
[![Crates.io Version](https://img.shields.io/crates/v/rmcp)](https://crates.io/crates/rmcp)
78
![Release status](https://github.com/modelcontextprotocol/rust-sdk/actions/workflows/release.yml/badge.svg)
89
[![docs.rs](https://img.shields.io/docsrs/rmcp)](https://docs.rs/rmcp/latest/rmcp)
@@ -12,14 +13,17 @@ An official rust Model Context Protocol SDK implementation with tokio async runt
1213
## Usage
1314

1415
### Import
16+
1517
```toml
1618
rmcp = { version = "0.1", features = ["server"] }
1719
## or dev channel
1820
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main" }
1921
```
2022

2123
### Quick start
24+
2225
Start a client in one line:
26+
2327
```rust
2428
use rmcp::{ServiceExt, transport::TokioChildProcess};
2529
use tokio::process::Command;
@@ -47,48 +51,55 @@ For client, the sink item is [`ClientJsonRpcMessage`](crate::model::ClientJsonRp
4751
For server, the sink item is [`ServerJsonRpcMessage`](crate::model::ServerJsonRpcMessage) and stream item is [`ClientJsonRpcMessage`](crate::model::ClientJsonRpcMessage)
4852

4953
##### These types is automatically implemented [`IntoTransport`](crate::transport::IntoTransport) trait
54+
5055
1. The types that already implement both [`Sink`](futures::Sink) and [`Stream`](futures::Stream) trait.
5156
2. A tuple of sink `Tx` and stream `Rx`: `(Tx, Rx)`.
5257
3. The type that implement both [`tokio::io::AsyncRead`] and [`tokio::io::AsyncWrite`] trait.
53-
4. A tuple of [`tokio::io::AsyncRead`] `R `and [`tokio::io::AsyncWrite`] `W`: `(R, W)`.
58+
4. A tuple of [`tokio::io::AsyncRead`] `R `and [`tokio::io::AsyncWrite`] `W`: `(R, W)`.
5459

5560
For example, you can see how we build a transport through TCP stream or http upgrade so easily. [examples](examples/README.md)
5661

5762
#### 2. Build a service
63+
5864
You can easily build a service by using [`ServerHandler`](crates/rmcp/src/handler/server.rs) or [`ClientHandler`](crates/rmcp/src/handler/client.rs).
5965

6066
```rust, ignore
6167
let service = common::counter::Counter::new();
6268
```
6369

6470
#### 3. Serve them together
71+
6572
```rust, ignore
6673
// this call will finish the initialization process
6774
let server = service.serve(transport).await?;
6875
```
6976

7077
#### 4. Interact with the server
78+
7179
Once the server is initialized, you can send requests or notifications:
7280

7381
```rust, ignore
74-
// request
82+
// request
7583
let roots = server.list_roots().await?;
7684
7785
// or send notification
7886
server.notify_cancelled(...).await?;
7987
```
8088

8189
#### 5. Waiting for service shutdown
90+
8291
```rust, ignore
8392
let quit_reason = server.waiting().await?;
8493
// or cancel it
8594
let quit_reason = server.cancel().await?;
8695
```
8796

8897
### Use marcos to declaring tool
98+
8999
Use `toolbox` and `tool` macros to create tool quickly.
90100

91101
Check this [file](examples/servers/src/common/calculator.rs).
102+
92103
```rust, ignore
93104
use rmcp::{ServerHandler, model::ServerInfo, schemars, tool};
94105
@@ -141,33 +152,39 @@ impl ServerHandler for Calculator {
141152
}
142153
143154
```
155+
144156
The only thing you should do is to make the function's return type implement `IntoCallToolResult`.
145157

146-
And you can just implement `IntoContents`, and the return value will be marked as success automatically.
158+
And you can just implement `IntoContents`, and the return value will be marked as success automatically.
147159

148160
If you return a type of `Result<T, E>` where `T` and `E` both implemented `IntoContents`, it's also OK.
149161

150162
### Manage Multi Services
163+
151164
For many cases you need to manage several service in a collection, you can call `into_dyn` to convert services into the same type.
165+
152166
```rust, ignore
153167
let service = service.into_dyn();
154168
```
155169

156-
157170
### Examples
171+
158172
See [examples](examples/README.md)
159173

160174
### Features
175+
161176
- `client`: use client side sdk
162177
- `server`: use server side sdk
163178
- `macros`: macros default
179+
164180
#### Transports
181+
165182
- `transport-io`: Server stdio transport
166183
- `transport-sse-server`: Server SSE transport
167184
- `transport-child-process`: Client stdio transport
168185
- `transport-sse`: Client sse transport
169186

170187
## Related Resources
171-
- [MCP Specification](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
172188

189+
- [MCP Specification](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
173190
- [Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts)

examples/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
# Server Examples
99

10-
- [Server SSE](servers/src/axum.rs), using axum as web server.
11-
- [Server stdio](servers/src/std_io.rs), using tokio async io.
12-
10+
- [Server SSE](servers/src/axum.rs), using axum as web server.
11+
- [Server stdio](servers/src/std_io.rs), using tokio async io.
1312

1413
# Transport Examples
1514

@@ -18,14 +17,16 @@
1817
- [Unix Socket](transport/src/unix_socket.rs)
1918
- [Websocket](transport/src/websocket.rs)
2019

20+
# Integration
2121

22-
# Intergration
2322
- [Rig](examples/rig-integration) A stream chatbot with rig
2423

2524
# WASI
25+
2626
- [WASI-P2 runtime](examples/wasi) How it works with wasip2
2727

2828
## Use Mcp Inspector
29+
2930
```sh
3031
npx @modelcontextprotocol/inspector
3132
```

examples/wasi/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
```sh
22
cargo build -p wasi --target wasm32-wasip2
3-
npx @modelcontextprotocol/inspector wasmtime target/wasm32-wasip2/debug/wasi.wasm
4-
```
3+
npx @modelcontextprotocol/inspector wasmtime target/wasm32-wasip2/debug/wasi.wasm
4+
```

0 commit comments

Comments
 (0)