Skip to content

Commit d958607

Browse files
committed
Default io-uring and add docs.rs build config
1 parent c3cfec3 commit d958607

10 files changed

Lines changed: 174 additions & 9 deletions

File tree

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# Enable Tokio unstable features required by dial9-tokio-telemetry for runtime tracing.
2121
# See: https://docs.rs/tokio/latest/tokio/#unstable-features
2222
rustflags = ["--cfg", "tokio_unstable"]
23+
rustdocflags = ["--cfg", "tokio_unstable"]
2324

2425
# Enable frame pointers for CPU profiling (Linux only, optional but recommended)
2526
# Uncomment the following line for better CPU profiling data

.github/workflows/ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ permissions:
2626

2727
env:
2828
CARGO_TERM_COLOR: always
29+
RUSTFLAGS: --cfg tokio_unstable
2930

3031
concurrency:
3132
group: ci-${{ github.workflow }}-${{ github.ref }}
@@ -68,7 +69,12 @@ jobs:
6869
uses: Swatinem/rust-cache@v2
6970

7071
- name: Run clippy
71-
run: cargo clippy --all-targets --all-features --locked -- -D warnings
72+
run: cargo clippy --all-targets --locked -- -D warnings
73+
74+
- name: Run clippy (io-uring)
75+
env:
76+
RUSTFLAGS: --cfg tokio_unstable
77+
run: cargo clippy --all-targets --locked --features io-uring -- -D warnings
7278

7379
test:
7480
name: Test
@@ -103,3 +109,34 @@ jobs:
103109

104110
- name: Build release binary
105111
run: cargo build --release --locked -p rustfs-mcp
112+
113+
docs:
114+
name: Docs
115+
runs-on: ubuntu-latest
116+
timeout-minutes: 20
117+
strategy:
118+
fail-fast: false
119+
matrix:
120+
profile: [default, io-uring]
121+
steps:
122+
- name: Checkout repository
123+
uses: actions/checkout@v6
124+
125+
- name: Setup Rust toolchain
126+
uses: dtolnay/rust-toolchain@nightly
127+
128+
- name: Cache Rust dependencies
129+
uses: Swatinem/rust-cache@v2
130+
131+
- name: Build docs (default)
132+
if: matrix.profile == 'default'
133+
env:
134+
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -D warnings
135+
run: cargo +nightly doc --no-deps --locked
136+
137+
- name: Build docs (io-uring)
138+
if: matrix.profile == 'io-uring'
139+
env:
140+
RUSTFLAGS: --cfg tokio_unstable
141+
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -D warnings
142+
run: cargo +nightly doc --no-deps --locked --features io-uring

.github/workflows/publish.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ permissions:
2525

2626
env:
2727
CARGO_TERM_COLOR: always
28+
RUSTFLAGS: --cfg tokio_unstable
2829

2930
concurrency:
3031
group: publish-${{ github.workflow }}-${{ github.ref }}
@@ -67,7 +68,12 @@ jobs:
6768
uses: Swatinem/rust-cache@v2
6869

6970
- name: Run clippy
70-
run: cargo clippy --all-targets --all-features --locked -- -D warnings
71+
run: cargo clippy --all-targets --locked -- -D warnings
72+
73+
- name: Run clippy (io-uring)
74+
env:
75+
RUSTFLAGS: --cfg tokio_unstable
76+
run: cargo clippy --all-targets --locked --features io-uring -- -D warnings
7177

7278
test:
7379
name: Test
@@ -103,11 +109,42 @@ jobs:
103109
- name: Build release binary
104110
run: cargo build --release --locked -p rustfs-mcp
105111

112+
docs:
113+
name: Docs
114+
runs-on: ubuntu-latest
115+
timeout-minutes: 20
116+
strategy:
117+
fail-fast: false
118+
matrix:
119+
profile: [default, io-uring]
120+
steps:
121+
- name: Checkout repository
122+
uses: actions/checkout@v6
123+
124+
- name: Setup Rust toolchain
125+
uses: dtolnay/rust-toolchain@nightly
126+
127+
- name: Cache Rust dependencies
128+
uses: Swatinem/rust-cache@v2
129+
130+
- name: Build docs (default)
131+
if: matrix.profile == 'default'
132+
env:
133+
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -D warnings
134+
run: cargo +nightly doc --no-deps --locked
135+
136+
- name: Build docs (io-uring)
137+
if: matrix.profile == 'io-uring'
138+
env:
139+
RUSTFLAGS: --cfg tokio_unstable
140+
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -D warnings
141+
run: cargo +nightly doc --no-deps --locked --features io-uring
142+
106143
publish:
107144
name: Publish to crates.io
108145
runs-on: ubuntu-latest
109146
timeout-minutes: 15
110-
needs: [fmt, clippy, test, build]
147+
needs: [fmt, clippy, test, build, docs]
111148
if: startsWith(github.ref, 'refs/tags/v')
112149
steps:
113150
- name: Checkout repository

Cargo.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ keywords = ["mcp", "s3", "aws", "rustfs", "server"]
2626
categories = ["development-tools", "web-programming"]
2727
documentation = "https://docs.rs/rustfs-mcp/latest/rustfs_mcp/"
2828

29+
[package.metadata.docs.rs]
30+
default-target = "x86_64-unknown-linux-gnu"
31+
targets = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]
32+
rustc-args = ["--cfg", "tokio_unstable"]
33+
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable"]
34+
35+
[features]
36+
default = ["io-uring"]
37+
io-uring = ["tokio/io-uring"]
38+
2939
[[bin]]
3040
name = "rustfs-mcp"
3141
path = "src/main.rs"
3242

3343
[lints.rust]
3444
unsafe_code = "warn"
3545
unused = "warn"
46+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
3647

3748
[lints.clippy]
3849
all = "warn"
@@ -45,7 +56,7 @@ aws-sdk-s3 = { version = "1.129.0", default-features = false, features = ["sigv4
4556
aws-smithy-http-client = { version = "1.1.12", default-features = false, features = ["default-client", "rustls-aws-lc"] }
4657

4758
# Async runtime and utilities
48-
tokio = { version = "1.52.1", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "io-uring"] }
59+
tokio = { version = "1.52.1", default-features = false, features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread"] }
4960

5061
# MCP SDK with macros support
5162
rmcp = { version = "1.5.0", default-features = false, features = ["server", "transport-io", "macros"] }

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ FROM rust:1.93-bookworm AS builder
1616

1717
WORKDIR /build
1818

19+
ARG ENABLE_IO_URING=1
20+
ENV RUSTFLAGS="--cfg tokio_unstable"
21+
ENV RUSTDOCFLAGS="--cfg tokio_unstable"
22+
1923
# Copy project and build a reproducible release binary.
2024
COPY . .
21-
RUN cargo build --release --locked -p rustfs-mcp
25+
RUN if [ "$ENABLE_IO_URING" = "1" ]; then \
26+
cargo build --release --locked -p rustfs-mcp; \
27+
else \
28+
cargo build --release --locked --no-default-features -p rustfs-mcp; \
29+
fi
2230

2331
FROM debian:bookworm-slim AS runtime
2432

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<p align="center">
1010
<a href="https://github.com/rustfs/rustfs/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/rustfs/rustfs/actions/workflows/ci.yml/badge.svg" /></a>
11+
<a href="https://docs.rs/rustfs-mcp"><img alt="docs.rs" src="https://img.shields.io/docsrs/rustfs-mcp" /></a>
1112
<a href="https://docs.rustfs.com/">📖 Documentation</a>
1213
<a href="https://github.com/rustfs/rustfs/issues">🐛 Bug Reports</a>
1314
<a href="https://github.com/rustfs/rustfs/discussions">💬 Discussions</a>
@@ -54,6 +55,20 @@ cargo build --release -p rustfs-mcp
5455
./target/release/rustfs-mcp
5556
```
5657

58+
### Optional: Enable io-uring
59+
60+
`io-uring` is enabled by default in this crate. Tokio requires unstable cfg for this mode:
61+
62+
```bash
63+
RUSTFLAGS="--cfg tokio_unstable" cargo build --release -p rustfs-mcp
64+
```
65+
66+
To explicitly disable it:
67+
68+
```bash
69+
cargo build --release -p rustfs-mcp --no-default-features
70+
```
71+
5772
## ⚙️ Configuration
5873

5974
### Environment Variables

src/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use anyhow::Result;
1616
use clap::Parser;
1717
use tracing::info;
1818

19-
/// Configuration for RustFS MCP Server
19+
/// Configuration for `rustfs-mcp`.
2020
#[derive(Parser, Debug, Clone)]
2121
#[command(
2222
name = "rustfs-mcp-server",
@@ -98,10 +98,12 @@ pub struct Config {
9898
}
9999

100100
impl Config {
101+
/// Parse configuration from command-line arguments and environment variables.
101102
pub fn new() -> Self {
102103
Config::parse()
103104
}
104105

106+
/// Validate required credentials are present.
105107
pub fn validate(&self) -> Result<()> {
106108
if self.access_key_id.is_none() {
107109
anyhow::bail!(
@@ -118,18 +120,21 @@ impl Config {
118120
Ok(())
119121
}
120122

123+
/// Return validated AWS access key id.
121124
pub fn access_key_id(&self) -> &str {
122125
self.access_key_id
123126
.as_ref()
124127
.expect("Access key ID should be validated")
125128
}
126129

130+
/// Return validated AWS secret access key.
127131
pub fn secret_access_key(&self) -> &str {
128132
self.secret_access_key
129133
.as_ref()
130134
.expect("Secret access key should be validated")
131135
}
132136

137+
/// Log a redacted configuration summary.
133138
pub fn log_configuration(&self) {
134139
let access_key_display = self
135140
.access_key_id

src/lib.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,43 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#![cfg_attr(docsrs, feature(doc_cfg))]
16+
//! RustFS MCP server library.
17+
//!
18+
//! This crate exposes a Model Context Protocol (MCP) server that provides
19+
//! S3-compatible storage operations, plus reusable configuration and client
20+
//! primitives for embedding into other Rust applications.
21+
//!
22+
//! # Optional features
23+
//!
24+
//! - `io-uring`: Enables Tokio's `io-uring` integration. This requires building
25+
//! with `RUSTFLAGS="--cfg tokio_unstable"`.
26+
27+
#[cfg(all(feature = "io-uring", not(tokio_unstable)))]
28+
compile_error!(
29+
"feature `io-uring` requires cfg `tokio_unstable` (set RUSTFLAGS/RUSTDOCFLAGS to \"--cfg tokio_unstable\")"
30+
);
31+
32+
/// Command-line and environment configuration parsing/validation.
1533
pub mod config;
34+
/// S3 client wrapper and operation/result data types.
1635
pub mod s3_client;
36+
/// MCP server and tool handlers.
1737
pub mod server;
1838

39+
/// Runtime configuration for the server.
1940
pub use config::Config;
41+
/// Bucket metadata and async S3 client wrapper.
2042
pub use s3_client::{BucketInfo, S3Client};
43+
/// MCP service implementation.
2144
pub use server::RustfsMcpServer;
2245

2346
use anyhow::{Context, Result};
2447
use rmcp::ServiceExt;
2548
use tokio::io::{stdin, stdout};
2649
use tracing::info;
2750

28-
/// Run the MCP server with the provided configuration
51+
/// Start the MCP server with an explicit [`Config`].
2952
pub async fn run_server_with_config(config: Config) -> Result<()> {
3053
info!("Starting RustFS MCP Server with provided configuration");
3154

@@ -49,15 +72,17 @@ pub async fn run_server_with_config(config: Config) -> Result<()> {
4972
Ok(())
5073
}
5174

52-
/// Run the MCP server with default configuration (from environment variables)
75+
/// Start the MCP server with [`Config::default`].
5376
pub async fn run_server() -> Result<()> {
5477
info!("Starting RustFS MCP Server with default configuration");
5578

5679
let config = Config::default();
5780
run_server_with_config(config).await
5881
}
5982

60-
/// Validate environment configuration (legacy function for backward compatibility)
83+
/// Validate required AWS credentials in environment variables.
84+
///
85+
/// This function is kept for backward compatibility.
6186
pub fn validate_environment() -> Result<()> {
6287
use std::env;
6388

0 commit comments

Comments
 (0)