Update inputSchema example usage (#136)

* Update Tool inputSchema in README example usage

* Update inputSchema usage in Tool tests
This commit is contained in:
Mattt 2025-06-12 02:57:04 -07:00 • committed by GitHub
commit 36865fb056
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 12 deletions

View file

@ -434,16 +434,20 @@ server.withMethodHandler(ListTools.self) { _ in
name: "weather", name: "weather",
description: "Get current weather for a location", description: "Get current weather for a location",
inputSchema: .object([ inputSchema: .object([
"properties": .object([
"location": .string("City name or coordinates"), "location": .string("City name or coordinates"),
"units": .string("Units of measurement, e.g., metric, imperial") "units": .string("Units of measurement, e.g., metric, imperial")
]) ])
])
), ),
Tool( Tool(
name: "calculator", name: "calculator",
description: "Perform calculations", description: "Perform calculations",
inputSchema: .object([ inputSchema: .object([
"properties": .object([
"expression": .string("Mathematical expression to evaluate") "expression": .string("Mathematical expression to evaluate")
]) ])
])
) )
] ]
return .init(tools: tools) return .init(tools: tools)

View file

@ -11,8 +11,10 @@ struct ToolTests {
name: "test_tool", name: "test_tool",
description: "A test tool", description: "A test tool",
inputSchema: .object([ inputSchema: .object([
"properties": .object([
"param1": .string("Test parameter") "param1": .string("Test parameter")
]) ])
])
) )
#expect(tool.name == "test_tool") #expect(tool.name == "test_tool")
@ -100,7 +102,9 @@ struct ToolTests {
name: "calculate", name: "calculate",
description: "Performs calculations", description: "Performs calculations",
inputSchema: .object([ inputSchema: .object([
"properties": .object([
"expression": .string("Mathematical expression to evaluate") "expression": .string("Mathematical expression to evaluate")
])
]), ]),
annotations: annotations annotations: annotations
) )
@ -179,9 +183,11 @@ struct ToolTests {
name: "test_tool", name: "test_tool",
description: "Test tool description", description: "Test tool description",
inputSchema: .object([ inputSchema: .object([
"properties": .object([
"param1": .string("String parameter"), "param1": .string("String parameter"),
"param2": .int(42), "param2": .int(42),
]) ])
])
) )
let encoder = JSONEncoder() let encoder = JSONEncoder()