Skip to content

Tool listing returns unnecessary fields #847

@fpoli

Description

@fpoli

Describe the bug

The list tools call returns unnecessary fields. To me, this seems unintended.

To Reproduce

Declare a tool

/// Parameters for adding two numbers.
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
struct AddRequest {
    /// The left-hand number.
    a: f64,
    /// The right-hand number.
    b: f64,
}

/// Add two numbers.
#[rmcp::tool]
fn add(Parameters(AddRequest { a, b }): Parameters<AddRequest>) -> String {
    (a + b).to_string()
}

The list tools call currently returns

{
    "name": "add",
    "description": "Add two numbers.",
    "inputSchema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "description": "Parameters for adding two numbers.",
        "title": "AddRequest",
        "type": "object",
        "properties": {
            "a": {
                "description": "The left-hand number.",
                "format": "double",
                "type": "number"
            },
            "b": {
                "description": "The right-hand number.",
                "format": "double",
                "type": "number"
            }
        },
        "required": [
            "a",
            "b"
        ]
    }
}

Expected behavior

The same answer, but without the fields with Parameters for adding two numbers and AddRequest:

{
    "name": "add",
    "description": "Add two numbers.",
    "inputSchema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
            "a": {
                "description": "The left-hand number.",
                "format": "double",
                "type": "number"
            },
            "b": {
                "description": "The right-hand number.",
                "format": "double",
                "type": "number"
            }
        },
        "required": [
            "a",
            "b"
        ]
    }
}

Since 2020-12 is the default schema, we could even say that to minimize the answer the $schema can be omitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions