Is the README example Tool registration method incorrect?

未关闭
#128 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

  • #251 来自 @systemblueio —— 已关闭,未合并
  • #253 来自 @ZhouYinLong-lab —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
swift
领域
api, documentation

调研方向

Start with the README Tool registration example and compare its inputSchema with the object schema shown in the issue. Check the Swift Tool API to determine which form is accepted, then update the README example to match the working registration format and verify the documented example is consistent with the API.

由索引模型根据 Issue 内容生成。

描述

bug

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.

主要语言
Swift
星标
1.6k
派生
270
平均合并
2 天 7 小时
30 天内合并 PR
15

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/swift-sdk 的其他 Issue

查看 modelcontextprotocol/swift-sdk 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。