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
@@ -386,6 +387,114 @@ Creating an MCP client using the `rust-mcp-sdk` with the SSE transport is almost
386
387
👉 see [examples/simple-mcp-client-sse](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-sse) for a complete working example.
387
388
388
389
390
+
## Macros
391
+
[rust-mcp-sdk](https://github.com/rust-mcp-stack/rust-mcp-sdk) includes several helpful macros that simplify common tasks when building MCP servers and clients. For example, they can automatically generate tool specifications and tool schemas right from your structs, or assist with elicitation requests and responses making them completely type safe.
392
+
393
+
> To use these macros, ensure the `macros` feature is enabled in your Cargo.toml.
394
+
395
+
### mcp_tool
396
+
`mcp_tool` is a procedural macro attribute that helps generating rust_mcp_schema::Tool from a struct.
397
+
398
+
Usage example:
399
+
```rust
400
+
#[mcp_tool(
401
+
name ="move_file",
402
+
title="Move File",
403
+
description = concat!("Move or rename files and directories. Can move files between directories ",
404
+
"and rename them in a single operation. If the destination exists, the ",
405
+
"operation will fail. Works across different directories and can be used ",
406
+
"for simple renaming within the same directory. ",
407
+
"Both source and destination must be within allowed directories."),
💻 For a real-world example, check out any of the tools available at: https://github.com/rust-mcp-stack/rust-mcp-filesystem/tree/main/src/tools
427
+
428
+
429
+
### tool_box
430
+
`tool_box` generates an enum from a provided list of tools, making it easier to organize and manage them, especially when your application includes a large number of tools.
431
+
432
+
It accepts an array of tools and generates an enum where each tool becomes a variant of the enum.
433
+
434
+
Generated enum has a `tools()` function that returns a `Vec<Tool>` , and a `TryFrom<CallToolRequestParams>` trait implementation that could be used to convert a ToolRequest into a Tool instance.
435
+
436
+
Usage example:
437
+
```rust
438
+
// Accepts an array of tools and generates an enum named `FileSystemTools`,
- using `tools()` in list tools request : [https://github.com/rust-mcp-stack/rust-mcp-filesystem/blob/main/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-filesystem/blob/main/src/handler.rs#L67)
449
+
- using `try_from` in call tool_request: [https://github.com/rust-mcp-stack/rust-mcp-filesystem/blob/main/src/handler.rs](https://github.com/rust-mcp-stack/rust-mcp-filesystem/blob/main/src/handler.rs#L100)
450
+
451
+
452
+
453
+
### mcp_elicit
454
+
The `mcp_elicit` macro generates implementations for the annotated struct to facilitate data elicitation. It enables struct to generate `ElicitRequestedSchema` and also parsing a map of field names to `ElicitResultContentValue` values back into the struct, supporting both required and optional fields. The generated implementation includes:
455
+
456
+
- A `message()` method returning the elicitation message as a string.
457
+
- A `requested_schema()` method returning an `ElicitRequestedSchema` based on the struct’s JSON schema.
458
+
- A `from_content_map()` method to convert a map of `ElicitResultContentValue` values into a struct instance.
459
+
460
+
### Attributes
461
+
462
+
-`message` - An optional string (or `concat!(...)` expression) to prompt the user or system for input. Defaults to an empty string if not provided.
463
+
464
+
Usage example:
465
+
```rust
466
+
// A struct that could be used to send elicit request and get the input from the user
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)
@@ -612,6 +721,7 @@ Below is a list of projects that utilize the `rust-mcp-sdk`, showcasing their na
612
721
| <ahref="https://rust-mcp-stack.github.io/mcp-discovery"><imgsrc="https://raw.githubusercontent.com/rust-mcp-stack/mcp-discovery/refs/heads/main/docs/_media/mcp-discovery-logo.png"width="64"/></a> |[MCP Discovery](https://rust-mcp-stack.github.io/mcp-discovery)| A lightweight command-line tool for discovering and documenting MCP Server capabilities. |[GitHub](https://github.com/rust-mcp-stack/mcp-discovery)|
613
722
| <ahref="https://github.com/EricLBuehler/mistral.rs"><imgsrc="https://avatars.githubusercontent.com/u/65165915?s=64"width="64"/></a> |[mistral.rs](https://github.com/EricLBuehler/mistral.rs)| Blazingly fast LLM inference. |[GitHub](https://github.com/EricLBuehler/mistral.rs)|
614
723
| <ahref="https://github.com/moonrepo/moon"><imgsrc="https://avatars.githubusercontent.com/u/102833400?s=64"width="64"/></a> |[moon](https://github.com/moonrepo/moon)| moon is a repository management, organization, orchestration, and notification tool for the web ecosystem, written in Rust. |[GitHub](https://github.com/moonrepo/moon)|
724
+
| <ahref="https://github.com/LepistaBioinformatics/mycelium"><imgsrc="https://avatars.githubusercontent.com/u/79392252?s=64"width="64"/></a> |[mycelium](https://github.com/LepistaBioinformatics/mycelium)|`mycelium` is a modern, open-source platform for secure, flexible, and scalable API management. |[GitHub](https://github.com/LepistaBioinformatics/mycelium)|
615
725
| <ahref="https://github.com/angreal/angreal"><imgsrc="https://avatars.githubusercontent.com/u/45580675?s=64"width="64"/></a> |[angreal](https://github.com/angreal/angreal)| Angreal provides a way to template the structure of projects and a way of executing methods for interacting with that project in a consistent manner. |[GitHub](https://github.com/angreal/angreal)|
616
726
| <ahref="https://github.com/FalkorDB/text-to-cypher"><imgsrc="https://avatars.githubusercontent.com/u/140048192?s=64"width="64"/></a> |[text-to-cypher](https://github.com/FalkorDB/text-to-cypher)| A high-performance Rust-based API service that translates natural language text to Cypher queries for graph databases. |[GitHub](https://github.com/FalkorDB/text-to-cypher)|
617
727
| <ahref="https://github.com/Tuurlijk/notify-mcp"><imgsrc="https://avatars.githubusercontent.com/u/790979?s=64"width="64"/></a> |[notify-mcp](https://github.com/Tuurlijk/notify-mcp)| A Model Context Protocol (MCP) server that provides desktop notification functionality. |[GitHub](https://github.com/Tuurlijk/notify-mcp)|
@@ -622,6 +732,10 @@ Below is a list of projects that utilize the `rust-mcp-sdk`, showcasing their na
622
732
623
733
624
734
735
+
736
+
737
+
738
+
625
739
## Contributing
626
740
627
741
We welcome everyone who wishes to contribute! Please refer to the [contributing](CONTRIBUTING.md) guidelines for more details.
Copy file name to clipboardExpand all lines: crates/rust-mcp-macros/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,10 +99,10 @@ fn main() {
99
99
100
100
## mcp_elicit Macro
101
101
102
-
The `mcp_elicit` macro generates an implementation for the annotated struct to facilitate data elicitation into a `rust_mcp_schema::Tool` instance. It enables parsing a map of field names to `ElicitResultContentValue` values into the struct, supporting both required and optional fields. The generated implementation includes:
102
+
The `mcp_elicit` macro generates implementations for the annotated struct to facilitate data elicitation. It enables struct to generate `ElicitRequestedSchema` and also parsing a map of field names to `ElicitResultContentValue` values back into the struct, supporting both required and optional fields. The generated implementation includes:
103
103
104
104
- A `message()` method returning the elicitation message as a string.
105
-
- A `requested_schema()` method returning an `ElicitRequestParamsRequestedSchema` based on the struct’s JSON schema.
105
+
- A `requested_schema()` method returning an `ElicitRequestedSchema` based on the struct’s JSON schema.
106
106
- A `from_content_map()` method to convert a map of `ElicitResultContentValue` values into a struct instance.
0 commit comments