Skip to content

Commit db8fe94

Browse files
authored
feat: upgrade to rust-mcp-sdk 0.8.x and MCP 2025-11-25 (#73)
* feat: update to mcp 2025-11-25 * chore: update deprecated * chore: bring back ommited history * chore: keep one icon only * chore: fix clippy
1 parent 8656d9f commit db8fe94

30 files changed

Lines changed: 392 additions & 64 deletions

Cargo.lock

Lines changed: 72 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ license = false
1515
eula = false
1616

1717
[dependencies]
18-
rust-mcp-sdk = {version="0.7", default-features = false, features = [
18+
rust-mcp-sdk = {version="0.8", default-features = false, features = [
1919
"server",
2020
"macros",
21-
"stdio",
22-
"2025_06_18",
21+
"stdio"
2322
] }
2423

2524
thiserror = { version = "2.0" }

docs/_media/favicon.png

100755100644
File mode changed.

docs/capabilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,4 @@
344344

345345

346346
<sup>◾ generated by [mcp-discovery](https://github.com/rust-mcp-stack/mcp-discovery)</sup>
347-
<!-- mcp-discovery-render-end -->
347+
<!-- mcp-discovery-render-end -->

src/fs_service/io/read.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,25 @@ use tokio::{
2020
const MAX_CONCURRENT_FILE_READ: usize = 5;
2121

2222
impl FileSystemService {
23-
pub async fn read_text_file(&self, file_path: &Path) -> ServiceResult<String> {
23+
pub async fn read_text_file(
24+
&self,
25+
file_path: &Path,
26+
with_line_numbers: bool,
27+
) -> ServiceResult<String> {
2428
let allowed_directories = self.allowed_directories().await;
2529
let valid_path = self.validate_path(file_path, allowed_directories)?;
2630
let content = tokio::fs::read_to_string(valid_path).await?;
27-
Ok(content)
31+
32+
if with_line_numbers {
33+
Ok(content
34+
.lines()
35+
.enumerate()
36+
.map(|(i, line)| format!("{:>6} | {}", i + 1, line))
37+
.collect::<Vec<_>>()
38+
.join("\n"))
39+
} else {
40+
Ok(content)
41+
}
2842
}
2943

3044
/// Reads the first n lines from a text file, preserving line endings.
@@ -116,7 +130,7 @@ impl FileSystemService {
116130
let start_pos = if line_count <= n {
117131
0 // Read from start if fewer than n lines
118132
} else {
119-
*newline_positions.get(n-1).unwrap_or(&0) + 1
133+
*newline_positions.get(n - 1).unwrap_or(&0) + 1
120134
};
121135

122136
// Read forward from start_pos

src/handler.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use crate::{error::ServiceResult, fs_service::FileSystemService, tools::*};
55
use async_trait::async_trait;
66
use rust_mcp_sdk::McpServer;
77
use rust_mcp_sdk::mcp_server::ServerHandler;
8-
use rust_mcp_sdk::schema::RootsListChangedNotification;
98
use rust_mcp_sdk::schema::{
10-
CallToolRequest, CallToolResult, InitializeRequest, InitializeResult, ListToolsRequest,
11-
ListToolsResult, RpcError, schema_utils::CallToolError,
9+
CallToolRequestParams, InitializeRequestParams, NotificationParams, PaginatedRequestParams,
10+
};
11+
use rust_mcp_sdk::schema::{
12+
CallToolResult, InitializeResult, ListToolsResult, RpcError, schema_utils::CallToolError,
1213
};
1314
use std::cmp::Ordering;
1415
use std::sync::Arc;
@@ -94,7 +95,7 @@ impl FileSystemHandler {
9495
// client supports roots
9596
let fs_service = self.fs_service.clone();
9697
// retrieve roots from the client and update the allowed directories accordingly
97-
let roots = match runtime.clone().list_roots(None).await {
98+
let roots = match runtime.clone().request_root_list(None).await {
9899
Ok(roots_result) => roots_result.roots,
99100
Err(_err) => {
100101
vec![]
@@ -144,7 +145,7 @@ impl ServerHandler for FileSystemHandler {
144145

145146
async fn handle_roots_list_changed_notification(
146147
&self,
147-
_notification: RootsListChangedNotification,
148+
_params: Option<NotificationParams>,
148149
runtime: Arc<dyn McpServer>,
149150
) -> std::result::Result<(), RpcError> {
150151
if self.mcp_roots_support {
@@ -160,7 +161,7 @@ impl ServerHandler for FileSystemHandler {
160161

161162
async fn handle_list_tools_request(
162163
&self,
163-
_: ListToolsRequest,
164+
_params: Option<PaginatedRequestParams>,
164165
_: Arc<dyn McpServer>,
165166
) -> std::result::Result<ListToolsResult, RpcError> {
166167
Ok(ListToolsResult {
@@ -172,33 +173,29 @@ impl ServerHandler for FileSystemHandler {
172173

173174
async fn handle_initialize_request(
174175
&self,
175-
initialize_request: InitializeRequest,
176+
params: InitializeRequestParams,
176177
runtime: Arc<dyn McpServer>,
177178
) -> std::result::Result<InitializeResult, RpcError> {
178179
runtime
179-
.set_client_details(initialize_request.params.clone())
180+
.set_client_details(params.clone())
180181
.await
181182
.map_err(|err| RpcError::internal_error().with_message(format!("{err}")))?;
182183

183184
let mut server_info = runtime.server_info().to_owned();
184185
// Provide compatibility for clients using older MCP protocol versions.
185-
if server_info
186-
.protocol_version
187-
.cmp(&initialize_request.params.protocol_version)
188-
== Ordering::Greater
189-
{
190-
server_info.protocol_version = initialize_request.params.protocol_version;
186+
if server_info.protocol_version.cmp(&params.protocol_version) == Ordering::Greater {
187+
server_info.protocol_version = params.protocol_version;
191188
}
192189
Ok(server_info)
193190
}
194191

195192
async fn handle_call_tool_request(
196193
&self,
197-
request: CallToolRequest,
194+
params: CallToolRequestParams,
198195
_: Arc<dyn McpServer>,
199196
) -> std::result::Result<CallToolResult, CallToolError> {
200197
let tool_params: FileSystemTools =
201-
FileSystemTools::try_from(request.params).map_err(CallToolError::new)?;
198+
FileSystemTools::try_from(params).map_err(CallToolError::new)?;
202199

203200
// Verify write access for tools that modify the file system
204201
if tool_params.require_write_access() {

src/server.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
use crate::handler::FileSystemHandler;
22
use crate::{cli::CommandArguments, error::ServiceResult};
3+
use rust_mcp_sdk::mcp_server::McpServerOptions;
34
use rust_mcp_sdk::schema::{
4-
Implementation, InitializeResult, LATEST_PROTOCOL_VERSION, ServerCapabilities,
5-
ServerCapabilitiesTools,
5+
Implementation, InitializeResult, ProtocolVersion, ServerCapabilities, ServerCapabilitiesTools,
66
};
77
use rust_mcp_sdk::{McpServer, StdioTransport, TransportOptions, mcp_server::server_runtime};
8+
use rust_mcp_sdk::{ToMcpServerHandler, mcp_icon};
89

910
pub fn server_details() -> InitializeResult {
1011
InitializeResult {
1112
server_info: Implementation {
1213
name: "rust-mcp-filesystem".to_string(),
1314
version: env!("CARGO_PKG_VERSION").to_string(),
14-
title:Some("Filesystem MCP Server: fast and efficient tools for managing filesystem operations.".to_string())
15+
title: Some("Filesystem MCP Server".to_string()),
16+
description: Some(
17+
"A fast and efficient tools for managing filesystem operations.".to_string(),
18+
),
19+
icons: vec![mcp_icon!(
20+
src = "https://rust-mcp-stack.github.io/rust-mcp-filesystem/_media/rust-mcp-filesystem-128.png",
21+
mime_type = "image/png",
22+
sizes = ["128x128"]
23+
)],
24+
website_url: Some("https://rust-mcp-stack.github.io/rust-mcp-filesystem".into()),
1525
},
1626
capabilities: ServerCapabilities {
1727
experimental: None,
@@ -20,18 +30,25 @@ pub fn server_details() -> InitializeResult {
2030
resources: None,
2131
tools: Some(ServerCapabilitiesTools { list_changed: None }),
2232
completions: None,
33+
tasks: None,
2334
},
2435
instructions: None,
2536
meta: None,
26-
protocol_version: LATEST_PROTOCOL_VERSION.to_string(),
37+
protocol_version: ProtocolVersion::V2025_06_18.to_string(),
2738
}
2839
}
2940

3041
pub async fn start_server(args: CommandArguments) -> ServiceResult<()> {
3142
let transport = StdioTransport::new(TransportOptions::default())?;
3243

3344
let handler = FileSystemHandler::new(&args)?;
34-
let server = server_runtime::create_server(server_details(), transport, handler);
45+
let server = server_runtime::create_server(McpServerOptions {
46+
server_details: server_details(),
47+
handler: handler.to_mcp_server_handler(),
48+
task_store: None,
49+
client_task_store: None,
50+
transport,
51+
});
3552

3653
server.start().await?;
3754

src/tools/calculate_directory_size.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ pub enum FileSizeOutputFormat {
2323
destructive_hint = false,
2424
idempotent_hint = false,
2525
open_world_hint = false,
26-
read_only_hint = true
26+
read_only_hint = true,
27+
icons = [
28+
(src = "https://rust-mcp-stack.github.io/rust-mcp-filesystem/_media/tool_icons/calculate_directory_size.png",
29+
mime_type = "image/png",
30+
sizes = ["128x128"])
31+
],
2732
)]
2833
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, JsonSchema)]
2934
pub struct CalculateDirectorySize {

src/tools/create_directory.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ use crate::fs_service::FileSystemService;
1717
destructive_hint = false,
1818
idempotent_hint = false,
1919
open_world_hint = false,
20-
read_only_hint = false
20+
read_only_hint = false,
21+
icons = [
22+
(src = "https://rust-mcp-stack.github.io/rust-mcp-filesystem/_media/tool_icons/create_directory.png",
23+
mime_type = "image/png",
24+
sizes = ["128x128"])
25+
],
2126
)]
2227
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, JsonSchema)]
2328
pub struct CreateDirectory {

src/tools/directory_tree.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ use crate::fs_service::FileSystemService;
1818
destructive_hint = false,
1919
idempotent_hint = false,
2020
open_world_hint = false,
21-
read_only_hint = true
21+
read_only_hint = true,
22+
icons = [
23+
(src = "https://rust-mcp-stack.github.io/rust-mcp-filesystem/_media/tool_icons/directory_tree.png",
24+
mime_type = "image/png",
25+
sizes = ["128x128"])
26+
],
2227
)]
2328
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, JsonSchema)]
2429
pub struct DirectoryTree {

0 commit comments

Comments
 (0)