Fix errors when title is not specified
Since the optional `title` becomes `title: null` when not provided, the following error occurs.
This occurs with Claude Code 1.0.100.
```console
[DEBUG] MCP server "example": Connection failed after 1591ms: [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": [
"serverInfo",
"title"
],
"message": "Expected string, received null"
}
]
```
By adding `compact`, the `title` key will be removed if the optional `title` keyword argument is not specified.
This commit is contained in:
parent
eb0d9c0e6d
commit
47d29e8014
1 changed files with 12 additions and 4 deletions
|
|
@ -33,6 +33,14 @@ module MCP
|
|||
assert_equal({ name: "mock_tool", title: "Mock Tool", description: "a mock tool for testing", inputSchema: { type: "object" } }, tool.to_h)
|
||||
end
|
||||
|
||||
test "#to_h does not have `:title` key when title is omitted" do
|
||||
tool = Tool.define(
|
||||
name: "mock_tool",
|
||||
description: "a mock tool for testing",
|
||||
)
|
||||
refute tool.to_h.key?(:title)
|
||||
end
|
||||
|
||||
test "#to_h includes annotations when present" do
|
||||
tool = TestTool
|
||||
expected_annotations = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue