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:
Koichi ITO 2025-09-03 02:13:39 +09:00
commit 47d29e8014

View file

@ -771,7 +771,7 @@ module MCP
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
end
test "server uses default title when not configured" do
test "server response does not include title when not configured" do
server = Server.new(name: "test_server")
request = {
jsonrpc: "2.0",
@ -780,7 +780,7 @@ module MCP
}
response = server.handle(request)
assert_nil response[:result][:serverInfo][:title]
refute response[:result][:serverInfo].key?(:title)
end
test "server uses default version when not configured" do