Skip to content

Commit 0a2f13a

Browse files
authored
style: fmt the project (#54)
add rustfmt.toml Signed-off-by: jokemanfire <[email protected]>
1 parent 59bfb6e commit 0a2f13a

36 files changed

+158
-132
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ jobs:
4141
steps:
4242
- uses: actions/checkout@v3
4343

44-
- name: Install Rust
45-
uses: dtolnay/rust-toolchain@stable
44+
- name: Install Rust fmt
45+
run: rustup toolchain install nightly --component rustfmt
4646

4747
- name: Check formatting
48-
run: cargo fmt --all -- --check
48+
run: cargo +nightly fmt --all -- --check
4949

5050
clippy:
5151
name: Lint with Clippy

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cargo-features = ["edition2024"]
2+
13
[workspace]
24
members = ["crates/rmcp", "crates/rmcp-macros", "examples/*"]
35
resolver = "2"
@@ -12,7 +14,7 @@ version = "0.1.5"
1214
authors = ["4t145 <[email protected]>"]
1315
license = "MIT/Apache-2.0"
1416
repository = "https://github.com/modelcontextprotocol/rust-sdk/"
15-
description = "Rust SDK for the Model Context Protocol"
17+
description = "Rust SDK for Model Context Protocol"
1618
keywords = ["mcp", "sdk", "tokio", "modelcontextprotocol"]
1719
homepage = "https://github.com/modelcontextprotocol/rust-sdk"
1820
categories = [

crates/rmcp-macros/Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
cargo-features = ["edition2024"]
2+
13
[package]
24
name = "rmcp-macros"
3-
license.workspace = true
4-
version.workspace = true
5-
edition.workspace = true
6-
repository.workspace = true
7-
homepage.workspace = true
8-
readme.workspace = true
5+
license = { workspace = true }
6+
version = { workspace = true }
7+
edition = { workspace = true }
8+
repository = { workspace = true }
9+
homepage = { workspace = true }
10+
readme = { workspace = true }
911
description = "Rust SDK for Model Context Protocol macros library"
1012
documentation = "https://docs.rs/rmcp-macros"
1113

crates/rmcp/Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
cargo-features = ["edition2024"]
2+
13
[package]
24
name = "rmcp"
3-
license.workspace = true
4-
version.workspace = true
5-
edition.workspace = true
6-
repository.workspace = true
7-
homepage.workspace = true
8-
readme.workspace = true
5+
license = { workspace = true }
6+
version = { workspace = true }
7+
edition = { workspace = true }
8+
repository = { workspace = true }
9+
homepage = { workspace = true }
10+
readme = { workspace = true }
911
description = "Rust SDK for Model Context Protocol"
1012
documentation = "https://docs.rs/rmcp"
1113

crates/rmcp/src/handler/client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use crate::error::Error as McpError;
2-
use crate::model::*;
3-
use crate::service::{Peer, RequestContext, RoleClient, Service, ServiceRole};
1+
use crate::{
2+
error::Error as McpError,
3+
model::*,
4+
service::{Peer, RequestContext, RoleClient, Service, ServiceRole},
5+
};
46

57
impl<H: ClientHandler> Service<RoleClient> for H {
68
async fn handle_request(

crates/rmcp/src/handler/server.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use crate::error::Error as McpError;
2-
use crate::model::*;
3-
use crate::service::{Peer, RequestContext, RoleServer, Service, ServiceRole};
1+
use crate::{
2+
error::Error as McpError,
3+
model::*,
4+
service::{Peer, RequestContext, RoleServer, Service, ServiceRole},
5+
};
46

57
mod resource;
68
pub mod tool;

crates/rmcp/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,26 @@ pub use error::Error;
66
pub mod model;
77
#[cfg(any(feature = "client", feature = "server"))]
88
pub mod service;
9+
#[cfg(feature = "client")]
10+
pub use handler::client::ClientHandler;
11+
#[cfg(feature = "server")]
12+
pub use handler::server::ServerHandler;
913
#[cfg(any(feature = "client", feature = "server"))]
1014
pub use service::{Peer, Service, ServiceError, ServiceExt};
1115
#[cfg(feature = "client")]
1216
pub use service::{RoleClient, serve_client};
1317
#[cfg(feature = "server")]
1418
pub use service::{RoleServer, serve_server};
1519

16-
#[cfg(feature = "client")]
17-
pub use handler::client::ClientHandler;
18-
#[cfg(feature = "server")]
19-
pub use handler::server::ServerHandler;
20-
2120
pub mod handler;
2221
pub mod transport;
2322

24-
#[cfg(all(feature = "macros", feature = "server"))]
25-
pub use rmcp_macros::tool;
26-
2723
// re-export
2824
#[cfg(all(feature = "macros", feature = "server"))]
2925
pub use paste::paste;
3026
#[cfg(all(feature = "macros", feature = "server"))]
27+
pub use rmcp_macros::tool;
28+
#[cfg(all(feature = "macros", feature = "server"))]
3129
pub use schemars;
3230
#[cfg(feature = "macros")]
3331
pub use serde;

crates/rmcp/src/model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub use capabilities::*;
1111
pub use content::*;
1212
pub use prompt::*;
1313
pub use resource::*;
14-
1514
use serde::{Deserialize, Serialize};
1615
use serde_json::Value;
1716
pub use tool::*;
@@ -964,9 +963,10 @@ impl From<CancelledNotification> for ClientNotification {
964963

965964
#[cfg(test)]
966965
mod tests {
967-
use super::*;
968966
use serde_json::json;
969967

968+
use super::*;
969+
970970
#[test]
971971
fn test_notification_serde() {
972972
let raw = json!( {

crates/rmcp/src/model/annotated.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::ops::{Deref, DerefMut};
22

3+
use chrono::{DateTime, Utc};
4+
use serde::{Deserialize, Serialize};
5+
36
use super::{
47
RawContent, RawEmbeddedResource, RawImageContent, RawResource, RawResourceTemplate,
58
RawTextContent, Role,
69
};
7-
use chrono::{DateTime, Utc};
8-
use serde::{Deserialize, Serialize};
910

1011
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1112
#[serde(rename_all = "camelCase")]

crates/rmcp/src/model/capabilities.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use super::JsonObject;
1+
use std::{collections::BTreeMap, marker::PhantomData};
2+
23
use paste::paste;
34
use serde::{Deserialize, Serialize};
4-
use std::collections::BTreeMap;
5-
use std::marker::PhantomData;
5+
6+
use super::JsonObject;
67
pub type ExperimentalCapabilities = BTreeMap<String, JsonObject>;
78

89
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]

0 commit comments

Comments
 (0)