Skip to content

Commit e19d9db

Browse files
authored
[Deps] Put clap behind an optional cli feature (#25)
`clap` sits in `[dependencies]` but only `bin/server.rs` and `bin/client.rs` use it - nothing under `src/` mentions it. Every library consumer of `mcp_rs` has therefore been compiling clap and its subtree for nothing. This makes it optional behind a non-default `cli` feature and gates the two binaries on it. `required-features` means cargo skips a binary rather than failing when the feature is off, so `cargo build` on a checkout still succeeds, and both CI jobs already pass `--all-features`, so the binaries stay built and linted. Measured on this branch: `cargo tree -e normal` goes from 13 clap-subtree crates to zero, and `cargo tree -e normal --features cli` still shows them. In gitar this subtree reaches most of the workspace, since `mcp_rs` is a dependency of `agent-models`. We just moved every gitar CLI from clap to `usage`, and this was the one remaining edge keeping clap in the graph. Heads up on two things I did not touch: **CI is already red on main.** `cargo test --all-features` fails with 15 `E0061`s in `tests/tools.rs`, from `agent_id: Uuid` landing on `CallToolArgs` as a required `TypedBuilder` field without the test call sites being updated. I reproduced that on `main` at `9b4756f` with this branch stashed, so it predates this PR. Left alone, as the fix is a semantic call: either the tests supply an `agent_id` or the field takes a `#[builder(default)]`, and whoever wrote it knows which. **gitar is pinned to a commit that is not on any branch.** Our `rev = "43eb26e6"` is the pre-squash head of #19, reachable only through `refs/pull/19/head`. #19 squash-merged as `b496f16`, and main has three commits since. So consuming this means moving off that dangling head onto main, which also brings `e6409b7` (sync `get_tool`) and `9b4756f`. Separate bump on our side, not something this PR does.
1 parent 9b4756f commit e19d9db

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ async-stream = "0.3"
2828
mime_guess = "2"
2929
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
3030
config = "0.15"
31-
clap = { version = "4", features = ["derive"] }
31+
# Optional: the two binaries below are the only clap users, and a library consumer that
32+
# never builds them was compiling clap plus its 12-crate subtree for nothing.
33+
clap = { version = "4", features = ["derive"], optional = true }
3234
reqwest = { version = "0.12", features = ["json"] }
3335
reqwest-eventsource = "0.6"
3436
mime = "0.3"
@@ -38,13 +40,21 @@ tracing-core = "0.1"
3840
async-recursion = "1"
3941
http = "1.1"
4042

43+
# Off by default so `mcp_rs` as a dependency carries no CLI parser. `required-features`
44+
# makes cargo skip the binaries rather than fail when it is off, so `cargo build` on a
45+
# checkout still succeeds and `--all-features` (what CI runs) still builds and lints them.
46+
[features]
47+
cli = ["dep:clap"]
48+
4149
[[bin]]
4250
name = "server"
4351
path = "bin/server.rs"
52+
required-features = ["cli"]
4453

4554
[[bin]]
4655
name = "client"
4756
path = "bin/client.rs"
57+
required-features = ["cli"]
4858

4959
[lib]
5060
name = "mcp_rs"

0 commit comments

Comments
 (0)