Skip to content

Commit 21f1086

Browse files
committed
fix(conflict): edit concflict and correction
2 parents 982f15e + 7ae2728 commit 21f1086

File tree

3 files changed

+67
-15
lines changed

3 files changed

+67
-15
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,41 @@ jobs:
9797

9898
- name: Run tests
9999
run: cargo test --all-features
100+
101+
coverage:
102+
name: Code Coverage
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v3
106+
107+
# install nodejs
108+
- name: Setup Node.js
109+
uses: actions/setup-node@v3
110+
with:
111+
node-version: '20'
112+
113+
- name: Install uv
114+
uses: astral-sh/setup-uv@v5
115+
116+
- name: Install Rust
117+
uses: dtolnay/rust-toolchain@stable
118+
119+
- name: Set up Python
120+
run: uv python install
121+
122+
- name: Create venv for python
123+
run: uv venv
124+
125+
- uses: Swatinem/rust-cache@v2
126+
127+
- name: Install cargo-llvm-cov
128+
run: cargo install cargo-llvm-cov
129+
130+
- name: Install llvm-tools-preview
131+
run: rustup component add llvm-tools-preview
132+
133+
- name: Run tests with coverage
134+
run: cargo llvm-cov --all-features
100135

101136
doc:
102137
name: Generate Documentation

crates/rmcp-macros/src/tool.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use proc_macro2::TokenStream;
44
use quote::{ToTokens, quote};
55
use syn::{
66
Expr, FnArg, Ident, ItemFn, ItemImpl, MetaList, PatType, Token, Type, Visibility, parse::Parse,
7-
parse_quote,
7+
parse_quote, spanned::Spanned,
88
};
99

1010
#[derive(Default)]
@@ -21,6 +21,7 @@ impl Parse for ToolImplItemAttrs {
2121
"tool_box" => {
2222
tool_box = Some(None);
2323
if input.lookahead1().peek(Token![=]) {
24+
input.parse::<Token![=]>()?;
2425
let value: Ident = input.parse()?;
2526
tool_box = Some(Some(value));
2627
}
@@ -224,6 +225,11 @@ pub(crate) fn tool_impl_item(attr: TokenStream, mut input: ItemImpl) -> syn::Res
224225
rmcp::tool_box!(@derive #ident);
225226
));
226227
}
228+
} else {
229+
return Err(syn::Error::new(
230+
proc_macro2::Span::call_site(),
231+
"tool_box attribute is required for trait implementation",
232+
));
227233
}
228234
} else if let Some(ident) = tool_box_ident {
229235
// if it is a normal impl block
@@ -367,6 +373,12 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
367373
unextractable_args_indexes.insert(index);
368374
}
369375
Some(Caught::Aggregated(rust_type)) => {
376+
if let ToolParams::Params { .. } = tool_macro_attrs.params {
377+
return Err(syn::Error::new(
378+
rust_type.span(),
379+
"cannot mix aggregated and individual parameters",
380+
));
381+
}
370382
tool_macro_attrs.params = ToolParams::Aggregated { rust_type };
371383
unextractable_args_indexes.insert(index);
372384
}
@@ -626,10 +638,12 @@ mod test {
626638

627639
#[test]
628640
fn test_trait_tool_macro() -> syn::Result<()> {
629-
let attr = quote! {};
641+
let attr = quote! {
642+
tool_box = Calculator
643+
};
630644
let input = quote! {
631645
impl ServerHandler for Calculator {
632-
tool_box!(@derive);
646+
#[tool]
633647
fn get_info(&self) -> ServerInfo {
634648
ServerInfo {
635649
instructions: Some("A simple calculator".into()),

examples/README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
cargo build --release --example servers_std_io
77
```
88

9-
This builds a standard input/output MCP server binary.
9+
This builds a standard input/output MCP server binary.
1010

1111
2. **Add or update this section in your** `PATH-TO/claude_desktop_config.json`
1212

13-
**Windows**
13+
Windows
1414

1515
```json
1616
{
@@ -23,7 +23,7 @@
2323
}
2424
```
2525

26-
**McOS/Linux**
26+
McOS/Linux
2727

2828
```json
2929
{
@@ -36,16 +36,19 @@
3636
}
3737
```
3838

39-
3. **Once Claude Desktop is running, try chatting:**
40-
```text
41-
counter.say_hello
42-
```
39+
3. **Ensure that the MCP UI elements appear in Claude Desktop**
40+
The MCP UI elements will only show up in Claude for Desktop if at least one server is properly configured.
41+
42+
4. **Once Claude Desktop is running, try chatting:**
43+
`text
44+
counter.say_hello
45+
`
4346
Or test other tools like:
44-
```text
45-
counter.increment
46-
counter.get_value
47-
counter.sum {"a": 3, "b": 4}
48-
```
47+
`text
48+
counter.increment
49+
counter.get_value
50+
counter.sum {"a": 3, "b": 4}
51+
`
4952

5053
# Client Examples
5154

0 commit comments

Comments
 (0)