Skip to content

Types with generics do not work with tool macro #91

Open
@chwzr

Description

@chwzr

Describe the bug
When I try to use the toolbox macro on a type that has generics, it will not work

To Reproduce

#[tool(tool_box)]
impl<GS: GraphService> GraphMcp<GS> {
    pub fn new(graph_service: GS) -> Self {
        Self {
            graph_service: Arc::new(graph_service),
        }
    }

    #[tool(description = "Get a list of nodes")]
    async fn list_nodes(&self) -> Result<CallToolResult, McpError> {
        Ok(CallToolResult::success(vec![]))
    }
}
// const_string!(Echo = "echo");
#[tool(tool_box)]
impl<GS: GraphService> ServerHandler for GraphMcp<GS> {
    fn get_info(&self) -> ServerInfo {
        ServerInfo {
            protocol_version: ProtocolVersion::V_2024_11_05,
            capabilities: ServerCapabilities::builder().enable_tools().build(),
            server_info: Implementation::from_build_env(),
            instructions: Some("This server provides access to the DataCards API.".to_string()),
        }
    }
}

Expected behavior
macro works with types which have Generics

Logs

17 | impl<GS: GraphService> DataCardsMcp<GS> {
   |                                    ^ no rules expected this token in macro call
   |
note: while trying to match `{`
  --> /Users/work/.cargo/git/checkouts/rust-sdk-773cd6d57c4837f3/6a74451/crates/rmcp/src/handler/server/tool.rs:431:21


Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions