* add axum sse example * fix: make the sse axum folder name correct * feat: add common modules for Axum SSE example This commit adds supporting modules for the Axum Server-Sent Events (SSE) example: - Added `counter.rs` with a simple counter router implementation - Added `jsonrpc_frame_codec.rs` for decoding JSON-RPC frames - Created a `mod.rs` to expose these modules - Removed the previous SSE example configuration from Cargo.toml * refactor: remove main.rs and update Cargo.toml for WASM compatibility This commit makes two key changes: 1. Removes the main.rs file and make it a example 2. Add a wasi_std_io example * refactor: simplify WASI I/O handling in example and fmt Merged AsyncInputStream and AsyncOutputStream into a single WasiFd struct with std_in() and std_out() methods, reducing code duplication and improving clarity of the WASI standard I/O example. * move examples to root |
||
|---|---|---|
| .. | ||
| clients | ||
| macros | ||
| servers | ||
| README.md | ||
Model Context Protocol Examples
This directory contains examples demonstrating how to use the Model Context Protocol (MCP) Rust SDK.
Structure
clients/: Examples of MCP clientsservers/: Examples of MCP serversmacros/: Examples of MCP macros
Running Client Examples
The client examples demonstrate different ways to connect to MCP servers.
Available Examples
You can run the examples in two ways:
Option 1: From the examples/clients directory
cd examples/clients
cargo run --example clients
cargo run --example sse
cargo run --example stdio
cargo run --example stdio_integration
Option 2: From the root directory
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
cd examples/servers
cargo run --example counter-server
Option 2: From the root directory
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
cd examples/macros
cargo run --example calculator
Option 2: From the root directory
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.