Move whole rmcp crate to offcial rust sdk (#44)

* get rid of async-trait

* move rmcp to official-rust-sdk

* replace master with main

* update readme, change license

* fix typo

* Update README.md

Co-authored-by: Jefry Dewangga <jefrydco@gmail.com>

* fix typos

---------

Co-authored-by: = <=>
Co-authored-by: Jefry Dewangga <jefrydco@gmail.com>
This commit is contained in:
4t145 2025-03-28 05:33:41 +08:00 • committed by GitHub
commit 0be6067326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,86 +1,31 @@
# Model Context Protocol Examples
# Client Examples
This directory contains examples demonstrating how to use the Model Context Protocol (MCP) Rust SDK.
- [Client SSE](clients/src/sse.rs), using reqwest and eventsource-client.
- [Client stdio](clients/src/std_io.rs), using tokio to spawn child process.
- [Everything](clients/src/everything_stdio.rs), test with `@modelcontextprotocol/server-everything`
- [Collection](clients/src/collection.rs), How to transpose service into dynamic object, so they will have a same type.
## Structure
# Server Examples
- `clients/`: Examples of MCP clients
- `servers/`: Examples of MCP servers
- `macros/`: Examples of MCP macros
- [Server SSE](servers/src/axum.rs), using axum as web server.
- [Server stdio](servers/src/std_io.rs), using tokio async io.
## Running Client Examples
The client examples demonstrate different ways to connect to MCP servers.
# Transport Examples
Before running the examples, ensure you have `uv` installed. You can find the installation instructions [here](https://github.com/astral-sh/uv).
- [Tcp](transport/src/tcp.rs)
- [Transport on http upgrade](transport/src/http_upgrade.rs)
- [Unix Socket](transport/src/unix_socket.rs)
- [Websocket](transport/src/websocket.rs)
### Available Examples
You can run the examples in two ways:
# Intergration
- [Rig](examples/rig-integration) A stream chatbot with rig
#### Option 1: From the examples/clients directory
# WASI
- [WASI-P2 runtime](examples/wasi) How it works with wasip2
```bash
cd examples/clients
cargo run --example clients
cargo run --example sse
cargo run --example stdio
cargo run --example stdio_integration
## Use Mcp Inspector
```sh
npx @modelcontextprotocol/inspector
```
#### Option 2: From the root directory
```bash
cargo run -p mcp-client-examples --example clients
cargo run -p mcp-client-examples --example sse
cargo run -p mcp-client-examples --example stdio
cargo run -p mcp-client-examples --example stdio_integration
```
## Running Server Examples
The server examples demonstrate how to implement MCP servers.
### Available Examples
You can run the server examples in two ways:
#### Option 1: From the examples/servers directory
```bash
cd examples/servers
cargo run --example counter-server
```
#### Option 2: From the root directory
```bash
cargo run -p mcp-server-examples --example counter-server
```
## Running Macros Examples
The macros examples demonstrate how to use the MCP macros to create tools.
### Available Examples
You can run the macros examples in two ways:
#### Option 1: From the examples/macros directory
```bash
cd examples/macros
cargo run --example calculator
```
#### Option 2: From the root directory
```bash
cargo run -p mcp-macros-examples --example calculator
```
## Notes
- Some examples may require additional setup or running both client and server components.
- The server examples use standard I/O for communication, so they can be connected to client examples using stdio transport.
- For SSE examples, you may need to run a separate SSE server or use a compatible MCP server implementation.