Skip to content

support stable #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cn-kali-team
Copy link

Added support for Rust stable toolchain
添加了对Rust stable版本的支持,使SDK能在stable工具链上编译运行

Motivation and Context

Current SDK requires nightly Rust which limits usage scenarios. Many production environments prefer stable versions.
当前SDK需要nightly Rust才能使用,这限制了用户的使用场景。许多生产环境更倾向于使用stable版本。

How Has This Been Tested?

  1. Ran all test cases under stable toolchain (1.82.0)
    在stable工具链(1.82.0)下运行所有测试用例
  2. Verified original functionality under nightly toolchain
    在nightly工具链下验证原有功能不受影响
  3. Tested core scenarios like model loading and inference
    测试了基础功能如模型加载、推理等核心场景

Breaking Changes

No breaking changes, fully backward compatible
无破坏性变更,此修改完全向后兼容

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist | 检查清单

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Main changes:
主要修改点:

  1. Replaced code that required nightly features
    替换了需要nightly特性的代码
  2. Updated build configuration
    更新了构建配置
  3. Ensured all features work on stable
    确保所有特性在stable下可用

Prerequisite | 前置条件

Requires merging: 4t145/sse-stream#2
需要先合并: 4t145/sse-stream#2

@github-actions github-actions bot added T-dependencies Dependencies related changes T-config Configuration file changes T-core Core library changes T-examples Example code changes T-handler Handler implementation changes T-service Service layer changes T-transport Transport layer changes labels Jun 18, 2025
@4t145
Copy link
Collaborator

4t145 commented Jun 18, 2025

Current SDK requires nightly Rust which limits usage scenarios. Many production environments prefer stable versions.
当前SDK需要nightly Rust才能使用,这限制了用户的使用场景。许多生产环境更倾向于使用stable版本。

No, current sdk requires 1.85, which is stable since early 2025.

Check this: https://forge.rust-lang.org/

@cn-kali-team
Copy link
Author

I hope it can run on the Win7 operating system, but the Rust support version for Win7 is 1.77.2, so I hope it can be backward compatible to the 2021 editing version, just modify the edition to 2021
我希望可以在win7操作系统运行,但是win7最后rust支持版本为1.77.2,所以希望可以向下兼容到2021年的edition,只需要修改edition为2021就可以了

@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

@cn-kali-team Have you tried these toolchains?

https://doc.rust-lang.org/rustc/platform-support/win7-windows-msvc.html

After all, Win7 has been discontinued for a long time.

@cn-kali-team
Copy link
Author

When using x86_64-win7-windows-msvc, it's necessary to switch to the nightly Rust version. Additionally, the edition setting has a propagation effect - if upstream uses edition="2024", downstream must also use edition="2024". Otherwise, when using older Rust versions, the rmcp package cannot be found.

You can try creating a local test project with edition set to "2021":
[package]
name = "app"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main", features = ["server", "transport-io"] }

-This results in:

    with extra environment variables: TERM=ansi CARGO_TERM_PROGRESS_WHEN=always RUST_BACKTRACE=short RUSTC=/usr/bin/rustc CARGO_TERM_PROGRESS_WIDTH=80
stdout:     Updating git repository `ssh://[email protected]/modelcontextprotocol/rust-sdk`
error: no matching package named `rmcp` found
location searched: ssh://[email protected]/modelcontextprotocol/rust-sdk?branch=main

Caused by:
  failed to load source for dependency `rmcp`

Caused by:
  Unable to update https://github.com/modelcontextprotocol/rust-sdk?branch=main#
13e72ec6

Caused by:
  process didn't exit successfully: `git fetch --force --update-head-ok https://
github.com/modelcontextprotocol/rust-sdk +13e72ec6c494025b10e6861750a0dba3d3dcf4
c5:refs/commit/13e72ec6c494025b10e6861750a0dba3d3dcf4c5` (exit code: 128)

    Updating git repository `https://github.com/modelcontextprotocol/rust-sdk`
remote: Enumerating objects: 1600, done.
remote: Counting objects: 100% (787/787), done.
remote: Compressing objects: 100% (458/458), done.
remote: Total 1600 (delta 561), reused 331 (delta 329), pack-reused 813 (from 2)
Receiving objects: 100% (1600/1600), 568.68 KiB | 1.18 MiB/s, done.

Resolving deltas: 100% (738/738), done.
From https://github.com/modelcontextprotocol/rust-sdk
 * [new ref]         13e72ec6c494025b10e6861750a0dba3d3dcf4c5 -> refs/commit/13e
72ec6c494025b10e6861750a0dba3d3dcf4c5
error: no matching package named `rmcp` found
location searched: https://github.com/modelcontextprotocol/rust-sdk?branch=main#
13e72ec6
  • When setting edition to "2024":
[package]
name = "app"
version = "0.1.0"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main", features = ["server", "transport-io"] }

You get:

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature
is not stabilized in this version of Cargo (1.77.2 (e52e36006 2024-03-26)).
  Consider trying a newer version of Cargo (this may require the nightly release
).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-20
24 for more information about the status of this feature.

Finally, you can refer to reqwest's approach which works on older stable versions:
https://github.com/seanmonstar/reqwest/blob/1794d997373c71e9521ada8d3e2f98f36b6aad59/Cargo.toml#L12C1-L12C17


使用x86_64-win7-windows-msvc需要切换到nightly版本,而且edition具有传染性,上游使用了edition="2024",下游也必须使用edition="2024",不然在使用第版本的rust会出现找不到rmcp包

  • 你可以是试试在本地创建一个测试项目,将edition设置为2021
[package]
name = "app"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main", features = ["server", "transport-io"] }
  • 可以得到
    with extra environment variables: TERM=ansi CARGO_TERM_PROGRESS_WHEN=always RUST_BACKTRACE=short RUSTC=/usr/bin/rustc CARGO_TERM_PROGRESS_WIDTH=80
stdout:     Updating git repository `ssh://[email protected]/modelcontextprotocol/rust-sdk`
error: no matching package named `rmcp` found
location searched: ssh://[email protected]/modelcontextprotocol/rust-sdk?branch=main

Caused by:
  failed to load source for dependency `rmcp`

Caused by:
  Unable to update https://github.com/modelcontextprotocol/rust-sdk?branch=main#
13e72ec6

Caused by:
  process didn't exit successfully: `git fetch --force --update-head-ok https://
github.com/modelcontextprotocol/rust-sdk +13e72ec6c494025b10e6861750a0dba3d3dcf4
c5:refs/commit/13e72ec6c494025b10e6861750a0dba3d3dcf4c5` (exit code: 128)

    Updating git repository `https://github.com/modelcontextprotocol/rust-sdk`
remote: Enumerating objects: 1600, done.
remote: Counting objects: 100% (787/787), done.
remote: Compressing objects: 100% (458/458), done.
remote: Total 1600 (delta 561), reused 331 (delta 329), pack-reused 813 (from 2)
Receiving objects: 100% (1600/1600), 568.68 KiB | 1.18 MiB/s, done.

Resolving deltas: 100% (738/738), done.
From https://github.com/modelcontextprotocol/rust-sdk
 * [new ref]         13e72ec6c494025b10e6861750a0dba3d3dcf4c5 -> refs/commit/13e
72ec6c494025b10e6861750a0dba3d3dcf4c5
error: no matching package named `rmcp` found
location searched: https://github.com/modelcontextprotocol/rust-sdk?branch=main#
13e72ec6
  • 当你设置edition为2024的时候
[package]
name = "app"
version = "0.1.0"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "main", features = ["server", "transport-io"] }
  • 你可以得到
Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature
is not stabilized in this version of Cargo (1.77.2 (e52e36006 2024-03-26)).
  Consider trying a newer version of Cargo (this may require the nightly release
).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-20
24 for more information about the status of this feature.

@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

I tried this in windows 11.

rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
cargo +nightly build --target x86_64-win7-windows-msvc -Zbuild-std --all-features

It seems works well in edition 2024?

Also checked in another project
图片

So could you accept to build your project in nightly toolchain and change the rust edition to 2024? After all, windows 7 are discontinued since 2020. I think it's not worthy to give up all the new features after 1.82 to support a discontinued system.

@cn-kali-team
Copy link
Author

I know this is feasible, but I hope to use the stable version to build the window7 program. Changing the edition to 2021 will not affect your use of Rust's new features because the stable version is backward compatible. What I mean is that you can relax the Rust version to allow more people to use it

我知道这样可行,但是我希望使用stable版本构建window7程序,将edition修改为2021并不会影响你使用rust的新功能,因为stable版本是向后兼容的,我的意思是你可以把rust版本放宽点可以让更多的人使用

@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

将edition修改为2021并不会影响你使用rust的新功能,因为stable版本是向后兼容的,我的意思是你可以把rust版本放宽点可以让更多的人使用

But in this crate, we cannot use the lastest features. 🥲🥲🥲

@jokemanfire what's your opinion on this?

@jokemanfire
Copy link
Collaborator

Although this makes sense, from the perspective of maintainers, I still hope to limit higher versions of the Rust toolchain, especially for some third-party libraries that will elevate higher toolchain versions in subsequent updates. If users encounter problems using lower version toolchains, it will undoubtedly increase our workload.

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-dependencies Dependencies related changes T-examples Example code changes T-handler Handler implementation changes T-service Service layer changes T-transport Transport layer changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants