Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions examples/servers/src/common/counter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::sync::Arc;

use rmcp::{
Error as McpError, RoleServer, ServerHandler, const_string, model::*, schemars,
service::RequestContext, tool,
Error as McpError, RoleServer, ServerHandler, model::*, schemars, service::RequestContext, tool,
};
use serde_json::json;
use tokio::sync::Mutex;
Expand All @@ -26,10 +25,6 @@ impl Counter {
}
}

fn _create_resource_text(&self, uri: &str, name: &str) -> Resource {
RawResource::new(uri, name.to_string()).no_annotation()
}

#[tool(description = "Increment the counter by 1")]
async fn increment(&self) -> Result<CallToolResult, McpError> {
let mut counter = self.counter.lock().await;
Expand Down Expand Up @@ -81,7 +76,7 @@ impl Counter {
)]))
}
}
const_string!(Echo = "echo");

#[tool(tool_box)]
impl ServerHandler for Counter {
fn get_info(&self) -> ServerInfo {
Expand All @@ -102,10 +97,13 @@ impl ServerHandler for Counter {
_request: Option<PaginatedRequestParam>,
_: RequestContext<RoleServer>,
) -> Result<ListResourcesResult, McpError> {
fn create_resource_text(uri: &str, name: &str) -> Resource {
RawResource::new(uri, name.to_string()).no_annotation()
}
Ok(ListResourcesResult {
resources: vec![
self._create_resource_text("str:////Users/to/some/path/", "cwd"),
self._create_resource_text("memo://insights", "memo-name"),
create_resource_text("str:////Users/to/some/path/", "cwd"),
create_resource_text("memo://insights", "memo-name"),
],
next_cursor: None,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-chat-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", features = [
"client",
"transport-child-process",
"transport-sse",
], no-default-features = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This had no effect like in #112. Setting default-features = false does not compile so I just removed it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry , I didn't meet this problem, could you pls provide more detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhm yes I'll try. The setting no-default-features does not exists, so no-default-features = true is ignored by Cargo. The setting should be default-features = true, but if you set that the code does not compile. So that's why I removed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The confusion might be because of cargo build --no-default-features. That is a valid option.

] }
Loading