Skip to content

Is the README example Tool registration method incorrect? #128

Open

Description

@Kila2

Describe the bug
Is the README example Tool registration method incorrect?
Using the example from the README, I get an error saying that the inputSchema is expected to be an object.

Example from the README:

Tool(
    name: "weather",
    description: "Get current weather for a location",
    inputSchema: .object([
        "location": .string("City name or coordinates"),
        "units": .string("Units of measurement, e.g., metric, imperial")
    ])
)

When I try this format, I get the expected response:

Tool(
    name: "weather",
    description: "Get current weather for a location",
    inputSchema: .object([
        "type": "object",
        "properties": [
            "a": ["type": "number"],
            "b": ["type": "number"]
        ],
        "required": ["a", "b"]
    ])
)

To Reproduce
Steps to reproduce the behavior:
1.

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Activity

  1. added
    bugSomething isn't working
    on Jun 5, 2025
  2. richard-giantrobot commented on Jun 5, 2025

    @richard-giantrobot

    I was getting the same error, thanks to your code snippet it started working. Thank you @Kila2, how did you figure it out?

  3. Kila2 commented on Jun 5, 2025

    @Kila2
    Author

    I found that the input mode for MCP servers to send messages to clients is "{}", but the MCP protocol requires a "type" field, that's all

  4. ptliddle commented on Jun 14, 2025

    @ptliddle

    No, see #131 (comment) for more context. It currently isn't producing valid JSON Schema output.

  5. samkudr commented on Sep 9, 2025

    @samkudr
    Contributor

    Is the README example Tool registration method incorrect?

    Yes, it misses inputSchema.type property. If #161 would be approved, at least partially, it will fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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