Skip to content

Tool not listed in response #174

Open
@7sedam7

Description

@7sedam7

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:

  1. Compile above code
  2. build the release version
  3. Run npx @modelcontextprotocol/inspector
  4. Set path to release built under arguments and click connect
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions