Description
Describe the bug
I'm trying to setup a basic MCP STDIO server with rmcp. I looked at their calculator example and made this:
use rmcp::{
handler::server::wrapper::Json,
model::{Implementation, ProtocolVersion, ServerCapabilities, ServerInfo},
schemars, tool, tool_box, ServiceExt,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = TestService {};
server.serve(rmcp::transport::stdio()).await?;
Ok(())
}
#[derive(Debug, Clone)]
struct TestService {}
#[tool(tool_box)]
impl TestService {
#[tool(description = "test")]
fn get_documents(
&self,
#[tool(param)]
#[schemars(description = "Search query")]
search_query: String,
) -> Json<Vec<String>> {
Json(vec!["test".to_string(), search_query])
}
//tool_box!(TestService { get_documents });
}
#[tool(tool_box)]
impl rmcp::ServerHandler for TestService {
//tool_box!(@derive);
fn get_info(&self) -> ServerInfo {
ServerInfo {
instructions: Some("test".to_string()),
capabilities: ServerCapabilities::builder().enable_tools().build(),
server_info: Implementation::from_build_env(),
protocol_version: ProtocolVersion::LATEST,
}
}
//fn list_tools(
// &self,
// request: Option<PaginatedRequestParam>,
// context: RequestContext<RoleServer>,
//) -> ListToolsResult {
//}
}
To test it I'm using: npx @modelcontextprotocol/inspector
and my server is visible, however, no tool are returned.
I tried with #[tool(tool_box)] anotation, and this direct usage based on their example and mcp inspector always gets empty response for the list of tools...
I was trying to play with implementing list_tools myself, but it complains it's a dupplicate of this #[tool....] anotation, so i'm guessing that should automatically get the list of tools i annotated. (so i did not finish with manual list_tools implementation, signature was complicated.)
To Reproduce
Steps to reproduce the behavior:
- Compile above code
- build the release version
- Run
npx @modelcontextprotocol/inspector
- Set path to release built under arguments and click connect
- Look how initialize request (or if you click on tools) does not return
get_documents
function that is declaired as tool
Expected behavior
I expect my function to be listed as a tool...
I appologise if this is not a bug, but i don't understand how this is suppose to work. I'll appreciate explanation, or link to more info.