Skip to content

Commit 2c46028

Browse files
authored
chore: house keeping, more tests, improved documentation (#10)
* chore: house keeping * add more tests * test: add more macro tests
1 parent 05f4729 commit 2c46028

File tree

6 files changed

+524
-2
lines changed

6 files changed

+524
-2
lines changed

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# **Contributing to rust-mcp-sdk**
2+
3+
🎉 Thank you for your interest in improving **rust-mcp-sdk**! Every contribution, big or small, is valuable and appreciated.
4+
5+
## **Code of Conduct**
6+
7+
We follow the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct). Please be respectful and inclusive when contributing.
8+
9+
## **How to Contribute**
10+
11+
### Participating in Tests, Documentation, and Examples
12+
13+
We highly encourage contributors to improve test coverage, enhance documentation, and introduce new examples to ensure the reliability and usability of the project. If you notice untested code paths, missing documentation, or areas where examples could help, consider adding tests, clarifying explanations, or providing real-world usage examples. Every improvement helps make the project more robust, well-documented, and accessible to others!
14+
15+
### Participating in Issues
16+
17+
You can contribute in three key ways:
18+
19+
1. **Report Issues** – If you find a bug or have an idea, open an issue for discussion.
20+
2. **Help Triage** – Provide details, test cases, or suggestions to clarify issues.
21+
3. **Resolve Issues** – Investigate problems and submit fixes via Pull Requests (PRs).
22+
23+
Anyone can participate at any stage, whether it's discussing, triaging, or reviewing PRs.
24+
25+
### **Filing a Bug Report**
26+
27+
When reporting a bug, use the provided issue template and fill in as many details as possible. Don’t worry if you can’t answer everything—just provide what you can.
28+
29+
### **Fixing Issues**
30+
31+
Most issues are resolved through a Pull Request. PRs go through a review process to ensure quality and correctness.
32+
33+
## **Pull Requests (PRs)**
34+
35+
We welcome PRs! Before submitting, please:
36+
37+
1. **Discuss major changes** – Open an issue before adding a new feature and opening a PR.
38+
2. **Create a feature branch** – Fork the repo and branch from `main`.
39+
3. **Write tests** – If your change affects functionality, add relevant tests.
40+
4. **Update documentation** – If you modify APIs, update the docs.
41+
5. **Run tests** – Make sure all tests succeed by running:
42+
43+
```sh
44+
cargo make test
45+
```
46+
47+
### **Commit Best Practices**
48+
49+
- **Relate PR changes to the issue** – Changes in a pull request (PR) should directly address the specific issue it’s tied to. Unrelated changes should be split into separate issues and PRs to maintain focus and simplify review.
50+
- **Logically separate commits** – Keep changes atomic and easy to review.
51+
- **Maintain a bisect-able history** – Each commit should compile and pass all tests to enable easy debugging with `git bisect` in case of regression.
52+
53+
## License
54+
55+
By contributing to rust-mcp-sdk, you acknowledge and agree that your contributions will be licensed under the terms specified in the LICENSE file located in the root directory of this repository.
56+
57+
---

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,21 @@ The same principles outlined above apply to the client-side handlers, `mcp_clien
213213
Use `client_runtime::create_client()` or `client_runtime_core::create_client()` , respectively.
214214
Check out the corresponding examples at: [examples/simple-mcp-client](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client) and [examples/simple-mcp-client-core](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-core).
215215

216+
## Contributing
217+
218+
We welcome everyone who wishes to contribute! Please refer to the [contributing](CONTRIBUTING.md) guidelines for more details.
219+
220+
Check out our [development guide](development.md) for instructions on setting up, building, testing, formatting, and trying out example projects.
221+
222+
All contributions, including issues and pull requests, must follow
223+
Rust's Code of Conduct.
224+
225+
Unless explicitly stated otherwise, any contribution you submit for inclusion in rust-mcp-sdk is provided under the terms of the MIT License, without any additional conditions or restrictions.
226+
227+
## Development
228+
229+
Check out our [development guide](development.md) for instructions on setting up, building, testing, formatting, and trying out example projects.
230+
216231
## License
217232

218233
This project is licensed under the MIT License. see the [LICENSE](LICENSE) file for details.

crates/rust-mcp-macros/src/lib.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,60 @@ pub fn derive_json_schema(input: TokenStream) -> TokenStream {
296296
};
297297
TokenStream::from(expanded)
298298
}
299+
300+
#[cfg(test)]
301+
mod tests {
302+
use super::*;
303+
use syn::parse_str;
304+
#[test]
305+
fn test_valid_macro_attributes() {
306+
let input = r#"name = "test_tool", description = "A test tool.""#;
307+
let parsed: MCPToolMacroAttributes = parse_str(input).unwrap();
308+
309+
assert_eq!(parsed.name.unwrap(), "test_tool");
310+
assert_eq!(parsed.description.unwrap(), "A test tool.");
311+
}
312+
313+
#[test]
314+
fn test_missing_name() {
315+
let input = r#"description = "Only description""#;
316+
let result: Result<MCPToolMacroAttributes, Error> = parse_str(input);
317+
assert!(result.is_err());
318+
assert_eq!(
319+
result.err().unwrap().to_string(),
320+
"The 'name' attribute is required."
321+
)
322+
}
323+
324+
#[test]
325+
fn test_missing_description() {
326+
let input = r#"name = "OnlyName""#;
327+
let result: Result<MCPToolMacroAttributes, Error> = parse_str(input);
328+
assert!(result.is_err());
329+
assert_eq!(
330+
result.err().unwrap().to_string(),
331+
"The 'description' attribute is required."
332+
)
333+
}
334+
335+
#[test]
336+
fn test_empty_name_field() {
337+
let input = r#"name = "", description = "something""#;
338+
let result: Result<MCPToolMacroAttributes, Error> = parse_str(input);
339+
assert!(result.is_err());
340+
assert_eq!(
341+
result.err().unwrap().to_string(),
342+
"The 'name' attribute should not be an empty string."
343+
);
344+
}
345+
#[test]
346+
fn test_empty_description_field() {
347+
let input = r#"name = "my-tool", description = """#;
348+
let result: Result<MCPToolMacroAttributes, Error> = parse_str(input);
349+
assert!(result.is_err());
350+
assert_eq!(
351+
result.err().unwrap().to_string(),
352+
"The 'description' attribute should not be an empty string."
353+
);
354+
}
355+
}

0 commit comments

Comments
 (0)