Skip to content

feat(deps): make chrono optional behind a default feature - #1474

Open
andreinknv wants to merge 2 commits into
modelcontextprotocol:mainfrom
andreinknv:chrono-optional
Open

andreinknv wants to merge 2 commits into
modelcontextprotocol:mainfrom
andreinknv:chrono-optional

Conversation

@andreinknv

@andreinknv andreinknv commented Nov 18, 2026 •

Copy link
Copy Markdown

Closes #1469.

Discussed in #1469. A downstream test there confirms that chrono drops out of the dependency tree and cargo deny check advisories passes without an ignore.

Motivation

chrono is marked unmaintained (RUSTSEC-2026-0543). rmcp depends on it unconditionally, so downstream cargo deny / cargo audit runs fail on it.

Changes

  • The clock, the RFC 3339 timestamps in tasks and Annotations::with_timestamp_now, and the ServiceError::Timeout message now use jiff 1 (default-features = false, features = ["std"]) and a small private time module. Output is unchanged: +00:00 offset, 0/3/6/9 fractional digits, and PT30S / PT1.5S / P0D.
  • New default feature chrono. It keeps Annotations::for_resource and Annotations::with_timestamp (which take chrono::DateTime<Utc>) and enables schemars?/chrono04.
  • The tests that used chrono directly now use jiff.
  • The crate README has a "Building without chrono" section with the default-features = false snippet.

Compatibility

Nothing changes with default features. cargo semver-checks reports "no semver update required" for default features and for all features except local. With default-features = false, rmcp no longer depends on chrono, except through oauth2 5 when an auth feature is enabled.

wasm32-unknown-unknown behaves as before. chrono (as configured since #234) and jiff both read the clock through std::time::SystemTime::now(), which panics on that target, and neither pulls in js-sys. A browser build that wants a working clock can enable jiff's js feature; before, the equivalent was chrono's wasmbind.

Tests

  • New unit tests pin the timestamp and duration text against chrono's previous output, including the full ServiceError::Timeout message.
  • cargo test --all-features: 1213 passed. cargo test -p rmcp --lib --no-default-features: 208 passed.
  • Clippy -D warnings with all features, with all features except local, and with 8 smaller feature sets, including none. Nightly fmt, nightly docs with --cfg docsrs -Dwarnings, and cargo +1.88.0 check --all-targets --all-features all pass.
  • wasm, on main and on this branch: a probe that calls Annotations::with_timestamp_now traps on wasm32-unknown-unknown exactly like a direct SystemTime::now() call, with no imports in the module; on wasm32-wasip1 both print the same timestamp format; examples/wasi builds for wasm32-wasip2.

Follow-up plan

  1. Add a setter that needs no chrono, for example Annotations::with_last_modified taking an RFC 3339 string or a jiff::Timestamp.
  2. In a later minor release, deprecate Annotations::for_resource and Annotations::with_timestamp, pointing at that setter.
  3. In the next major release, remove chrono from the default features.

AI assistance: I used an AI coding assistant (Claude Code) to write most of this change and draft this text; I reviewed and tested it.

🤖 Generated with Claude Code

chrono is marked unmaintained by RUSTSEC-2026-0543. Use jiff for the clock and the
RFC 3339 task and annotation timestamps, keeping the exact previous output
(`+00:00` offset, 0/3/6/9 fractional digits), and format the request timeout
message without chrono (`PT30S`, `P0D`).

The new default `chrono` feature keeps `Annotations::for_resource` and
`Annotations::with_timestamp` (which take `chrono::DateTime<Utc>`) and schemars'
`chrono04` support. With default features disabled, rmcp no longer depends on
chrono unless an `auth` feature pulls it in through oauth2.
@andreinknv
andreinknv requested a review from a team as a code owner November 18, 2026 13:04
@github-actions github-actions Bot added T-documentation Documentation improvements T-test Testing related changes T-config Configuration file changes T-core Core library changes T-model Model/data structure changes labels Nov 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T13:32:39.940858Z 9043cdf New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@michaelneale is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

@jokemanfire jokemanfire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at a95b804 from the code and a local A/B run, not the description.

What I ran (Linux, stable 1.96; Windows and MSRV not run here)

  • A scratch example (not committed) that formats the same values both ways: chrono::DateTime::to_rfc3339() vs Annotations::with_timestamp(..).last_modified, and format!("request timeout after {}", chrono::Duration::from_std(d).unwrap_or_default()) vs ServiceError::Timeout{d}.to_string().
  • 14 timestamps: seconds 0, pre-epoch (-1s + 500ms), 2099, and every fractional shape (1ns, 1µs, 1ms, 100ms, 123ms, 123456µs, 123456789ns, 999999999ns).
  • 12 durations: zero, 1ns, 1µs, 1ms, 1.5s, 30s, 5400s, 86400s, i64::MAX ms exactly, one nanosecond past it, and Duration::MAX.
  • Result: 26/26 identical, including the 0/3/6/9 fractional-digit rule, the +00:00 offset, and the overflow quirk where chrono::Duration::from_std fails and unwrap_or_default() prints P0D — your too_long branch reproduces that exactly.
  • cargo tree -p rmcp -i chrono: default features → chrono v0.4.40 (direct, plus through schemars 1.2.3); --no-default-features --features server,macros → not in the tree at all. Your opt-out claim holds.

Code read

  • time::rfc3339 is only reachable from now_rfc3339, so the sign of subsec_nanosecond() for pre-epoch values never reaches it; the digit selection matches SecondsFormat::AutoSi. The #[cfg(any(client, server))] on Iso8601Duration matches where ServiceError::Timeout exists.
  • with_timestamp_now no longer routes through with_timestamp, which is what keeps it available without the chrono feature — correct, since with_timestamp keeps using chrono's own to_rfc3339 and the two agree (probe above).

Two things worth settling before merge

  1. Default users still trip the advisory. chrono is in default, so cargo tree -i chrono still shows it for anyone who does not add default-features = false. That is fine as a staged change, but it means the people who filed #1469 (plain rmcp = "3") see no difference in cargo deny check advisories, and the opt-out is not documented anywhere a downstream would look. I would like the README and CHANGELOG to carry the exact snippet (default-features = false plus the feature list they actually need) and one line on the plan to flip the default at the next major. Right now the README change is one line and does not say this.

  2. The flip is a hard API break, and the migration path is invisible. With the feature off, Annotations::for_resource and with_timestamp vanish; at the flip every caller panics at compile time with no replacement that accepts a timestamp. Cheap way to make the eventual break a non-event: add an untyped with_last_modified_rfc3339(&str) (or a jiff-typed setter) now so non-chrono users have a supported path, and #[deprecated(note = "…")] on the chrono setters in a later release before the default changes. Not required for this PR, but it should be in the PR body as the follow-up plan.

Question: which wasm targets did you verify?

jiff's docs for Timestamp::now() say it "may also panic when SystemTime::now() itself panics. The most common context in which this happens is on the wasm32-unknown-unknown target… you should enable Jiff's js feature". This PR deletes the two target-specific chrono blocks, and CHANGELOG.md:1087 records #234 as "disable wasmbind in chrono for wasm32-unknown-unknown", so that target has been deliberately configured before. I read the old config as panicking the same way (no wasmbind), i.e. parity, but I did not build for wasm32-unknown-unknown to prove it — CI only builds examples/wasi for wasm32-wasip2, which has a real clock. One sentence in the PR body saying "wasm32-unknown-unknown behaves as before / now needs jiff/js" would close it.

None of this blocks the dependency change itself, which I could not fault: the formatting is byte-identical on everything I threw at it and the feature wiring does what it says.

Show the `default-features = false` snippet, what is unavailable without the `chrono`
feature, that the `auth` features still pull chrono in through oauth2, and the plan to
drop `chrono` from the default features in the next major release.
@andreinknv

Copy link
Copy Markdown
Author

Thanks for checking it so thoroughly.

1. Docs. 9043cdf adds a "Building without chrono" section to the crate README, which is also the crate-level rustdoc. It covers the default-features = false snippet, what goes away without chrono, the auth/oauth2 caveat, cargo tree -i chrono, and the plan for the next major. cargo tree finds no chrono with the snippet's feature set, and the nightly docs build passes with --cfg docsrs -Dwarnings.

I left CHANGELOG.md alone because release-plz writes it in the release PR; every commit that touches it is a chore: release. The entry will come from this PR's title. For the release PR, a note could read:

With the new default chrono feature turned off, rmcp no longer depends on chrono (except through oauth2 for the auth features). See "Building without chrono" in the README.

If you'd rather have it under [Unreleased] in this PR, I'll add it.

2. Migration path. It's now in the PR body as a follow-up plan: a setter that needs no chrono, then deprecating the chrono setters in a later minor, then flipping the default at the next major. I can add the setter in this PR if you'd prefer it now.

3. wasm. wasm32-unknown-unknown behaves as before. I built a small cdylib probe against main (3.11.0) and against this branch. It calls Annotations::default().with_timestamp_now(), plus std::time::SystemTime::now() directly as a control, and I ran it in Node:

  • main (chrono 0.4.45) and this branch (jiff 1.0.1, with and without the chrono feature): the module has no imports, so no js-sys. The probe and the control both trap with unreachable, so the clock panics the same way it did before.
  • wasm32-wasip1 under Node's WASI: both versions print a timestamp in the same format, for example 2026-11-18T13:25:46.986149+00:00.
  • examples/wasi builds for wasm32-wasip2, as in CI.

With rmcp's default features, wasm32-unknown-unknown doesn't compile on either main or this branch, because uuid needs a randomness source there. That hasn't changed. I added a sentence on wasm to the PR body.

AI assistance: I used an AI coding assistant (Claude Code) to run these checks and draft this reply; I reviewed the results.

🤖 Generated with Claude Code

nixonyh added a commit to voxell-tech/hamlet that referenced this pull request Nov 20, 2026
A chief can list MCP servers in `mcp/servers.json` in the realm, and
their tools are offered to every agent beside the built-in ones (C36,
ADR 0017).

- The server is the MCP client, through the `rmcp` crate: its client,
its transport over a reader and a writer, and its streamable HTTP client
with OAuth. pi sees each tool as one more entry of the catalogue and
calls it through the same `operation` message as `read`, so the runtime
protocol does not change.
- `mcp/` is in the realm, out of every agent's reach, so the tokens in
the list are too. An entry names a program, or the `url` of a remote
server and its `headers`. Each program runs under the sandbox with the
reach its entry declares (`fs_ro`, `fs_rw`, `net`, limits, `env`,
`inherit_env`), in its own folder `mcp/<name>/`, its working folder,
`HOME` and the one place it writes besides `fs_rw`. A server runs for as
long as it is listed, so it has no CPU limit of its own. Unknown keys
are faults.
- A changed list starts, restarts or stops servers while the server
runs; a change of `timeout_secs`, `allow` or `ask` alone restarts
nothing, and a file that is not JSON, or holds anything but `servers`,
changes no server. A changed entry keeps its tools offered while it
starts again. A server that ends starts again after 2 seconds, doubling
to 5 minutes.
- The tools a server last listed stay offered while it starts again, so
a restart changes no agent's tools and no prompt; a call meanwhile fails
at once with why it stopped. Only an entry that does not load, a server
that never started, and tools left out are named in the prompt (C15).
`tools/list_changed` lists again.
- A tool of server `github` called `create_issue` is
`mcp__github__create_issue`; other characters, or past 64, are changed
or shortened with a hash. No hand-added tool may take a name beginning
with `mcp__`. A server offers at most 128 tools; a schema that does not
compile or passes 16 KiB leaves its tool out.
- A call is classified by the gate as an added tool, marked begun so it
never runs twice, checked against its schema, and cancelled on its
timeout or a stopped turn. A server's network is the chief's, given in
its entry, and holds no call.
- A tool its server does not mark `readOnlyHint` waits for a chief in
every mode (H11's new `act` danger); the entry's `allow` and `ask`
override the server's word either way, a tool's name before `*`. Always
allows that tool for the rest of the conversation
(`session_tool_grant`).
- Every agent is offered every server's tools; `set_tools` and `/tools`
turn one off for an agent, or every tool of a server by `mcp__<server>`.
- Settings has an MCP Servers page, drawn in the UI gallery too, and
`hamlet mcp` the same acts: list, tools, add, edit, remove, restart,
sign in, and import. The server changes `servers.json` one entry at a
time, keeps the rest of the file as written, and never sends a value of
`env` or `headers`, only their names. A restart keeps the server's tools
offered.
- Import finds the servers Claude Code, Claude Desktop, Cursor and Codex
list on the server's machine (`hamlet_import`): a program by its full
path, its install folder readable when it is in the home folder,
`${NAME}` as `inherit_env`, and a remote server with its headers.
- A remote server that signs in with OAuth is signed in to from Settings
or `hamlet mcp sign-in`: the code comes back on a loopback of the
server's machine, or in the address the browser ended on, pasted back.
The tokens are kept in `mcp/.signed-in/`, refreshed there, and removed
with the server.
- An agent can ask a chief for a server with `request_mcp_server`, a new
`mcp-server` wait; allowed, the server is listed with its environment's
values empty for the chief to give, and the agent is told either way.
- The workspace moves to `reqwest` 0.13, which `rmcp`'s HTTP client
needs, on rustls with ring, installed where a client is built.
- Its result's text is scrubbed of the realm's credentials and the
server's own secrets, then cut as pi cuts a read. Images go to a model
that takes them, fitted to its limits; audio and binary resources are
named and left out.
- A server's error output goes only to the server's log, scrubbed.
Sampling, roots and elicitation are refused.
- `hamlet_os` can spawn a command with its input piped
(`Tree::spawn_piped`), and `hamlet_sandbox` confines one that keeps
running (`Env::spawn_piped`). The folder watcher of the hand-added tools
is shared with the list's.
- `deny.toml` ignores RUSTSEC-2026-0543: `rmcp` types its timestamps
with `chrono`, which is unmaintained, and has no release without it
until modelcontextprotocol/rust-sdk#1474.
- Docs: `docs/mcp.md`, C36, H11, ADR 0017, the protocol, the society,
the realm, the sandbox, the tour, the glossary.

![A call and the list of MCP
servers](https://github.com/user-attachments/assets/2493fc1a-228b-4eed-9f38-8f36ae5580c9)

![The MCP Servers page in
Settings](https://github.com/user-attachments/assets/bb0c8ab4-785c-4e07-a932-aab272a83357)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-documentation Documentation improvements T-model Model/data structure changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chrono is flagged unmaintained (RUSTSEC-2026-0543): any plan to move to jiff/time or make it optional?

2 participants